commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ep...@apache.org
Subject cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestConfigurationXMLDocument.java
Date Mon, 08 Mar 2004 23:27:09 GMT
epugh       2004/03/08 15:27:09

  Modified:    configuration/src/java/org/apache/commons/configuration
                        CompositeConfiguration.java
                        ConfigurationFactory.java
  Added:       configuration/src/java/org/apache/commons/configuration
                        ConfigurationXMLDocument.java
               configuration/conf testConfigurationXMLDocument.xml
                        testDigesterCreateObject.xml
               configuration/src/test/org/apache/commons/configuration
                        TestConfigurationXMLDocument.java
  Log:
  Java classes and test data for Bug 26944 from Oliver Heger.
  
  Revision  Changes    Path
  1.8       +6 -2      jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java
  
  Index: CompositeConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CompositeConfiguration.java	27 Feb 2004 17:41:35 -0000	1.7
  +++ CompositeConfiguration.java	8 Mar 2004 23:27:09 -0000	1.8
  @@ -258,6 +258,8 @@
       {
           CompositeConfiguration subsetCompositeConfiguration =
               new CompositeConfiguration();
  +        Configuration subConf = null;
  +        int count = 0;
           for (ListIterator i = configList.listIterator(); i.hasNext();)
           {
               Configuration config = (Configuration) i.next();
  @@ -265,9 +267,11 @@
               if (subset != null)
               {
                   subsetCompositeConfiguration.addConfiguration(subset);
  +                subConf = subset;
  +                count++;
               }
           }
  -        return subsetCompositeConfiguration;
  +        return (count == 1) ? subConf : subsetCompositeConfiguration;
       }
       /**
        * Get a List of strings associated with the given configuration key.
  
  
  
  1.9       +7 -20     jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationFactory.java
  
  Index: ConfigurationFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationFactory.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ConfigurationFactory.java	27 Feb 2004 17:41:35 -0000	1.8
  +++ ConfigurationFactory.java	8 Mar 2004 23:27:09 -0000	1.9
  @@ -154,7 +154,7 @@
           {
           	log.error("IO Exception caught", ioe);
           	throw new ConfigurationException("IO Exception caught",ioe);
  -        }		
  +        }
           return builder.getConfiguration();
       }
       /**
  @@ -267,7 +267,7 @@
   			matchString + "hierarchicalDom4j",
   			new BasePathConfigurationFactory(HierarchicalDOM4JConfiguration.class),
   			METH_LOAD,
  -			additional);        
  +			additional);
           setupDigesterInstance(
               digester,
               matchString + "jndi",
  @@ -391,17 +391,13 @@
   
       /**
        * A base class for digester factory classes. This base class maintains
  -     * a default class for the objects to be created. It also supports a
  -     * <code>className</code> attribute for specifying a different class.
  +     * a default class for the objects to be created.
        * There will be sub classes for specific configuration implementations.
        */
       public class DigesterConfigurationFactory
           extends AbstractObjectCreationFactory
           implements ObjectCreationFactory
       {
  -        /** Constant for the className attribute.*/
  -        protected static final String ATTR_CLASSNAME = "className";
  -
           /** Actual class to use. */
           private Class clazz;
   
  @@ -415,23 +411,14 @@
           }
   
           /**
  -         * Creates an instance of the specified class. If the passed in
  -         * attributes contain a <code>className</code> attribute, the value
of
  -         * this attribute is interpreted as the full qualified class name of
  -         * the class to be instantiated. Otherwise the default class is used.
  -         * @param attribs the attributes
  +         * Creates an instance of the specified class.
  +         * @param attribs the attributes (ignored)
            * @return the new object
            * @exception Exception if object creation fails
            */
           public Object createObject(Attributes attribs) throws Exception
           {
  -            Class actCls;
  -            
  -            int idx = attribs.getIndex(ATTR_CLASSNAME);
  -            actCls = (idx < 0) ? clazz :
  -            Class.forName(attribs.getValue(idx));
  -
  -            return actCls.newInstance();
  +            return clazz.newInstance();
           }
       }
   
  
  
  
  1.3       +1 -1      jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationXMLDocument.java
  
  
  
  
  1.3       +0 -0      jakarta-commons/configuration/conf/testConfigurationXMLDocument.xml
  
  
  
  
  1.3       +1 -1      jakarta-commons/configuration/conf/testDigesterCreateObject.xml
  
  
  
  
  1.4       +8 -3      jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationXMLDocument.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message