You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ps...@apache.org on 2004/12/29 06:45:17 UTC

svn commit: r123596 - /incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java

Author: psteitz
Date: Tue Dec 28 21:45:15 2004
New Revision: 123596

URL: http://svn.apache.org/viewcvs?view=rev&rev=123596
Log:
Javadoc
Modified:
   incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java

Modified: incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java
Url: http://svn.apache.org/viewcvs/incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java?view=diff&rev=123596&p1=incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java&r1=123595&p2=incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java&r2=123596
==============================================================================
--- incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java	(original)
+++ incubator/directory/naming/trunk/config/src/java/org/apache/naming/config/Config.java	Tue Dec 28 21:45:15 2004
@@ -41,22 +41,40 @@
  */
 public final class Config
 {
+    /**
+     * Naming context configuration.
+     */
     public static final class Naming
     {
+        /** list of context configurations */
         private final Collection contextList = new LinkedList();
 
+        /**
+         *  Adds a new Context configuration to the context list.
+         * 
+         * @param context Context configuration to add.
+         */
         public void addContext(Context context)
         {
             contextList.add(context);
         }
-        /**
-         * @return
+        
+        /**
+         * Returns the context list.
+         * 
+         * @return  context list.
          */
         public Collection getContextList()
         {
             return Collections.unmodifiableCollection(contextList);
         }
-
+
+        /**
+         * Generates and returns a sorted list of all configured names.
+         * 
+         * @return configured names
+         * @throws InvalidNameException if an invalid name is encountered
+         */
         public Set generateSortedSubcontextNameSet() throws InvalidNameException
         {
             Set sortedSubcontextNameSet = new TreeSet();
@@ -67,7 +85,12 @@
             }
             return Collections.unmodifiableSet(sortedSubcontextNameSet);
         }
-
+
+        /**
+         * Returns a string representation of the context list.
+         * 
+         * @return context list as a string.
+         */
         public String toString()
         {
             return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -75,20 +98,35 @@
                 .toString();
         }
     }
-
+
+    /**
+     * Configuration for a Context.  Contexts contain lists of 
+     * {@link org.apache.naming.config.Config$Environment} entries and 
+     * {@link org.apache.naming.config.Config$Resource} references.
+     */
     public static final class Context
     {
         private String name;
         private final Collection environmentList = new LinkedList();
         private final Collection resourceList = new LinkedList();
 
+        /**
+         * Adds an Environment configuration to the environment list.
+         * 
+         * @param environment environment configuration to add.
+         */
         public void addEnvironment(Environment environment)
         {
             environmentList.add(environment);
         }
 
-        /**
-         * @param sortedSubcontextNameSet
+        /**
+         * Adds the subcontext names in this Context to the input set.
+         * 
+         * @param sortedSubcontextNameSet  set to be augmented with names from
+         *  this context.
+         * @throws InvalidNameException  if the configured string name of a
+         * Resource or Environment in this context is not a valid JNDI name.
          */
         public void addSubContextNames(Set sortedSubcontextNameSet) throws InvalidNameException
         {
@@ -115,31 +153,63 @@
                 sortedSubcontextNameSet.add(name.getPrefix(j).toString());
             }
         }
-
+
+        /**
+         * Adds a Resource configuration to the resource list.
+         * 
+         * @param resource resource configuration to add.
+         */
         public void addResource(Resource resource)
         {
             resourceList.add(resource);
-        }
+        }
+        
+        /**
+         * Returns the environment list.
+         * 
+         * @return list of Environment configurations in the Context
+         */
         public Collection getEnvironmentList()
         {
             return Collections.unmodifiableCollection(environmentList);
         }
-
+
+        /**
+         * Returns the name of this context.
+         * 
+         * @return context name
+         */
         public String getName()
         {
             return name;
         }
-
+
+        /**
+         * Sets the name of this context.
+         * 
+         * @param name  the name
+         */
         public void setName(String name)
         {
             this.name = name;
         }
-
+
+        /**
+         * Returns the resource list.
+         * 
+         * @return list of Resource configurations in the Context.
+         */
         public Collection getResourceList()
         {
             return Collections.unmodifiableCollection(resourceList);
         }
-
+
+        /**
+         * Returns a string representation of the name, environment list and
+         * resource list of this context.
+         * 
+         * @return string representation of this context.
+         */
         public String toString()
         {
             return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -149,42 +219,85 @@
                 .toString();
         }
     }
