[ 
https://issues.apache.org/jira/browse/CONFIGURATION-288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12518126
 ] 

Thorbjørn Ravn Andersen commented on CONFIGURATION-288:
-------------------------------------------------------

Code snippet (GetNestedConfigurationName.java)

package x;

import org.apache.commons.configuration.CombinedConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.log4j.BasicConfigurator;

public class GetNestedConfigurationName {

        public static void main(String[] args) {
                try {
                        main0(args);
                } catch (Throwable e) {
                        e.printStackTrace();
                }
        }
        public static void main0(String[] args) throws Exception {
                BasicConfigurator.configure();
                DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder("A.xml");
                Configuration configuration = builder.getConfiguration();
                System.out.println("C is loaded : c.property1=" + 
configuration.getString("c.property1"));
                if (configuration instanceof CombinedConfiguration) {
                        CombinedConfiguration combined = 
(CombinedConfiguration) configuration;
                        Configuration c = combined.getConfiguration("C");
                        if (c == null) {
                                System.out.println("no configuration named C");
                        } else {
                                System.out.println("C by name : c.property1=" + 
c.getString("c.property1"));
                        }
                }
        }

}

output is

C is loaded : c.property1=value1
Combined configuration
no configuration named C

> getConfigurationNames() does not report names of nested configurations
> ----------------------------------------------------------------------
>
>                 Key: CONFIGURATION-288
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-288
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: Nightly Builds
>         Environment: using trunk of august 6 2007
>            Reporter: Thorbjørn Ravn Andersen
>         Attachments: A.xml, B.xml, C.properties, 
> GetNestedConfigurationName.java, namedConfiguration.jar
>
>
> Given a <configuration> A which includes a <configuration> B which in turn 
> loads the <properties> C.
> A and C has the config-name attribute.  B does not.
> Calling A.getConfigurationNames() does not return the name of C.  From my 
> initial reading of the code, it only returns names on the B level.
> It also appears that the name for A does not appear either.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to