tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/naming/src/org/apache/naming/core BaseDirContext.java ContextAccessController.java DirContextHelper.java JndiPermission.java NameParserImpl.java NamingContextBindingsEnumeration.java NamingContextEnumeration.java ServerAttribute.java ServerAttributes.java ServerName.java
Date Tue, 01 Oct 2002 18:42:17 GMT
costin      2002/10/01 11:42:17

  Added:       naming/src/org/apache/naming/core BaseDirContext.java
                        ContextAccessController.java DirContextHelper.java
                        JndiPermission.java NameParserImpl.java
                        NamingContextBindingsEnumeration.java
                        NamingContextEnumeration.java ServerAttribute.java
                        ServerAttributes.java ServerName.java
  Log:
  Initial version - compile but probably doesn't run ( well, it
  did work at some stage ).
  
  This code is a refactored version of what's in catalina - I tried
  to merge different variants and standardise on use of Name.
  
  The reason of using Name - as I mentioned earlier - is the possible
  optimizations ( like using MessageBytes, caching, etc ), String is
  a very inflexible object.
  
  I added more comments to BaseDirContext on what I would like to
  do ( introspection-based config, etc ).
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseDirContext.java
  
  Index: BaseDirContext.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 apache@apache.org.
   *
   * 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;
  
  //import org.apache.naming.NameParserImpl;
  
  // Based on a merge of various catalina naming contexts
  // Name is used - it provide better oportunities for reuse and optimizations
  
  /**
   * Base Directory Context implementation. All j-t-c/naming contexts should
   * extend it. 
   *
   * Implements all JNDI methods - if you just extend it you'll get UnsuportedOperation.
   * XXX Should it also act as introspector proxy or should we use a separate context ?
   * The intention is to allow use 'introspection magic' and bean-like DirContexts.
   *
   * IMPORTANT: all contexts should use setters/getters for configuration, instead
   * of the Hashtable. The default constructor will use introspection to configure
   * and may provide ( via a hook ? ) JMX management on all contexts.
   *
   * You must extend and override few methods. Of course, you can also override any other
   * method and provide a more optimal implementation, but in most cases you only
   * need the minimal set.
   *
   * All methods use Name variant. They should expect an arbitrary implementation, but
   * it's recommended to check if ServerName is used - and take advantage of the
   * specific features ( MessageBytes, etc ).
   *
   * <ul>
   *   <li>
   * </ul>
   *
   * @author Remy Maucherat
   * @author Costin Manolache
   */
  public class BaseDirContext implements DirContext {
  
      /**
       * Builds a base directory context.
       */
      public BaseDirContext() {
          this( new Hashtable() );
      }
  
      /**
       * Builds a base directory context using the given environment.
       */
      public BaseDirContext(Hashtable env) {
          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();
          }
      }
  
      // ----------------------------------------------------- Instance Variables
  
      /**
       * Environment. All context config info.
       * XXX IntrospectionDirContext should call the right setters.
       */
      protected Hashtable env;
  
      /**
       * Default name parser for this context.
       * XXX This should be combined with the Tomcat mapper, and
       * optimized for MessageBytes.
       */
      protected final NameParser nameParser = new NameParserImpl();
  
      /**
       * Cached.
       * deprecated ? Should be implemented via notes or other mechanism.
       * Or via config.
       */
      protected boolean cached = true;
      protected int cacheTTL = 5000; // 5s
      protected int cacheObjectMaxSize = 32768; // 32 KB
  
      
      /** Prefix used for URL-based namming lookup. It must be removed
       *  from all names.
       *  Deprecated ? Do we need it ?
       */
      protected String urlPrefix="";
  
      // ------------------------------------------------------------- Properties
  
      // XXX Introspection should be used to turn the Hashtable attributes
      // into setters.
      
      public void setURLPrefix( String s ) {
          urlPrefix=s;
      }
      
      /**
       * Set cached attribute. If false, this context will be skipped from caching
       */
      public void setCached(boolean cached) {
          this.cached = cached;
      }
  
      /**
       * Is cached ?
       */
      public boolean isCached() {
          return cached;
      }
  
  
      /**
       * Set cache TTL.
       */
      public void setCacheTTL(int cacheTTL) {
          this.cacheTTL = cacheTTL;
      }
  
  
      /**
       * Get cache TTL.
       */
      public int getCacheTTL() {
          return cacheTTL;
      }
  
  
      /**
       * Set cacheObjectMaxSize.
       */
      public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
          this.cacheObjectMaxSize = cacheObjectMaxSize;
      }
  
  
      /**
       * Get cacheObjectMaxSize.
       */
      public int getCacheObjectMaxSize() {
          return cacheObjectMaxSize;
      }
  
      // -------------------- Lifecycle methods ? -------------------- 
  
      /**
       * Allocate resources for this directory context.
       */
      public void allocate() {
          ; // No action taken by the default implementation
      }
  
  
      /**
       * Release any resources allocated for this directory context.
       */
      public void release() {
          ; // No action taken by the default implementation
      }
  
      // -------------------- Abstract methods -------------------- 
      // This is what a subclass should implement.
      
      /** The lookup method to implement
       */
      protected Object lookup(Name name, boolean resolveLinks, Object o)
          throws NamingException
      {
          throws OperationNotSupportedException();
      }
  
      public void bind(Name name, Object obj, Attributes attrs, boolean rebind )
          throws NamingException
      {
          throws 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);
          bind(newName, value);
          unbind(oldName);
      }
  
      public Attributes getAttributes(Name name, String[] attrIds)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
      
      // -------------------- Utils --------------------
      
  
      /**
       * Returns true if writing is allowed on this context.
       */
      protected boolean isWritable(Name name) {
          return ContextAccessController.isWritable(name);
      }
  
  
      /**
       * Throws a naming exception is Context is not writable.
       */
      protected void checkWritable(Name n) 
          throws NamingException
      {
          if (!isWritable(n))
              throw new NamingException("read only");
      }
  
      protected Name string2Name(String s ) throws InvalidNameException {
          // XXX uniq
          //        try {
              return new CompositeName( s );
  //         } catch( InvalidNameException ex ) {
  //             ex.printStackTrace();
  //             return null;
  //         }
      }
      
  
      // -------------------- DirContext impl -------------------- 
      // Various things required by JNDI
      
      /**
       * Retrieves the named object. If name is empty, returns a new instance 
       * of this context (which represents the same naming context as this 
       * context, but its environment may be modified independently and it may 
       * be accessed concurrently).
       * 
       * @param name the name of the object to look up
       * @return the object bound to name
       * @exception NamingException if a naming exception is encountered
       */
      public Object lookup(Name name)
          throws NamingException
      {
          return lookup(name, true, null );
      }
  
      /**
       * Retrieves the named object.
       * 
       * @param name the name of the object to look up
       * @return the object bound to name
       * @exception NamingException if a naming exception is encountered
       */
      public Object lookup(String name)
          throws NamingException
      {
          return lookup( string2Name(name), true , null);
      }
  
  
      /**
       * Binds a name to an object. All intermediate contexts and the target 
       * context (that named by all but terminal atomic component of the name) 
       * must already exist.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @exception NameAlreadyBoundException if name is already bound
       * @exception InvalidAttributesException if object did not supply all 
       * mandatory attributes
       * @exception NamingException if a naming exception is encountered
       */
      public void bind(Name name, Object obj)
          throws NamingException
      {
          bind(name, obj, null, false);
      }
  
  
      /**
       * Binds a name to an object.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @exception NameAlreadyBoundException if name is already bound
       * @exception InvalidAttributesException if object did not supply all 
       * mandatory attributes
       * @exception NamingException if a naming exception is encountered
       */
      public void bind(String name, Object obj)
          throws NamingException
      {
          bind(string2Name(name), obj, null, false);
      }
  
  
      /**
       * Binds a name to an object, overwriting any existing binding. All 
       * intermediate contexts and the target context (that named by all but 
       * terminal atomic component of the name) must already exist.
       * <p>
       * If the object is a DirContext, any existing attributes associated with 
       * the name are replaced with those of the object. Otherwise, any 
       * existing attributes associated with the name remain unchanged.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @exception InvalidAttributesException if object did not supply all 
       * mandatory attributes
       * @exception NamingException if a naming exception is encountered
       */
      public void rebind(Name name, Object obj)
          throws NamingException
      {
          bind(name, obj, null, true);
      }
  
  
      /**
       * Binds a name to an object, overwriting any existing binding.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @exception InvalidAttributesException if object did not supply all 
       * mandatory attributes
       * @exception NamingException if a naming exception is encountered
       */
      public void rebind(String name, Object obj)
          throws NamingException
      {
          bind(string2Name(name), obj, null, true);
      }
  
  
      /**
       * Unbinds the named object. Removes the terminal atomic name in name 
       * from the target context--that named by all but the terminal atomic 
       * part of name.
       * <p>
       * This method is idempotent. It succeeds even if the terminal atomic 
       * name is not bound in the target context, but throws 
       * NameNotFoundException if any of the intermediate contexts do not exist. 
       * 
       * @param name the name to bind; may not be empty
       * @exception NameNotFoundException if an intermediate context does not 
       * exist
       * @exception NamingException if a naming exception is encountered
       */
      public void unbind(Name name)
          throws NamingException
      {
          unbind( name, false );
      }
      
      public void unbind(String name)
          throws NamingException
      {
          unbind( string2Name( name ), false);
      }
  
  
      /**
       * Binds a new name to the object bound to an old name, and unbinds the 
       * old name. Both names are relative to this context. Any attributes 
       * associated with the old name become associated with the new name. 
       * Intermediate contexts of the old name are not changed.
       * 
       * @param oldName the name of the existing binding; may not be empty
       * @param newName the name of the new binding; may not be empty
       * @exception NameAlreadyBoundException if newName is already bound
       * @exception NamingException if a naming exception is encountered
       */
      public  void rename(String oldName, String newName)
          throws NamingException
      {
          rename( string2Name( oldName ), string2Name( newName ));
      }
  
  
      /**
       * Enumerates the names bound in the named context, along with the class 
       * names of objects bound to them. The contents of any subcontexts are 
       * not included.
       * <p>
       * If a binding is added to or removed from this context, its effect on 
       * an enumeration previously returned is undefined.
       * 
       * @param name the name of the context to list
       * @return an enumeration of the names and class names of the bindings in 
       * this context. Each element of the enumeration is of type NameClassPair.
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration list(String name)
          throws NamingException
      {
          return list(string2Name(name));
      }
  
      public NamingEnumeration list(Name name)
          throws NamingException
      {
          throw new OperationNotSupportedException("list");
      }
  
  
      /**
       * Enumerates the names bound in the named context, along with the 
       * objects bound to them. The contents of any subcontexts are not 
       * included.
       * <p>
       * If a binding is added to or removed from this context, its effect on 
       * an enumeration previously returned is undefined.
       * 
       * @param name the name of the context to list
       * @return an enumeration of the bindings in this context. 
       * Each element of the enumeration is of type Binding.
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration listBindings(Name name)
          throws NamingException
      {
          throw new OperationNotSupportedException( "listBindings" );
      }
  
      public NamingEnumeration listBindings(String name)
          throws NamingException
      {
          return listBindings( string2Name( name ));
      }
  
  
      /**
       * Destroys the named context and removes it from the namespace. Any 
       * attributes associated with the name are also removed. Intermediate 
       * contexts are not destroyed.
       * <p>
       * This method is idempotent. It succeeds even if the terminal atomic 
       * name is not bound in the target context, but throws 
       * NameNotFoundException if any of the intermediate contexts do not exist. 
       * 
       * In a federated naming system, a context from one naming system may be 
       * bound to a name in another. One can subsequently look up and perform 
       * operations on the foreign context using a composite name. However, an 
       * attempt destroy the context using this composite name will fail with 
       * NotContextException, because the foreign context is not a "subcontext" 
       * of the context in which it is bound. Instead, use unbind() to remove 
       * the binding of the foreign context. Destroying the foreign context 
       * requires that the destroySubcontext() be performed on a context from 
       * the foreign context's "native" naming system.
       * 
       * @param name the name of the context to be destroyed; may not be empty
       * @exception NameNotFoundException if an intermediate context does not 
       * exist
       * @exception NotContextException if the name is bound but does not name 
       * a context, or does not name a context of the appropriate type
       */
      public void destroySubcontext(Name name)
          throws NamingException
      {
          unbind( name, true );
      }
  
  
      /**
       * Destroys the named context and removes it from the namespace.
       * 
       * @param name the name of the context to be destroyed; may not be empty
       * @exception NameNotFoundException if an intermediate context does not 
       * exist
       * @exception NotContextException if the name is bound but does not name 
       * a context, or does not name a context of the appropriate type
       */
      public  void destroySubcontext(String name)
          throws NamingException
      {
          unbind( string2Name( name ), true );
      }
  
  
      /**
       * Creates and binds a new context. Creates a new context with the given 
       * name and binds it in the target context (that named by all but 
       * terminal atomic component of the name). All intermediate contexts and 
       * the target context must already exist.
       * 
       * @param name the name of the context to create; may not be empty
       * @return the newly created context
       * @exception NameAlreadyBoundException if name is already bound
       * @exception InvalidAttributesException if creation of the subcontext 
       * requires specification of mandatory attributes
       * @exception NamingException if a naming exception is encountered
       */
      public Context createSubcontext(Name name)
          throws NamingException
      {
          return createSubcontext( name, null );
      }
  
      public Context createSubcontext(String name)
          throws NamingException
      {
          return createSubcontext( string2Name( name ),null);
      }
  
  
      /**
       * Retrieves the named object, following links except for the terminal 
       * atomic component of the name. If the object bound to name is not a 
       * link, returns the object itself.
       * 
       * @param name the name of the object to look up
       * @return the object bound to name, not following the terminal link 
       * (if any).
       * @exception NamingException if a naming exception is encountered
       */
      public Object lookupLink(Name name)
          throws NamingException {
          return lookup(name, false, null);
      }
  
  
      /**
       * Retrieves the named object, following links except for the terminal 
       * atomic component of the name.
       * 
       * @param name the name of the object to look up
       * @return the object bound to name, not following the terminal link 
       * (if any).
       * @exception NamingException if a naming exception is encountered
       */
      public Object lookupLink(String name)
          throws NamingException
      {
          return lookupLink( string2Name(name) );
      }
  
  
      /**
       * Retrieves the parser associated with the named context. In a 
       * federation of namespaces, different naming systems will parse names 
       * differently. This method allows an application to get a parser for 
       * parsing names into their atomic components using the naming convention 
       * of a particular naming system. Within any single naming system, 
       * NameParser objects returned by this method must be equal (using the 
       * equals() test).
       * 
       * @param name the name of the context from which to get the parser
       * @return a name parser that can parse compound names into their atomic 
       * components
       * @exception NamingException if a naming exception is encountered
       */
      public NameParser getNameParser(Name name)
          throws NamingException {
  
  	while ((!name.isEmpty()) && (name.get(0).length() == 0))
  	    name = name.getSuffix(1);
          if (name.isEmpty())
              return nameParser;
  
          if (name.size() > 1) {
              Object obj = lookup(name.get(0));
              if (obj instanceof Context) {
                  return ((Context) obj).getNameParser(name.getSuffix(1));
              } else {
                  throw new NotContextException( name.toString());
              }
          }
  
          return nameParser;
  
      }
  
  
      /**
       * Retrieves the parser associated with the named context.
       * 
       * @param name the name of the context from which to get the parser
       * @return a name parser that can parse compound names into their atomic 
       * components
       * @exception NamingException if a naming exception is encountered
       */
      public NameParser getNameParser(String name)
          throws NamingException
      {
          return getNameParser(new CompositeName(name));
      }
  
      /**
       * Composes the name of this context with a name relative to this context.
       * <p>
       * Given a name (name) relative to this context, and the name (prefix) 
       * of this context relative to one of its ancestors, this method returns 
       * the composition of the two names using the syntax appropriate for the 
       * naming system(s) involved. That is, if name names an object relative 
       * to this context, the result is the name of the same object, but 
       * relative to the ancestor context. None of the names may be null.
       * 
       * @param name a name relative to this context
       * @param prefix the name of this context relative to one of its ancestors
       * @return the composition of prefix and name
       * @exception NamingException if a naming exception is encountered
       */
      public Name composeName(Name name, Name prefix)
          throws NamingException
      {
  	prefix = (Name) name.clone();
  	return prefix.addAll(name);
      }
  
  
      /**
       * Composes the name of this context with a name relative to this context.
       * 
       * @param name a name relative to this context
       * @param prefix the name of this context relative to one of its ancestors
       * @return the composition of prefix and name
       * @exception NamingException if a naming exception is encountered
       */
      public String composeName(String name, String prefix)
          throws NamingException {
          return prefix + "/" + name;
      }
  
  
      /**
       * Adds a new environment property to the environment of this context. If 
       * the property already exists, its value is overwritten.
       * 
       * @param propName the name of the environment property to add; may not 
       * be null
       * @param propVal the value of the property to add; may not be null
       * @exception NamingException if a naming exception is encountered
       */
      public Object addToEnvironment(String propName, Object propVal)
          throws NamingException
      {
          return env.put(propName, propVal);
      }
  
  
      /**
       * Removes an environment property from the environment of this context. 
       * 
       * @param propName the name of the environment property to remove; 
       * may not be null
       * @exception NamingException if a naming exception is encountered
       */
      public Object removeFromEnvironment(String propName)
          throws NamingException
      {
          return env.remove(propName);
      }
  
  
      /**
       * Retrieves the environment in effect for this context. See class 
       * description for more details on environment properties. 
       * The caller should not make any changes to the object returned: their 
       * effect on the context is undefined. The environment of this context 
       * may be changed using addToEnvironment() and removeFromEnvironment().
       * 
       * @return the environment of this context; never null
       * @exception NamingException if a naming exception is encountered
       */
      public Hashtable getEnvironment()
          throws NamingException
      {
          return env;
      }
  
  
      /**
       * Closes this context. This method releases this context's resources 
       * immediately, instead of waiting for them to be released automatically 
       * by the garbage collector.
       * This method is idempotent: invoking it on a context that has already 
       * been closed has no effect. Invoking any other method on a closed 
       * context is not allowed, and results in undefined behaviour.
       * 
       * @exception NamingException if a naming exception is encountered
       */
      public void close()
          throws NamingException
      {
          // We don't own the env., but the clone
          env.clear();
      }
  
  
      /**
       * Retrieves the full name of this context within its own namespace.
       * <p>
       * Many naming services have a notion of a "full name" for objects in 
       * their respective namespaces. For example, an LDAP entry has a 
       * distinguished name, and a DNS record has a fully qualified name. This 
       * method allows the client application to retrieve this name. The string 
       * returned by this method is not a JNDI composite name and should not be 
       * passed directly to context methods. In naming systems for which the 
       * notion of full name does not make sense, 
       * OperationNotSupportedException is thrown.
       * 
       * @return this context's name in its own namespace; never null
       * @exception OperationNotSupportedException if the naming system does 
       * not have the notion of a full name
       * @exception NamingException if a naming exception is encountered
       */
      public String getNameInNamespace()
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
  
      // ----------------------------------------------------- DirContext Methods
  
  
      /**
       * Retrieves all of the attributes associated with a named object. 
       * 
       * @return the set of attributes associated with name. 
       * Returns an empty attribute set if name has no attributes; never null.
       * @param name the name of the object from which to retrieve attributes
       * @exception NamingException if a naming exception is encountered
       */
      public Attributes getAttributes(Name name)
          throws NamingException
      {
          return getAttributes(name, null);
      }
  
  
      /**
       * Retrieves all of the attributes associated with a named object.
       * 
       * @return the set of attributes associated with name
       * @param name the name of the object from which to retrieve attributes
       * @exception NamingException if a naming exception is encountered
       */
      public Attributes getAttributes(String name)
          throws NamingException
      {
          return getAttributes(string2Name(name));
      }
  
      /**
       * Retrieves selected attributes associated with a named object. 
       * See the class description regarding attribute models, attribute type 
       * names, and operational attributes.
       * 
       * @return the requested attributes; never null
       * @param name the name of the object from which to retrieve attributes
       * @param attrIds the identifiers of the attributes to retrieve. null 
       * indicates that all attributes should be retrieved; an empty array 
       * indicates that none should be retrieved
       * @exception NamingException if a naming exception is encountered
       */
      public Attributes getAttributes(String name, String[] attrIds)
          throws NamingException
      {
          return getAttributes(string2Name(name), attrIds);
      }
  
  
      /**
       * Modifies the attributes associated with a named object. The order of 
       * the modifications is not specified. Where possible, the modifications 
       * are performed atomically.
       * 
       * @param name the name of the object whose attributes will be updated
       * @param mod_op the modification operation, one of: ADD_ATTRIBUTE, 
       * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
       * @param attrs the attributes to be used for the modification; may not 
       * be null
       * @exception AttributeModificationException if the modification cannot be
       * completed successfully
       * @exception NamingException if a naming exception is encountered
       */
      public void modifyAttributes(Name name, int mod_op, Attributes attrs)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
  
      /**
       * Modifies the attributes associated with a named object.
       * 
       * @param name the name of the object whose attributes will be updated
       * @param mod_op the modification operation, one of: ADD_ATTRIBUTE, 
       * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
       * @param attrs the attributes to be used for the modification; may not 
       * be null
       * @exception AttributeModificationException if the modification cannot be
       * completed successfully
       * @exception NamingException if a naming exception is encountered
       */
      public void modifyAttributes(String name, int mod_op, Attributes attrs)
          throws NamingException
      {
          modifyAttributes(string2Name(name), mod_op, attrs);
      }
  
  
      /**
       * Modifies the attributes associated with a named object using an an 
       * ordered list of modifications. The modifications are performed in the 
       * order specified. Each modification specifies a modification operation 
       * code and an attribute on which to operate. Where possible, the 
       * modifications are performed atomically.
       * 
       * @param name the name of the object whose attributes will be updated
       * @param mods an ordered sequence of modifications to be performed; may 
       * not be null
       * @exception AttributeModificationException if the modification cannot be
       * completed successfully
       * @exception NamingException if a naming exception is encountered
       */
      public void modifyAttributes(Name name, ModificationItem[] mods)
          throws NamingException {
          if( mods==null ) return;
          for( int i=0; i<mods.length; i++ ) {
              //mods[i];
          }
      }
  
  
      /**
       * Modifies the attributes associated with a named object using an an 
       * ordered list of modifications.
       * 
       * @param name the name of the object whose attributes will be updated
       * @param mods an ordered sequence of modifications to be performed; may 
       * not be null
       * @exception AttributeModificationException if the modification cannot be
       * completed successfully
       * @exception NamingException if a naming exception is encountered
       */
      public void modifyAttributes(String name, ModificationItem[] mods)
          throws NamingException
      {
          modifyAttributes(string2Name(name), mods);
      }
  
  
      /**
       * Binds a name to an object, along with associated attributes. If attrs 
       * is null, the resulting binding will have the attributes associated 
       * with obj if obj is a DirContext, and no attributes otherwise. If attrs 
       * is non-null, the resulting binding will have attrs as its attributes; 
       * any attributes associated with obj are ignored.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @param attrs the attributes to associate with the binding
       * @exception NameAlreadyBoundException if name is already bound
       * @exception InvalidAttributesException if some "mandatory" attributes 
       * of the binding are not supplied
       * @exception NamingException if a naming exception is encountered
       */
      public void bind(Name name, Object obj, Attributes attrs)
          throws NamingException
      {
          bind(name, obj, attrs, false);
      }
  
  
      /**
       * Binds a name to an object, along with associated attributes.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @param attrs the attributes to associate with the binding
       * @exception NameAlreadyBoundException if name is already bound
       * @exception InvalidAttributesException if some "mandatory" attributes 
       * of the binding are not supplied
       * @exception NamingException if a naming exception is encountered
       */
      public void bind(String name, Object obj, Attributes attrs)
          throws NamingException
      {
          bind( string2Name(name), obj, attrs, false);
      }
  
  
      /**
       * Binds a name to an object, along with associated attributes, 
       * overwriting any existing binding. If attrs is null and obj is a 
       * DirContext, the attributes from obj are used. If attrs is null and obj 
       * is not a DirContext, any existing attributes associated with the object
       * already bound in the directory remain unchanged. If attrs is non-null, 
       * any existing attributes associated with the object already bound in 
       * the directory are removed and attrs is associated with the named 
       * object. If obj is a DirContext and attrs is non-null, the attributes 
       * of obj are ignored.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @param attrs the attributes to associate with the binding
       * @exception InvalidAttributesException if some "mandatory" attributes 
       * of the binding are not supplied
       * @exception NamingException if a naming exception is encountered
       */
      public void rebind(Name name, Object obj, Attributes attrs)
          throws NamingException
      {
          bind(name, obj, attrs, true);
      }
  
  
      /**
       * Binds a name to an object, along with associated attributes, 
       * overwriting any existing binding.
       * 
       * @param name the name to bind; may not be empty
       * @param obj the object to bind; possibly null
       * @param attrs the attributes to associate with the binding
       * @exception InvalidAttributesException if some "mandatory" attributes 
       * of the binding are not supplied
       * @exception NamingException if a naming exception is encountered
       */
      public void rebind(String name, Object obj, Attributes attrs)
          throws NamingException
      {
          bind( string2Name( name ) , obj, attrs, true);
      }
  
  
      /**
       * Creates and binds a new context, along with associated attributes. 
       * This method creates a new subcontext with the given name, binds it in 
       * the target context (that named by all but terminal atomic component of 
       * the name), and associates the supplied attributes with the newly 
       * created object. All intermediate and target contexts must already 
       * exist. If attrs is null, this method is equivalent to 
       * Context.createSubcontext().
       * 
       * @param name the name of the context to create; may not be empty
       * @param attrs the attributes to associate with the newly created context
       * @return the newly created context
       * @exception NameAlreadyBoundException if the name is already bound
       * @exception InvalidAttributesException if attrs does not contain all 
       * the mandatory attributes required for creation
       * @exception NamingException if a naming exception is encountered
       */
      public DirContext createSubcontext(String name, Attributes attrs)
          throws NamingException
      {
          return createSubcontext(string2Name( name ), attrs);
      }
  
  
      /**
       * Retrieves the schema associated with the named object. The schema 
       * describes rules regarding the structure of the namespace and the 
       * attributes stored within it. The schema specifies what types of 
       * objects can be added to the directory and where they can be added; 
       * what mandatory and optional attributes an object can have. The range 
       * of support for schemas is directory-specific.
       * 
       * @param name the name of the object whose schema is to be retrieved
       * @return the schema associated with the context; never null
       * @exception OperationNotSupportedException if schema not supported
       * @exception NamingException if a naming exception is encountered
       */
      public DirContext getSchema(Name name)
          throws NamingException
      {
          return getSchema(name.toString());
      }
  
  
      /**
       * Retrieves the schema associated with the named object.
       * 
       * @param name the name of the object whose schema is to be retrieved
       * @return the schema associated with the context; never null
       * @exception OperationNotSupportedException if schema not supported
       * @exception NamingException if a naming exception is encountered
       */
      public DirContext getSchema(String name)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
  
      /**
       * Retrieves a context containing the schema objects of the named 
       * object's class definitions.
       * 
       * @param name the name of the object whose object class definition is to 
       * be retrieved
       * @return the DirContext containing the named object's class 
       * definitions; never null
       * @exception OperationNotSupportedException if schema not supported
       * @exception NamingException if a naming exception is encountered
       */
      public DirContext getSchemaClassDefinition(Name name)
          throws NamingException
      {
          return getSchemaClassDefinition(name.toString());
      }
  
  
      /**
       * Retrieves a context containing the schema objects of the named 
       * object's class definitions.
       * 
       * @param name the name of the object whose object class definition is to 
       * be retrieved
       * @return the DirContext containing the named object's class 
       * definitions; never null
       * @exception OperationNotSupportedException if schema not supported
       * @exception NamingException if a naming exception is encountered
       */
      public DirContext getSchemaClassDefinition(String name)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
  
      /**
       * Searches in a single context for objects that contain a specified set 
       * of attributes, and retrieves selected attributes. The search is 
       * performed using the default SearchControls settings.
       * 
       * @param name the name of the context to search
       * @param matchingAttributes the attributes to search for. If empty or 
       * null, all objects in the target context are returned.
       * @param attributesToReturn the attributes to return. null indicates 
       * that all attributes are to be returned; an empty array indicates that 
       * none are to be returned.
       * @return a non-null enumeration of SearchResult objects. Each 
       * SearchResult contains the attributes identified by attributesToReturn 
       * and the name of the corresponding object, named relative to the 
       * context named by name.
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration search(Name name, Attributes matchingAttributes,
                                      String[] attributesToReturn)
          throws NamingException
      {
          return search(name.toString(), matchingAttributes, attributesToReturn);
      }
  
  
      /**
       * Searches in a single context for objects that contain a specified set 
       * of attributes, and retrieves selected attributes.
       * 
       * @param name the name of the context to search
       * @param matchingAttributes the attributes to search for. If empty or 
       * null, all objects in the target context are returned.
       * @param attributesToReturn the attributes to return. null indicates 
       * that all attributes are to be returned; an empty array indicates that 
       * none are to be returned.
       * @return a non-null enumeration of SearchResult objects. Each 
       * SearchResult contains the attributes identified by attributesToReturn 
       * and the name of the corresponding object, named relative to the 
       * context named by name.
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration search(String name, Attributes matchingAttributes,
                                      String[] attributesToReturn)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
  
      /**
       * Searches in a single context for objects that contain a specified set 
       * of attributes. This method returns all the attributes of such objects. 
       * It is equivalent to supplying null as the atributesToReturn parameter 
       * to the method search(Name, Attributes, String[]).
       * 
       * @param name the name of the context to search
       * @param matchingAttributes the attributes to search for. If empty or 
       * null, all objects in the target context are returned.
       * @return a non-null enumeration of SearchResult objects. Each 
       * SearchResult contains the attributes identified by attributesToReturn 
       * and the name of the corresponding object, named relative to the 
       * context named by name.
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration search(Name name, Attributes matchingAttributes)
          throws NamingException {
          return search(name.toString(), matchingAttributes);
      }
  
  
      /**
       * Searches in a single context for objects that contain a specified set 
       * of attributes.
       * 
       * @param name the name of the context to search
       * @param matchingAttributes the attributes to search for. If empty or 
       * null, all objects in the target context are returned.
       * @return a non-null enumeration of SearchResult objects. Each 
       * SearchResult contains the attributes identified by attributesToReturn 
       * and the name of the corresponding object, named relative to the 
       * context named by name.
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration search(String name, Attributes matchingAttributes)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
      /**
       * Searches in the named context or object for entries that satisfy the 
       * given search filter. Performs the search as specified by the search 
       * controls.
       * 
       * @param name the name of the context or object to search
       * @param filter the filter expression to use for the search; may not be 
       * null
       * @param cons the search controls that control the search. If null, 
       * the default search controls are used (equivalent to 
       * (new SearchControls())).
       * @return an enumeration of SearchResults of the objects that satisfy 
       * the filter; never null
       * @exception InvalidSearchFilterException if the search filter specified 
       * is not supported or understood by the underlying directory
       * @exception InvalidSearchControlsException if the search controls 
       * contain invalid settings
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration search
          (Name name, String filter, SearchControls cons)
          throws NamingException
      {
          return search(name.toString(), filter, cons);
      }
  
  
      /**
       * Searches in the named context or object for entries that satisfy the 
       * given search filter. Performs the search as specified by the search 
       * controls.
       * 
       * @param name the name of the context or object to search
       * @param filter the filter expression to use for the search; may not be 
       * null
       * @param cons the search controls that control the search. If null, 
       * the default search controls are used (equivalent to 
       * (new SearchControls())).
       * @return an enumeration of SearchResults of the objects that satisfy 
       * the filter; never null
       * @exception InvalidSearchFilterException if the search filter 
       * specified is not supported or understood by the underlying directory
       * @exception InvalidSearchControlsException if the search controls 
       * contain invalid settings
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration search(String name, String filter, 
                                               SearchControls cons)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
  
      /**
       * Searches in the named context or object for entries that satisfy the 
       * given search filter. Performs the search as specified by the search 
       * controls.
       * 
       * @param name the name of the context or object to search
       * @param filterExpr the filter expression to use for the search. 
       * The expression may contain variables of the form "{i}" where i is a 
       * nonnegative integer. May not be null.
       * @param filterArgs the array of arguments to substitute for the 
       * variables in filterExpr. The value of filterArgs[i] will replace each 
       * occurrence of "{i}". If null, equivalent to an empty array.
       * @param cons the search controls that control the search. If null, the 
       * default search controls are used (equivalent to (new SearchControls())).
       * @return an enumeration of SearchResults of the objects that satisy the 
       * filter; never null
       * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i} 
       * expressions where i is outside the bounds of the array filterArgs
       * @exception InvalidSearchControlsException if cons contains invalid 
       * settings
       * @exception InvalidSearchFilterException if filterExpr with filterArgs 
       * represents an invalid search filter
       * @exception NamingException if a naming exception is encountered
       */
      public NamingEnumeration search(Name name, String filterExpr, 
                                      Object[] filterArgs, SearchControls cons)
          throws NamingException
      {
          return search(name.toString(), filterExpr, filterArgs, cons);
      }
  
  
      /**
       * Searches in the named context or object for entries that satisfy the 
       * given search filter. Performs the search as specified by the search 
       * controls.
       * 
       * @param name the name of the context or object to search
       * @param filterExpr the filter expression to use for the search. 
       * The expression may contain variables of the form "{i}" where i is a 
       * nonnegative integer. May not be null.
       * @param filterArgs the array of arguments to substitute for the 
       * variables in filterExpr. The value of filterArgs[i] will replace each 
       * occurrence of "{i}". If null, equivalent to an empty array.
       * @param cons the search controls that control the search. If null, the 
       * default search controls are used (equivalent to (new SearchControls())).
       * @return an enumeration of SearchResults of the objects that satisy the 
       * filter; never null
       * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i} 
       * expressions where i is outside the bounds of the array filterArgs
       * @exception InvalidSearchControlsException if cons contains invalid 
       * settings
       * @exception InvalidSearchFilterException if filterExpr with filterArgs 
       * represents an invalid search filter
       * @exception NamingException if a naming exception is encountered
       */
      public  NamingEnumeration search(String name, String filterExpr, 
                                           Object[] filterArgs,
                                           SearchControls cons)
          throws NamingException
      {
          throw new OperationNotSupportedException();
      }
  
      //-------------------- Helpers -------------------- 
  
      /** Just a hack so that all DirContexts can be used as tasks.
       * They'll do nothing - the setters will be called ( just like
       * new Context(Hashtable) - since we use introspection ) and the
       * context can be registred as a reference in the Project ns.
       *
       * Then other tasks could manipulate it by name.
       *
       * In a future version of ant we should have the 'references'
       * pluggable and a possible impl should be JNDI.
       *
       * Alternative: there is a way to use tasks without this method,
       * but for now it's simpler.
       */
      public void execute() {
      }
      
  }
  
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ContextAccessController.java
  
  Index: ContextAccessController.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 apache@apache.org.
   *
   * 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.Hashtable;
  import javax.naming.NamingException;
  
  /**
   * Handles the access control on the JNDI contexts. All
   * contexts implementations should use this.
   *
   * @author Remy Maucherat
   */
  public class ContextAccessController {
  
  
      // -------------------------------------------------------------- Variables
  
  
      /**
       * Catalina context names on which writing is not allowed.
       */
      private static Hashtable readOnlyContexts = new Hashtable();
  
  
      /**
       * Security tokens repository.
       */
      private static Hashtable securityTokens = new Hashtable();
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Set a security token for a context. Can be set only once.
       * 
       * @param name Name of the context
       * @param context Security token
       */
      public static void setSecurityToken(Object name, Object token) {
          if ((!securityTokens.containsKey(name)) && (token != null)) {
              securityTokens.put(name, token);
          }
      }
  
  
      /**
       * Remove a security token for a context.
       * 
       * @param name Name of the context
       * @param context Security token
       */
      public static void unsetSecurityToken(Object name, Object token) {
          if (checkSecurityToken(name, token)) {
              securityTokens.remove(name);
          }
      }
  
  
      /**
       * Check a submitted security token. The submitted token must be equal to
       * the token present in the repository. If no token is present for the 
       * context, then returns true.
       * 
       * @param name Name of the context
       * @param context Submitted security token
       */
      public static boolean checkSecurityToken
          (Object name, Object token) {
          Object refToken = securityTokens.get(name);
          if (refToken == null)
              return (true);
          if ((refToken != null) && (refToken.equals(token)))
              return (true);
          return (false);
      }
  
  
      /**
       * Allow writing to a context.
       * 
       * @param name Name of the context
       * @param token Security token
       */
      public static void setWritable(Object name, Object token) {
          if (checkSecurityToken(name, token))
              readOnlyContexts.remove(name);
      }
  
  
      /**
       * Set whether or not a context is writable.
       * 
       * @param name Name of the context
       */
      public static void setReadOnly(Object name) {
          readOnlyContexts.put(name, name);
      }
  
  
      /**
       * Returns if a context is writable.
       * 
       * @param name Name of the context
       */
      public static boolean isWritable(Object name) {
          return !(readOnlyContexts.containsKey(name));
      }
  
  
  }
  
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/DirContextHelper.java
  
  Index: DirContextHelper.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 apache@apache.org.
   *
   * 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.Hashtable;
  import java.util.HashMap;
  import javax.naming.Context;
  import javax.naming.Name;
  import javax.naming.NameParser;
  import javax.naming.NamingEnumeration;
  import javax.naming.NamingException;
  import javax.naming.CompositeName;
  import javax.naming.NameParser;
  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;
  
  import java.io.*;
  
  /**
   * Utility class providing additional operations on DirContexts.
   * Instead of extending DirContext we use a helper who will work
   * on any context, including 'foreign' ones ( like JNDI, etc ).
   *
   * Typical methods - conversions ( int, boolean), etc.
   *
   * This code should check if the context extend our BaseDirContext
   * and use specific features ( like notes - to cache the conversion
   * results for example ), but fallback for external contexts.
   *
   * @author Costin Manolache
   */
  public class DirContextHelper  {
      static DirContextHelper instance=new DirContextHelper();
      
      public static DirContextHelper getInstance() {
          return instance;
      }
      
      
      /** Debugging string - the context, imediate childs and attributes
       */
      public String toString(DirContext ctx) {
          return "";
      }
  }
  
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/JndiPermission.java
  
  Index: JndiPermission.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 apache@apache.org.
   *
   * 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.security.BasicPermission;
  import java.security.Permission;
  
  /**
   * Java SecurityManager Permission class for JNDI name based file resources
   * <p>
   * The JndiPermission extends the BasicPermission.
   * The permission name is a full or partial jndi resource name.
   * An * can be used at the end of the name to match all named
   * resources that start with name.  There are no actions.</p>
   * <p>
   * Example that grants permission to read all JNDI file based resources:
   * <li> permission org.apache.naming.JndiPermission "*";</li>
   * </p>
   *
   * @author Glenn Nielsen
   * @version $Revision: 1.1 $ $Date: 2002/10/01 18:42:16 $
   */
  
  public final class JndiPermission extends BasicPermission {
  
      // ----------------------------------------------------------- Constructors
  
      /**
       * Creates a new JndiPermission with no actions
       *
       * @param String - JNDI resource path name
       */
      public JndiPermission(String name) {
          super(name);
      }
  
      /**
       * Creates a new JndiPermission with actions
       *
       * @param String - JNDI resource path name
       * @param String - JNDI actions (none defined)
       */
      public JndiPermission(String name, String actions) {
          super(name,actions);
      }
  
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NameParserImpl.java
  
  Index: NameParserImpl.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NameParserImpl.java,v 1.1 2002/10/01 18:42:16 costin Exp $
   * $Revision: 1.1 $
   * $Date: 2002/10/01 18:42:16 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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.NameParser;
  import javax.naming.Name;
  import javax.naming.NamingException;
  import javax.naming.CompositeName;
  
  /**
   * Parses names.
   *
   * @author Remy Maucherat
   * @version $Revision: 1.1 $ $Date: 2002/10/01 18:42:16 $
   */
  public class NameParserImpl 
      implements NameParser
  {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // ----------------------------------------------------- NameParser Methods
  
  
      /**
       * Parses a name into its components.
       * 
       * @param name The non-null string name to parse
       * @return A non-null parsed form of the name using the naming convention 
       * of this parser.
       */
      public Name parse(String name)
          throws NamingException {
          return new CompositeName(name);
      }
  
  //     public Name parse( String name ) throws NamingException
  //     {
  //         return new CompoundName( name, syntax );
  //     }
    
  //   public Properties getSyntax()
  //   {
  //     return syntax;
  //   }
    
  //   static Properties syntax = new Properties();
    
  //   static
  //   {
  //     syntax.put("jndi.syntax.direction", "left_to_right");
  //     syntax.put("jndi.syntax.separator", "/");
  //     syntax.put("jndi.syntax.ignorecase", "false");
  //   }
  
  
  }
  
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NamingContextBindingsEnumeration.java
  
  Index: NamingContextBindingsEnumeration.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 apache@apache.org.
   *
   * 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.Hashtable;
  import java.util.Vector;
  import java.util.Enumeration;
  import javax.naming.NamingException;
  import javax.naming.NamingEnumeration;
  import javax.naming.Binding;
  
  /**
   * Naming enumeration implementation.
   *
   * @author Remy Maucherat
   * @version $Revision: 1.1 $ $Date: 2002/10/01 18:42:16 $
   */
  
  public class NamingContextBindingsEnumeration 
      implements NamingEnumeration {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      public NamingContextBindingsEnumeration(Vector entries) {
          enum = entries.elements();
      }
  
  
      public NamingContextBindingsEnumeration(Enumeration enum) {
          this.enum = enum;
      }
  
  
      // -------------------------------------------------------------- Variables
  
  
      /**
       * Underlying enumeration.
       */
      protected Enumeration enum;
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Retrieves the next element in the enumeration.
       */
      public Object next()
          throws NamingException {
          return nextElement();
      }
  
  
      /**
       * Determines whether there are any more elements in the enumeration.
       */
      public boolean hasMore()
          throws NamingException {
          return enum.hasMoreElements();
      }
  
  
      /**
       * Closes this enumeration.
       */
      public void close()
          throws NamingException {
      }
  
  
      public boolean hasMoreElements() {
          return enum.hasMoreElements();
      }
  
  
      public Object nextElement() {
          NamingEntry entry = (NamingEntry) enum.nextElement();
          return new Binding(entry.name, entry.value.getClass().getName(), 
                             entry.value, true);
      }
  
  
  }
  
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NamingContextEnumeration.java
  
  Index: NamingContextEnumeration.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 apache@apache.org.
   *
   * 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.Hashtable;
  import java.util.Vector;
  import java.util.Enumeration;
  import javax.naming.NamingException;
  import javax.naming.NamingEnumeration;
  import javax.naming.NameClassPair;
  
  /**
   * Naming enumeration implementation.
   *
   * @author Remy Maucherat
   * @version $Revision: 1.1 $ $Date: 2002/10/01 18:42:16 $
   */
  
  public class NamingContextEnumeration 
      implements NamingEnumeration {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      public NamingContextEnumeration(Vector entries) {
          enum = entries.elements();
      }
  
  
      public NamingContextEnumeration(Enumeration enum) {
          this.enum = enum;
      }
  
  
      // -------------------------------------------------------------- Variables
  
  
      /**
       * Underlying enumeration.
       */
      protected Enumeration enum;
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Retrieves the next element in the enumeration.
       */
      public Object next()
          throws NamingException {
          return nextElement();
      }
  
  
      /**
       * Determines whether there are any more elements in the enumeration.
       */
      public boolean hasMore()
          throws NamingException {
          return enum.hasMoreElements();
      }
  
  
      /**
       * Closes this enumeration.
       */
      public void close()
          throws NamingException {
      }
  
  
      public boolean hasMoreElements() {
          return enum.hasMoreElements();
      }
  
  
      public Object nextElement() {
          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/ServerAttribute.java
  
  Index: ServerAttribute.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 apache@apache.org.
   *
   * 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.*;
  import javax.naming.directory.*;
  
  /**
   * Extended version for Attribute. All our dirContexts should return objects
   * of this type. Methods that take attribute param should use this type
   * of objects for performance.
   *
   * This is an extension of the 'note' in tomcat 3.3. Each attribute will have an
   * 'ID' ( small int ) and an associated namespace. The attributes are recyclable.
   *
   * The attribute is designed for use in server env, where performance is important.
   *
   * @author Costin Manolache
   */
  public class ServerAttribute extends BasicAttribute
  {
      public ServerAttribute(String id) {
          super(id);
      }
      
      
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ServerAttributes.java
  
  Index: ServerAttributes.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 apache@apache.org.
   *
   * 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.*;
  import javax.naming.directory.*;
  
  /**
   * Extended version for Attribute. All our dirContexts should return objects
   * of this type. Methods that take attribute param should use this type
   * of objects for performance.
   *
   * This is an extension of the 'note' in tomcat 3.3. Each attribute will have an
   * 'ID' ( small int ) and an associated namespace. The attributes are recyclable.
   *
   * The attribute is designed for use in server env, where performance is important.
   *
   * @author Costin Manolache
   */
  public class ServerAttributes extends BasicAttributes
  {
      
      
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ServerName.java
  
  Index: ServerName.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 apache@apache.org.
   *
   * 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.*;
  
  /**
   * Extended version for Attribute. All our dirContexts should return objects
   * of this type. Methods that take attribute param should use this type
   * of objects for performance.
   *
   * This is an extension of the 'note' in tomcat 3.3. Each attribute will have an
   * 'ID' ( small int ) and an associated namespace. The attributes are recyclable.
   *
   * The attribute is designed for use in server env, where performance is important.
   *
   * @author Costin Manolache
   */
  public class ServerName extends CompositeName
  {
      private int id=0;
  
      public ServerName( String s ) throws InvalidNameException {
          super(s);
      }
  
      /** ID is a small int, equivalent with a note.
          The name is reused in the server environment, and various
          components can use the id for fast access.
  
          The id is local for a particular context.
  
          /Servlet/ClassName -> ClassName will have an ID ( note id ) unique
                                for the Servlet 
      */
      public final int getId() {
          return id;
      }
  
      // XXX Should we allow setting the id, or use a counter for each prefix ? 
      public final void setId( int id ) {
          this.id=id;
      }
  
      /**
       */
      public static Name getName( String s ) throws InvalidNameException {
          return new ServerName( s );
      }
  
      /**
       * @todo: optimize parsing and cache ( reuse existing instances ).
       */
  //     public static Name getName( MessageBytes mb ) {
  //         return new ServerName( mb.toString() );
  //     }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message