costin      2002/10/08 11:46:43

  Modified:    naming   build.xml
               naming/src jndi.properties
               naming/src/org/apache/naming/ant JndiProperties.java
               naming/src/org/apache/naming/core BaseDirContext.java
                        ContextAccessController.java DirContextHelper.java
                        NamingContextEnumeration.java
               naming/src/org/apache/naming/modules/fs FileDirContext.java
                        fsURLContextFactory.java
               naming/src/org/apache/naming/modules/java
                        SelectorContext.java javaURLContextFactory.java
               naming/src/org/apache/naming/modules/memory
                        MemoryNamingContext.java
               naming/src/org/apache/naming/res LocalStrings.properties
  Added:       naming/src/org/apache/naming/ant JndiEnv.java
               naming/src/org/apache/naming/core BaseNamingImpl.java
                        NamingEntry.java
  Removed:     naming/src/org/apache/naming/modules/memory NamingEntry.java
  Log:
  Few fixes. It should now work ( including the test target ). It requires
  ant-sax2.jar, from ant/proposals/embed ( for testing and to compile
  the ant hooks ).
  
  I'll probably move the ant-specific stuff into embed.
  
  Revision  Changes    Path
  1.2       +6 -6      jakarta-tomcat-connectors/naming/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/naming/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml 25 Sep 2002 19:32:17 -0000      1.1
  +++ build.xml 8 Oct 2002 18:46:42 -0000       1.2
  @@ -33,12 +33,6 @@
           <pathelement location="${jndi.home}/lib/jndibrowser.jar"/>
       </path>
   
  -    <systemPath pathRef="build-main.classpath" />
  -    <taskdef name="jndiSet" classname="org.apache.naming.ant.JndiSet"/>
  -    <taskdef name="jndiProperties" 
classname="org.apache.naming.ant.JndiProperties"/>
  -    <taskdef name="jndiFileCtx" classname="org.apache.naming.file.FileDirContext"/>
  -
  -    <jndiProperties/>
    
       <target name="main"  >
           <mkdir dir="${naming.build.dir}/classes"/>
  @@ -57,6 +51,12 @@
       </target>
   
     <target name="test"  >
  +    <systemPath pathRef="build-main.classpath" />
  +    <taskdef name="jndiSet" classname="org.apache.naming.ant.JndiSet"/>
  +    <taskdef name="jndiProperties" 
classname="org.apache.naming.ant.JndiProperties"/>
  +    <taskdef name="jndiFileCtx" 
classname="org.apache.naming.modules.fs.FileDirContext"/>
  +
  +    <jndiProperties/>
       <jndiSet context="/foo" value="bar" />
   
       <jndiFileCtx docBase="/tmp" id="docBaseId" />
  
  
  
  1.2       +2 -2      jakarta-tomcat-connectors/naming/src/jndi.properties
  
  Index: jndi.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/jndi.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jndi.properties   25 Sep 2002 19:26:53 -0000      1.1
  +++ jndi.properties   8 Oct 2002 18:46:42 -0000       1.2
  @@ -2,5 +2,5 @@
   #java.naming.factory.state=
   #java.naming.factory.control=
   
  -java.naming.factory.initial=org.apache.naming.memory.memoryURLContextFactory
  -java.naming.factory.url.pkgs=org.apache.naming
  \ No newline at end of file
  +java.naming.factory.initial=org.apache.naming.modules.memory.memoryURLContextFactory
  +java.naming.factory.url.pkgs=org.apache.naming.modules
  
  
  
  1.2       +5 -1      
jakarta-tomcat-connectors/naming/src/org/apache/naming/ant/JndiProperties.java
  
  Index: JndiProperties.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/ant/JndiProperties.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JndiProperties.java       25 Sep 2002 19:29:17 -0000      1.1
  +++ JndiProperties.java       8 Oct 2002 18:46:42 -0000       1.2
  @@ -87,7 +87,11 @@
   //         System.setProperty( "java.naming.factory.initial", 
