commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phineas Fung" <phineas.f...@ckh.com.hk>
Subject [Configuration] read different XML configuration files based on FQCN
Date Thu, 09 Jun 2005 07:52:37 GMT
Hi,

We have a few implementation classes that implements the same worker
interface, that are returned by  a factory at runtime.

Every implementation class needs to read an XML configuration file (to be
exact, a tree structure).  The XML hierarchy and fields in each
configuration file are the same, but contents are different for each
implementation class.

Unfortunately, all of these implementation classes will be used at the same
time, and I cannot figure out how to let each implementation class read its
own XML file.

If I do sth like this:

<configuration>
  <system/>
  <xml fileName="implementationClass_A.xml"/>
  <xml fileName="implementationClass_B.xml"/>
  <xml fileName="implementationClass_C.xml"/>
</configuration>

The values in implementationClass_C.xml will be overridden by those in A or
B.  What I want is:

Construct a ConfigurationRepository using the fully-qualified class name,
i.e. "ImplementationClass_C", then it'll read configuration values from
implementationClass_C.xml.  Another ConfigurationRepository using e.g.
"ImplementationClass_B", then it'll read configuration values from
implementationClass_B.xml.

Sample configuration files are:

implementationClass_A.xml

<config>
    <cacheTree name="field1_field2_field3">
        <level sortingOrder="100" field="field1"/>
        <level sortingOrder="200" field="field2"/>
        <level sortingOrder="300" field="field3"/>
    </cacheTree>

    <cacheTree name="field1_field3">
        <level sortingOrder="100" field="field1"/>
        <level sortingOrder="200" field="field3"/>
    </cacheTree>

    <getterMethod methodName="get_Field1" cacheTree="field1_field3"/>
    <getterMethod methodName="get_Field1_Field2"
cacheTree="field1_field2_field3"/>
    <getterMethod methodName="get_Field1_Field3" cacheTree="field1_field3"/>
    <getterMethod methodName="get_Field1_Field2_Field3"
cacheTree="field1_field2_field3"/>
    <getterMethod methodName="get_Field1_Field2_Field3_Field4"
cacheTree="field1_field2_field3"/>
</config>

implementationClass_B.xml

<config>
    <cacheTree name="field1_field2">
        <level sortingOrder="100" field="field1"/>
        <level sortingOrder="200" field="field2"/>
    </cacheTree>

    <getterMethod methodName="get_Field1" cacheTree="field1_field2"/>
    <getterMethod methodName="get_Field1_Field2" cacheTree="field1_field2"/>
</config>

Any thoughts will be greatly appreciated.

Thanks alot.


Best Regards,
Phineas


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


Mime
View raw message