-
+
+    /**
+     * Configuration for an Environment entry.  Environment entries represent
+     * JNDI environment properties that take values that are primitive java
+     *  types.  The Environment configuration includes the type, the value and
+     * the JNDI name as a string, relative to the initial context.
+     */
     public static final class Environment
     {
         private String name;
         private String value;
         private String type;
+        
+        /**
+         * Gets the name of this environment.
+         * 
+         * @return name  the name
+         */
         public String getName()
         {
             return name;
         }
-
+
+        /**
+         * Sets the name of this environment.
+         * 
+         * @param name  the name
+         */
         public void setName(String name)
         {
             this.name = name;
         }
-
+
+        /**
+         * Returns the class name of this environment entry.
+         * 
+         * @return Environment entry class name
+         */
         public String getType()
         {
             return type;
         }
-
+
+        /**
+         * Sets the class name of this environment entry.
+         * 
+         * @param type  class name
+         */
         public void setType(String type)
         {
             this.type = type;
         }
-
+
+        /**
+         * Returns the value of this environment entry as a String.
+         * 
+         * @return String representation of the value
+         */
         public String getValue()
         {
             return value;
         }
-
+
+        /**
+         * Sets the (String) value of this environment entry.
+         * 
+         * @param value
+         */
         public void setValue(String value)
         {
             this.value = value;
         }
-
+
+        /**
+         * Returns the JNDI name, type and value of this environment entry as
+         * as String.
+         * 
+         * @return String representation of this environment entry.
+         */
         public String toString()
         {
             return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -195,10 +308,18 @@
         }
 
         /**
-         * @todo finish types, throw exceptions
-         * @return
+         * Tries to create an instance of type <code>this.type</code> using 
+         * <code>this.value</code>. 
+         * <p> 
+         * Only primitive types are currently supported. Wrapper object
+         * <code>valueOf</code> methods are used and runtime exceptions
+         *  are not handled.  If <code>this.type</code> is not a primitive type,
+         * <code>null</code> is returned.
+         * 
+         * @return object instance
          */
-        public Object createValue()
+        public Object createValue()
+        //TODO: handle / rethrow exceptions, support more types?
         {
             if (type.equals(String.class.getName()))
             {
@@ -239,47 +360,89 @@
             return null;
         }
     }
-
+
+    /**
+    * Configuration for an JNDI resource reference.  Resource references 
+    * include the type of the resource, the parameters to be used in creating
+    * the resource instance and the JNDI name of the resource as a string, 
+    * relative to the initial context.
+    */
     public static final class Resource
     {
         private String name;
         private String type;
         private final Map parameters = new HashMap();
-
+
+        /**
+         * Adds a name-value pair to the parameters associated with this resource.
+         * 
+         * @param name parameter name
+         * @param value parameter value
+         */
         public void addParameter(String name, String value)
         {
             parameters.put(name, value);
-        }
+        }
+        
+        /**
+         * Returns the name of this resource.
+         *
+         *  @return name
+         */
         public String getName()
         {
             return name;
         }
-
+
+        /**
+         * Sets the name of this resource.
+         * 
+         * @param name name.
+         */
         public void setName(String name)
         {
             this.name = name;
         }
-
+
+        /**
+         * Returns the parameters associated with this resource as a Map.
+         * The keys of the map are the parameter names.
+         * 
+         * @return parameters
+         */
         public Map getParameters()
         {
             return parameters;
         }
-
+
+        /**
+         * Returns the type of this resource.
+         * 
+         * @return class name
+         */
         public String getType()
         {
             return type;
         }
-
+
+        /**
+         * Sets the type of this resource.
+         * 
+         * @param type  class name.
+         */
         public void setType(String type)
         {
             this.type = type;
         }
 
-        /**
-         * @todo finish types, throw exceptions
-         * @return
-         */
-        public Object createValue()
+       /**
+        * Creates a {@link ResourceRef} based on the configuration
+        * properties of this resource.
+        * 
+        * @return ResourceRef instance.
+        */
+        public Object createValue()
+        //TODO: exceptions?
         {
             ResourceRef ref = new ResourceRef(type, null, null, null);
             for (Iterator i = parameters.keySet().iterator(); i.hasNext();)
@@ -290,7 +453,12 @@
             }
             return ref;
         }
-
+
+        /**
+         * Returns the name, type and parameter list as a String.
+         * 
+         * @return String representation of this resource reference configuration.
+         */
         public String toString()
         {
             return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)