"org.apache.naming.memory.MemoryInitialContextFactory" );
       }
       
  -    public Object getProperty( Project p, String ns, String name ) {
  +    public boolean setProperty( Object p, String ns, String name, Object value ) {
  +        return false;
  +    }
  +
  +    public Object getProperty( Object p, String ns, String name ) {
           if( ! name.startsWith( PREFIX ) )
               return null;
           
  
  
  
  1.1                  
jakarta-tomcat-connectors/naming/src/org/apache/naming/ant/JndiEnv.java
  
  Index: JndiEnv.java
  ===================================================================
  /*
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.naming.ant;
  
  import java.io.*;
  import java.util.*;
  
  import org.apache.tools.ant.*;
  
  import javax.naming.*;
  
  /**
   *  Task to set up JNDI properties ( the hashtable that is passed to InitialContext )
   *  It has explicit attributes for common properties, and supports generic name/value
   *  elements.
   * 
   * @author  Costin Manolache
   */
  public class JndiEnv extends Task  {
   
      Hashtable env = new Hashtable();
      String url;
      boolean topLevel=true;
      
      public JndiEnv() {
      }
      
      public JndiEnv(boolean child) {
          topLevel=false;
      }
      
      public String getProviderUrl() {
          return (String) env.get(Context.PROVIDER_URL);
      }
      
      public void setProviderUrl(String providerUrl) {
          env.put(Context.PROVIDER_URL, providerUrl);
      }
  
      public String getUrl() {
          return url;
      }
  
      public void setUrl(String url) {
          this.url = url;
      }
  
      public String getInitialFactory() {
          return (String) env.get(Context.INITIAL_CONTEXT_FACTORY);
      }
  
      public void setInitialFactory(String initialFactory) {
          env.put(Context.INITIAL_CONTEXT_FACTORY, initialFactory);
      }
  
      public String getAuthoritative() {
          return (String) env.get(Context.AUTHORITATIVE);
      }
  
      public void setAuthoritative(String authoritative) {
          env.put(Context.AUTHORITATIVE, authoritative);
      }
  
      public String getObjectFactories() {
          return (String) env.get(Context.OBJECT_FACTORIES);
      }
  
      public void setObjectFactories(String objectFactories) {
          env.put(Context.OBJECT_FACTORIES, objectFactories);
      }
  
      public String getUrlPkgPrefixes() {
          return (String) env.get(Context.URL_PKG_PREFIXES);
      }
  
      public void setUrlPkgPrefixes(String urlPkgPrefixes) {
          env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
      }
  
      public void execute() {
          if( nvEntries!=null ) {
              for( int i=0; i<nvEntries.size(); i++ ) {
                  NameValue nv=(NameValue)nvEntries.elementAt(i);
                  env.put( nv.name, nv.value);
              }
          }
          // If this is a standalone task - add a ref in the project.
          if(topLevel)
              project.addReference( "globalJndiEnv", this );
      }
  
      Vector nvEntries;
      
      public NameValue addEnv() {
          if( nvEntries==null ) nvEntries=new Vector();
          NameValue nv=new NameValue();
          nvEntries.addElement( nv );
          return nv;
      }
      
      public static class NameValue {
          String name;
          String value;
          
          public void setName(String name) {
              this.name=name;
          }
          public void setValue(String value) {
              this.value=value;
          }
      }
  }
  
  
  
  1.2       +5 -6      
jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseDirContext.java
  
  Index: BaseDirContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseDirContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseDirContext.java       1 Oct 2002 18:42:16 -0000       1.1
  +++ BaseDirContext.java       8 Oct 2002 18:46:42 -0000       1.2
  @@ -107,21 +107,20 @@
        * Builds a base directory context.
        */
       public BaseDirContext() {
  -        this( new Hashtable() );
  +        this.env=new Hashtable();
       }
   
       /**
        * Builds a base directory context using the given environment.
        */
       public BaseDirContext(Hashtable env) {
  +        this.env=new Hashtable();
           if (env != null ) {
               Enumeration envEntries = env.keys();
               while (envEntries.hasMoreElements()) {
                   String entryName = (String) envEntries.nextElement();
                   this.env.put(entryName, env.get(entryName));
               }
  -        } else {
  -            this.env=new Hashtable();
           }
       }
   
  @@ -233,16 +232,16 @@
       
       /** The lookup method to implement
        */
  -    protected Object lookup(Name name, boolean resolveLinks, Object o)
  +    public Object lookup(Name name, boolean resolveLinks, Object o)
           throws NamingException
       {
  -        throws OperationNotSupportedException();
  +        throw new OperationNotSupportedException();
       }
   
       public void bind(Name name, Object obj, Attributes attrs, boolean rebind )
           throws NamingException
       {
  -        throws OperationNotSupportedException();
  +        throw new OperationNotSupportedException();
       }
       
       public void unbind(Name name, boolean isContext)
  
  
  
  1.2       +0 -2      
jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ContextAccessController.java
  
  Index: ContextAccessController.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ContextAccessController.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextAccessController.java      1 Oct 2002 18:42:16 -0000       1.1
  +++ ContextAccessController.java      8 Oct 2002 18:46:42 -0000       1.2
  @@ -165,7 +165,5 @@
       public static boolean isWritable(Object name) {
           return !(readOnlyContexts.containsKey(name));
       }
  -
  -
   }
   
  
  
  
  1.2       +16 -0     
jakarta-tomcat-connectors/naming/src/org/apache/naming/core/DirContextHelper.java
  
  Index: DirContextHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/DirContextHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DirContextHelper.java     1 Oct 2002 18:42:16 -0000       1.1
  +++ DirContextHelper.java     8 Oct 2002 18:46:42 -0000       1.2
  @@ -104,5 +104,21 @@
       public String toString(DirContext ctx) {
           return "";
       }
  +
  +    public int getIntAttribute( DirContext ctx, String name ) {
  +        return 0;
  +    }
  +
  +    public long getLongAttribute( DirContext ctx, String name ) {
  +        return 0;
  +    }
  +
  +    public String getStringAttribute( DirContext ctx, String name ) {
  +        return null;
  +    }
  +
  +    public boolean getBooleanAttribute( DirContext ctx, String name ) {
  +        return false;
  +    }
   }
   
  
  
  
  1.2       +3 -4      
jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NamingContextEnumeration.java
  
  Index: NamingContextEnumeration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NamingContextEnumeration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NamingContextEnumeration.java     1 Oct 2002 18:42:16 -0000       1.1
  +++ NamingContextEnumeration.java     8 Oct 2002 18:46:42 -0000       1.2
  @@ -75,7 +75,8 @@
    */
   
   public class NamingContextEnumeration 
  -    implements NamingEnumeration {
  +    implements NamingEnumeration
  +{
   
   
       // ----------------------------------------------------------- Constructors
  @@ -138,7 +139,5 @@
           NamingEntry entry = (NamingEntry) enum.nextElement();
           return new NameClassPair(entry.name, entry.value.getClass().getName());
       }
  -
  -
   }
   
  
  
  
  1.1                  
jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseNamingImpl.java
  
  Index: BaseNamingImpl.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.naming.core;
  
  import java.util.*;
  import javax.naming.*;
  import javax.naming.directory.DirContext;
  import javax.naming.directory.Attributes;
  import javax.naming.directory.Attribute;
  import javax.naming.directory.ModificationItem;
  import javax.naming.directory.SearchControls;
  import org.apache.tomcat.util.res.StringManager;
  
  /**
   * Base Directory Context implementation. All j-t-c/naming contexts should
   * extend it. 
   *
   *
   * @author Remy Maucherat
   * @author Costin Manolache
   */
  public class BaseNamingImpl {
  
      /**
       * Builds a base directory context.
       */
      public BaseNamingImpl() {
      }
  
  
      /** Configuration - called for all entries in the 'env'.
       *  The base implementation will call IntrospectionUtil and
       *  call explicit setter methods.
       */
      public void setEnv(String name, Object value ) {
  
      }
  
      /** The context facade that calls us.
       */
      public void setContext( Context ctx ) {
  
      }
      
      /**
       * 
       */
      public void recycle() {
      }
  
      // -------------------- Abstract methods -------------------- 
      // This is what a subclass should override
      
      /** The lookup method.
       */
      public Object lookup(Name name, boolean resolveLinks, Object o)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
      public void bind(Name name, Object obj, Attributes attrs, boolean rebind )
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
      
      public void unbind(Name name, boolean isContext)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
      public void size() throws NamingException
      {
          throw new OperationNotSupportedException("size");
      }
  
      public Name childNameAt( int i ) throws NamingException
      {
          return null;
      }
  
      public Object childAt( int i ) throws NamingException
      {
          return null;
      }
      
      public DirContext createSubcontext(Name name, Attributes attrs)
          throws NamingException
      {
          // XXX We can implement a decent default using bind and the current class.
          throw new OperationNotSupportedException();
      }
  
      public void rename(Name oldName, Name newName)
          throws NamingException
      {
          // Override if needed
          Object value = lookup(oldName, false, null);
          // XXX Copy attributes
          bind(newName, value, null, true);
          unbind(oldName, false);
      }
  
      public Attributes getAttributes(Name name, String[] attrIds)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }    
  }
  
  
  
  
  1.1                  
jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NamingEntry.java
  
  Index: NamingEntry.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.naming.core;
  
  import javax.naming.directory.*;
  
  /**
   * Represents a binding in a NamingContext. All jtc contexts should
   * use this class to represent entries.
   *
   * @author Remy Maucherat
   * @author Costin Manolache
   */
  public class NamingEntry {
  
  
      // -------------------------------------------------------------- Constants
  
  
      public static final int ENTRY = 0;
      public static final int LINK_REF = 1;
      public static final int REFERENCE = 2;
      
      public static final int CONTEXT = 10;
  
  
      // ----------------------------------------------------------- Constructors
  
  
      public NamingEntry(String name, Object value, Attributes atts, int type) {
          this.name = name;
          this.value = value;
          this.type = type;
          this.attributes=atts;
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The type instance variable is used to avoid unsing RTTI when doing
       * lookups.
       */
      public int type;
      public String name;
      public Object value;
  
      public Attributes attributes;
  
      // cached values
      private boolean hasIntValue=false;
      private boolean hasBoolValue=false;
      private boolean hasLongValue=false;
      
      private int intValue;
      private boolean boolValue;
      private long longValue;
  
      // --------------------------------------------------------- Object Methods
  
      public void recycle() {
      }
  
      public boolean equals(Object obj) {
          if ((obj != null) && (obj instanceof NamingEntry)) {
              return name.equals(((NamingEntry) obj).name);
          } else {
              return false;
          }
      }
  
      public int hashCode() {
          return name.hashCode();
      }
  
  }
  
  
  
  1.2       +11 -4     
jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/fs/FileDirContext.java
  
  Index: FileDirContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/fs/FileDirContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileDirContext.java       1 Oct 2002 18:45:19 -0000       1.1
  +++ FileDirContext.java       8 Oct 2002 18:46:43 -0000       1.2
  @@ -257,11 +257,16 @@
        * @return the object bound to name
        * @exception NamingException if a naming exception is encountered
        */
  -    public Object lookup(Name nameO, boolean resolveLinkx, Object o)
  +    public Object lookup(Name nameObj, boolean resolveLinkx, Object o)
           throws NamingException
       {
  -        if( log.isDebugEnabled() ) log.debug( "lookup " + nameO );
  -        String name=nameO.toString(); // we need to convert anyway, for File 
constructor
  +        if( log.isDebugEnabled() ) log.debug( "lookup " + nameObj );
  +
  +        System.out.println("XXX " + nameObj.get(0));
  +        if( "fs:".equals( nameObj.get(0).toString() ))
  +            nameObj=nameObj.getSuffix(1);
  +        
  +        String name=nameObj.toString(); // we need to convert anyway, for File 
constructor
           
           Object result = null;
           File file = file(name);
  @@ -302,6 +307,8 @@
       public void unbind(Name nameObj)
           throws NamingException
       {
  +        if( "fs:".equals( nameObj.get(0).toString() ))
  +            nameObj=nameObj.getSuffix(1);
           String name=nameObj.toString();
           if( log.isDebugEnabled() ) log.debug( "unbind " + name );
           File file = file(name);
  @@ -775,7 +782,7 @@
                   //object = new FileResource(currentFile);
                   object = currentFile;
               }
  -            entry = new NamingEntry(names[i], object, NamingEntry.ENTRY);
  +            entry = new NamingEntry(names[i], object, null, NamingEntry.ENTRY);
               entries.addElement(entry);
   
           }
  
  
  
  1.2       +1 -1      
jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/fs/fsURLContextFactory.java
  
  Index: fsURLContextFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/fs/fsURLContextFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- fsURLContextFactory.java  1 Oct 2002 18:45:19 -0000       1.1
  +++ fsURLContextFactory.java  8 Oct 2002 18:46:43 -0000       1.2
  @@ -65,7 +65,7 @@
   import javax.naming.NamingException;
   import javax.naming.spi.ObjectFactory;
   import javax.naming.spi.InitialContextFactory;
  -import org.apache.naming.memory.MemoryNamingContext;
  +import org.apache.naming.modules.memory.MemoryNamingContext;
   //import org.apache.naming.ContextBindings;
   
   /**
  
  
  
  1.2       +4 -2      
jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/java/SelectorContext.java
  
  Index: SelectorContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/java/SelectorContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectorContext.java      1 Oct 2002 18:46:30 -0000       1.1
  +++ SelectorContext.java      8 Oct 2002 18:46:43 -0000       1.2
  @@ -68,7 +68,7 @@
   import javax.naming.NamingException;
   
   import org.apache.tomcat.util.res.StringManager;
  -import org.apache.naming.memory.*;
  +import org.apache.naming.modules.memory.*;
   
   /* This delegates to another context, removing a prefix.
      XXX make it generic, move to core. The context thread can be
  @@ -674,7 +674,9 @@
               if (initialContext == null) {
                   // Allocating a new context and binding it to the appropriate 
                   // name
  -                initialContext = new MemoryNamingContext(env, ICName);
  +                // XXX Should return null, let the caller create something
  +                // Or use a different constructor.
  +                initialContext = new MemoryNamingContext(env);
                   ContextBindings.bindContext(ICName, initialContext);
               }
               return initialContext;
  
  
  
  1.2       +2 -2      
jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/java/javaURLContextFactory.java
  
  Index: javaURLContextFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/java/javaURLContextFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- javaURLContextFactory.java        1 Oct 2002 18:46:30 -0000       1.1
  +++ javaURLContextFactory.java        8 Oct 2002 18:46:43 -0000       1.2
  @@ -66,7 +66,7 @@
   import javax.naming.NamingException;
   import javax.naming.spi.ObjectFactory;
   import javax.naming.spi.InitialContextFactory;
  -import org.apache.naming.memory.MemoryNamingContext;
  +import org.apache.naming.modules.memory.MemoryNamingContext;
   //import org.apache.naming.ContextBindings;
   
   import org.apache.tomcat.util.res.StringManager;
  @@ -143,7 +143,7 @@
           } else {
               // If the thread is not bound, return a shared writable context
               if (initialContext == null)
  -                initialContext = new MemoryNamingContext(environment, MAIN);
  +                initialContext = new MemoryNamingContext(environment);
               return initialContext;
           }
       }
  
  
  
  1.2       +12 -9     
jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/memory/MemoryNamingContext.java
  
  Index: MemoryNamingContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/memory/MemoryNamingContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MemoryNamingContext.java  1 Oct 2002 18:46:06 -0000       1.1
  +++ MemoryNamingContext.java  8 Oct 2002 18:46:43 -0000       1.2
  @@ -273,13 +273,9 @@
       }
   
       // XXX Make it iterative, less objects
  -    private NamingEntry findNamingEntry(Name name, boolean resolveLinks)
  +    private NamingEntry findNamingEntry(Name name, boolean resolveLinks, Object o)
           throws NamingException
       {
  -        // Removing empty parts
  -        while ((!name.isEmpty()) && (name.get(0).length() == 0))
  -            name = name.getSuffix(1);
  -        
            if (name.isEmpty()) {
   //             // If name is empty, a newly allocated naming context is returned
   //             MemoryNamingContext mmc= new MemoryNamingContext(env);
  @@ -302,18 +298,25 @@
                   throw new NamingException
                       (sm.getString("namingContext.contextExpected"));
               }
  -            //            return ((Context) entry.value).lookup(name.getSuffix(1));
  -            return ((MemoryNamingContext) 
entry.value).findNamingEntry(name.getSuffix(1), resolveLinks);
  +            return entry;
           } else {
               return entry;
           }
       }
   
  -    protected Object lookup(Name name, boolean resolveLinks, Object o)
  +    public Object lookup(Name name, boolean resolveLinks, Object o)
           throws NamingException
       {
  -        NamingEntry entry=findNamingEntry( name, resolveLinks );
  +        // Removing empty parts
  +        while ((!name.isEmpty()) && (name.get(0).length() == 0))
  +            name = name.getSuffix(1);
  +        
  +        NamingEntry entry=findNamingEntry( name, resolveLinks, o );
   
  +        if( entry.type == NamingEntry.CONTEXT ) {
  +            return ((BaseDirContext) entry.value).lookup(name.getSuffix(1), 
resolveLinks, o);
  +        }
  +        
           if ((resolveLinks) && (entry.type == NamingEntry.LINK_REF)) {
               String link = ((LinkRef) entry.value).getLinkName();
               if (link.startsWith(".")) {
  
  
  
  1.2       +22 -1     
jakarta-tomcat-connectors/naming/src/org/apache/naming/res/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/res/LocalStrings.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocalStrings.properties   1 Oct 2002 18:49:49 -0000       1.1
  +++ LocalStrings.properties   8 Oct 2002 18:46:43 -0000       1.2
  @@ -7,4 +7,25 @@
   namingContext.readOnly=Context is read only
   namingContext.invalidName=Name is not valid
   namingContext.alreadyBound=Name {0} is already bound in this Context
  -namingContext.noAbsoluteName=Can't generate an absolute name for this namespace
  \ No newline at end of file
  +namingContext.noAbsoluteName=Can't generate an absolute name for this namespace
  +
  +fileResources.base=Document base {0} does not exist or is not a readable directory
  +warResources.notWar=Doc base must point to a WAR file
  +warResources.invalidWar=Invalid or unreadable WAR file : {0}
  +jarResources.syntax=Document base {0} must start with 'jar:' and end with '!/'
  +resources.alreadyStarted=Resources has already been started
  +resources.connect=Cannot connect to document base {0}
  +resources.input=Cannot create input stream for resource {0}
  +resources.notStarted=Resources has not yet been started
  +resources.null=Document base cannot be null
  +resources.notFound=Resource {0} not found
  +resources.path=Context relative path {0} must start with '/'
  +resources.alreadyBound=Name {0} is already bound in this Context
  +resources.bindFailed=Bind failed: {0}
  +resources.unbindFailed=Unbind failed: {0}
  +standardResources.alreadyStarted=Resources has already been started
  +standardResources.directory=File base {0} is not a directory
  +standardResources.exists=File base {0} does not exist
  +standardResources.notStarted=Resources has not yet been started
  +standardResources.null=Document base cannot be null
  +standardResources.slash=Document base {0} must not end with a slash
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to