You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by epugh <ep...@upstate.com> on 2003/07/21 15:44:39 UTC

[CONFIGURATION] Multiple Namespaces for use with Multiple Apps

Lets move this over to commons-config so other (more knowledgable types) can
chime in...

I am not real sure about the whole namespace stuff, to be honest.   Would
you have just a single configuration digester file for every single
application?  Because something I have thought about would be if I wanted to
have a single config for multiple apps, then the best place to store that is
really in a database table..  A JDBCConfiguration could be easily written
where you have a table with columns name, value, namespace, and your
namespace is broken up by application...

I think, if you specify multiple property files in the digester, then all
will be loaded..  However, having said that, they are just a bunch of POJO
objects in memeory, and if you use a singleton pattern, then they will exist
only once, so the memory impact should be minimal..

Eric

-----Original Message-----
From: Keith Kee [mailto:kkee@ARCCorp.com]
Sent: Monday, July 21, 2003 1:58 PM
To: 'epugh@upstate.com'
Subject: RE: commons configuration


Thanks for the explanation. Just so that we are on the same page, say if I
separate each module of all J2EE enterprise applications by namespace. Only
the properties files and XML pertaining to that namespace will be loaded,
right? That is, not all the properties and xml files in the entire composite
configuration digester file will be loaded.

The reason why I ask is because I am thinking of creating kind of a Table of
Content using the digester file. From which, it will separate each web app
or module by namespace. Do you think it is a good idea? Will there be any
memory impact on this approach?

Thanks
Keith

> -----Original Message-----
> From: epugh [mailto:epugh@upstate.com]
> Sent: Sunday, July 20, 2003 3:05 PM
> To: 'Keith Kee'
> Subject: RE: commons configuration
>
>
> Wow! Great questions..  and remember, if you don't like
> something abouc C-C, submit a patch!
>
> Let see, the CompositeConfiguration doesn't use a lot of
> memory, basically it uses the same as if you had 5 seperate
> configurations, because it is just a wrapper.  The
> ConfigurationFactory only runs at the beginning, after that
> it wouldn't be in memory.  The configuration values depend on
> their type. For xml and property files, they are loaded
> immediatly.  But for JNDI, they are lazy loaded.  However,
> once loaded, they remain loaded, so if you change your jndi
> tree, the JNDIConfiguration won't know about it.
>
> If you use a singleton model to get your confirguration, then
> it would just be one per JVM. If you don't then, it would be
> one per application.
>
> ERic
> -----Original Message-----
> From: Keith Kee [mailto:kkee@ARCCorp.com]
> Sent: Sunday, July 20, 2003 7:21 PM
> To: 'epugh@upstate.com'
> Subject: RE: commons configuration
>
>
> Hi Eric,
>    Thanks for replying, I will download maven and build C-C
> with it. Also, thanks for the suggestion about using
> compositeconfiguration. However, if all my classes use the
> compositeconfiguration, does it take up a lot of memory? Does
> it load one copy in memory per application (I am thinking
> webapps and EJBs)? Also, if I make use of namespaces to
> separate the configuration for each application, does the
> application simply load the configuration for the particular
> namespace or the entire configuration file? Lastly, does C-C
> load all the properties in memory (or lazily), and does it
> cache the properties?
>
> Thanks again for your help,
> Keith
>
> > -----Original Message-----
> > From: epugh [mailto:epugh@upstate.com]
> > Sent: Wednesday, July 16, 2003 10:59 AM
> > To: 'Keith Kee'
> > Subject: RE: commons configuration
> >
> >
> > a ha!  Yes, C-C is meant to be built with Maven.  Maven provides a
> > plugin to build an Ant build.xml file, however, since non of the
> > developers ever run it, it seems to get out of date...  The
> testcase
> > that failed shouldn't have been run, as it has no tests in
> it!  argh..
> > a bug I guess in the ant build.xml plugin..
> >
> > I would highly recommend using Maven, it is great.  b10 just came
> > out...
> >
> > So, insofar as reading in config values, you are refering to
> > applications versus webapps?  I would look at the
> > CompositeConfiguration and the ConfigurationFactory.
> >
> > If you established a rule that at the root of your classes
> would be a
> > configuration.xml, then you could have that file load up a
> > compositeconfiguration where the variosu config files might
> be jndi,
> > propertiy files, or other xml files!
> >
> > Does this make sense?
> >
> > Eric
> >
> > -----Original Message-----
> > From: Keith Kee [mailto:kkee@ARCCorp.com]
> > Sent: Wednesday, July 16, 2003 2:19 PM
> > To: 'epugh@upstate.com'
> > Subject: RE: commons configuration
> >
> >
> > Hi Eric,
> >     I think C-C is going to be great for maintenance in
> production. A
> > side question. I am trying to get all the developers to use this
> > module for their applications, so that in production, I can
> change all
> > the applications' properties without ever messing around with
> > deployment descriptors. In your opinion, what is the best
> way to the
> > applications to be made aware of the file from which they
> should load
> > the configurations from? So far, I can only come up with setting
> > a system property in a startup script where an application
> > will read where the master digester rule file is. From there,
> > it will read from its own namespace for all its configuration
> > data. From your experience in production, is there a better way?
> >     Below is the output of the ant build process. I am not
> > using maven but ant. Would that be a problem?
> >
> > $ ant clean
> > Buildfile: build.xml
> >
> > clean:
> >    [delete] Deleting directory
> > C:\sfw\jakarta-commons-sandbox\configuration\targ
> > et
> >    [delete] Deleting directory
> > C:\sfw\jakarta-commons-sandbox\configuration\dist
> >
> >
> > BUILD SUCCESSFUL
> > Total time: 1 second
> >
> > kkee@KKEE /dev/c/sfw/jakarta-commons-sandbox/configuration
> > $ ant
> > Buildfile: build.xml
> >
> > init:
> >     [mkdir] Created dir:
> > C:\sfw\jakarta-commons-sandbox\configuration\target\lib
> >
> >
> > get-deps:
> >       [get] Getting:
> > http://www.ibiblio.org/maven/commons-collections/jars/commo
> > ns-collections-2.1.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/commons-lang/jars/commons-lang
> > -1.0.1.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/commons-logging/jars/commons-l
> > ogging-1.0.2.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/dom4j/jars/dom4j-1.3.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/commons-digester/jars/commons-
> > digester-1.5.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/commons-beanutils/jars/commons
> > -beanutils-1.6.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/xerces/jars/xerces-2.2.1.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/xml-apis/jars/xml-apis-2.0.2.j
> > ar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/junit/jars/junit-3.8.1.jar
> >       [get] Getting:
> http://www.ibiblio.org/maven/ant/jars/ant-1.5.jar
> >       [get] Getting:
> > http://www.ibiblio.org/maven/ant/jars/ant-optional-1.5.jar
> >
> > compile:
> >     [mkdir] Created dir:
> > C:\sfw\jakarta-commons-sandbox\configuration\target\cla
> > sses
> >     [javac] Compiling 13 source files to
> > C:\sfw\jakarta-commons-sandbox\configur
> > ation\target\classes
> >      [copy] Copying 16 files to
> > C:\sfw\jakarta-commons-sandbox\configuration\tar
> > get\classes
> >      [copy] Copying 6 files to
> > C:\sfw\jakarta-commons-sandbox\configuration\targ
> > et\test-classes
> >
> > compile-tests:
> >     [javac] Compiling 16 source files to
> > C:\sfw\jakarta-commons-sandbox\configur
> > ation\target\test-classes
> >
> > internal-test:
> >     [mkdir] Created dir:
> > C:\sfw\jakarta-commons-sandbox\configuration\target\tes
> > t-reports
> >     [junit] Running
> > org.apache.commons.configuration.NonStringTestHolder
> >     [junit] Tests run: 1, Failures: 1, Errors: 0, Time
> > elapsed: 0.31 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.NonStringTestHolder
> >     [junit] Tests run: 1, Failures: 1, Errors: 0, Time
> > elapsed: 0.31 sec
> >
> >     [junit] Testcase: warning took 0 sec
> >     [junit]     FAILED
> >     [junit] No tests found in
> > org.apache.commons.configuration.NonStringTestHold
> > er
> >     [junit] junit.framework.AssertionFailedError: No tests found in
> > org.apache.c ommons.configuration.NonStringTestHolder
> >
> >     [junit] Testcase: warning
> >     [junit] TEST
> org.apache.commons.configuration.NonStringTestHolder
> > FAILED
> >     [junit] Running
> > org.apache.commons.configuration.TestBaseConfiguration
> >     [junit] Tests run: 4, Failures: 0, Errors: 0, Time
> > elapsed: 0.33 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestBaseConfiguration
> >     [junit] Tests run: 4, Failures: 0, Errors: 0, Time
> > elapsed: 0.33 sec
> >
> >     [junit] Testcase: testRetrieve took 0.01 sec
> >     [junit] Testcase: testInterpolation took 0.02 sec
> >     [junit] Testcase: testMultipleInterpolation took 0 sec
> >     [junit] Testcase: testInterpolationLoop took 0 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestCompositeConfiguration
> >     [junit] Tests run: 16, Failures: 0, Errors: 0, Time
> > elapsed: 0.59 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestCompositeConfigurati
> > on
> >     [junit] Tests run: 16, Failures: 0, Errors: 0, Time
> > elapsed: 0.59 sec
> >
> >     [junit] Testcase: testAddRemoveConfigurations took 0.17 sec
> >     [junit] Testcase: testGetProperty took 0.01 sec
> >     [junit] Testcase: testCantRemoveMemoryConfig took 0 sec
> >     [junit] Testcase: testGetPropertyMissing took 0.02 sec
> >     [junit] Testcase: testMultipleTypesOfConfigs took 0.01 sec
> >     [junit] Testcase: testPropertyExistsInOnlyOneConfig took 0 sec
> >     [junit] Testcase: testDefaultValueWhenKeyMissing took 0.01 sec
> >     [junit] Testcase: testGettingConfiguration took 0.01 sec
> >     [junit] Testcase: testClearingProperty took 0.01 sec
> >     [junit] Testcase: testAddingProperty took 0.01 sec
> >     [junit] Testcase: testSettingMissingProperty took 0.01 sec
> >     [junit] Testcase: testGettingSubset took 0.01 sec
> >     [junit] Testcase: testVector took 0.01 sec
> >     [junit] Testcase: testStringArray took 0 sec
> >     [junit] Testcase: testGetKeysPreservesOrder took 0.01 sec
> >     [junit] Testcase: testGetKeys2PreservesOrder took 0.01 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestCompositeConfigurationN
> > onStringProperties
> >     [junit] Tests run: 23, Failures: 0, Errors: 0, Time
> > elapsed: 0.401 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestCompositeConfigurati
> > onNonStringProperties
> >     [junit] Tests run: 23, Failures: 0, Errors: 0, Time
> > elapsed: 0.401 sec
> >
> >     [junit] Testcase: testBoolean took 0.05 sec
> >     [junit] Testcase: testBooleanDefaultValue took 0.01 sec
> >     [junit] Testcase: testBooleanArrayValue took 0 sec
> >     [junit] Testcase: testByte took 0 sec
> >     [junit] Testcase: testByteArrayValue took 0 sec
> >     [junit] Testcase: testDouble took 0.01 sec
> >     [junit] Testcase: testDoubleDefaultValue took 0 sec
> >     [junit] Testcase: testDoubleArrayValue took 0 sec
> >     [junit] Testcase: testFloat took 0.011 sec
> >     [junit] Testcase: testFloatDefaultValue took 0 sec
> >     [junit] Testcase: testFloatArrayValue took 0 sec
> >     [junit] Testcase: testInteger took 0 sec
> >     [junit] Testcase: testIntegerDefaultValue took 0 sec
> >     [junit] Testcase: testIntegerArrayValue took 0.01 sec
> >     [junit] Testcase: testLong took 0 sec
> >     [junit] Testcase: testLongDefaultValue took 0 sec
> >     [junit] Testcase: testLongArrayValue took 0.01 sec
> >     [junit] Testcase: testShort took 0 sec
> >     [junit] Testcase: testShortDefaultValue took 0 sec
> >     [junit] Testcase: testShortArrayValue took 0 sec
> >     [junit] Testcase: testVectorMissing took 0 sec
> >     [junit] Testcase: testSubset took 0.01 sec
> >     [junit] Testcase: testIsEmpty took 0 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestConfigurationConverter
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time
> > elapsed: 0.311 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestConfigurationConvert
> > er
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time
> > elapsed: 0.311 sec
> >
> >     [junit] Testcase: testConverter took 0.011 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestConfigurationFactory
> >     [junit] Tests run: 5, Failures: 0, Errors: 0, Time
> > elapsed: 0.781 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestConfigurationFactory
> >
> >     [junit] Tests run: 5, Failures: 0, Errors: 0, Time
> > elapsed: 0.781 sec
> >
> >     [junit] Testcase: testLoadingConfiguration took 0.331 sec
> >     [junit] Testcase: testLoadingConfigurationReverseOrder
> > took 0.03 sec
> >     [junit] Testcase: testLoadingConfigurationWithRulesXML
> > took 0.08 sec
> >     [junit] Testcase: testLoadingConfigurationNamespaceAware
> > took 0.01 sec
> >     [junit] Testcase: testLoadingConfigurationBasePath took 0.01 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestConfigurationUtils
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time
> > elapsed: 0.311 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestConfigurationUtils
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time
> > elapsed: 0.311 sec
> >
> >     [junit] Testcase: testCompare took 0.01 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestDOM4JConfiguration
> >     [junit] Tests run: 5, Failures: 0, Errors: 0, Time
> > elapsed: 0.491 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestDOM4JConfiguration
> >     [junit] Tests run: 5, Failures: 0, Errors: 0, Time
> > elapsed: 0.491 sec
> >
> >     [junit] Testcase: testGetProperty took 0.12 sec
> >     [junit] Testcase: testGetComplexProperty took 0.01 sec
> >     [junit] Testcase: testSettingFileNames took 0 sec
> >     [junit] Testcase: testLoad took 0.02 sec
> >     [junit] Testcase: testLoadWithBasePath took 0.01 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestEqualBehaviour
> >     [junit] Tests run: 7, Failures: 0, Errors: 0, Time
> > elapsed: 0.56 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestEqualBehaviour
> >     [junit] Tests run: 7, Failures: 0, Errors: 0, Time
> > elapsed: 0.56 sec
> >
> >     [junit] Testcase: testLoading took 0.23 sec
> >     [junit] Testcase: testDeletingExisting took 0 sec
> >     [junit] Testcase: testDeletingNonExisting took 0.01 sec
> >     [junit] Testcase: testSettingNonExisting took 0.01 sec
> >     [junit] Testcase: testSettingExisting took 0.01 sec
> >     [junit] Testcase: testAddingUnset took 0.01 sec
> >     [junit] Testcase: testAddingSet took 0 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestEqualsProperty
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time
> > elapsed: 0.34 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestEqualsProperty
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time
> > elapsed: 0.34 sec
> >
> >     [junit] Testcase: testEquals took 0.05 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestNonStringProperties
> >     [junit] Tests run: 23, Failures: 0, Errors: 0, Time
> > elapsed: 0.4 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestNonStringProperties
> >     [junit] Tests run: 23, Failures: 0, Errors: 0, Time
> > elapsed: 0.4 sec
> >
> >     [junit] Testcase: testBoolean took 0.06 sec
> >     [junit] Testcase: testBooleanDefaultValue took 0 sec
> >     [junit] Testcase: testBooleanArrayValue took 0 sec
> >     [junit] Testcase: testByte took 0.01 sec
> >     [junit] Testcase: testByteArrayValue took 0 sec
> >     [junit] Testcase: testDouble took 0 sec
> >     [junit] Testcase: testDoubleDefaultValue took 0 sec
> >     [junit] Testcase: testDoubleArrayValue took 0 sec
> >     [junit] Testcase: testFloat took 0.01 sec
> >     [junit] Testcase: testFloatDefaultValue took 0 sec
> >     [junit] Testcase: testFloatArrayValue took 0 sec
> >     [junit] Testcase: testInteger took 0 sec
> >     [junit] Testcase: testIntegerDefaultValue took 0 sec
> >     [junit] Testcase: testIntegerArrayValue took 0.01 sec
> >     [junit] Testcase: testLong took 0 sec
> >     [junit] Testcase: testLongDefaultValue took 0 sec
> >     [junit] Testcase: testLongArrayValue took 0.01 sec
> >     [junit] Testcase: testShort took 0 sec
> >     [junit] Testcase: testShortDefaultValue took 0 sec
> >     [junit] Testcase: testShortArrayValue took 0 sec
> >     [junit] Testcase: testVectorMissing took 0 sec
> >     [junit] Testcase: testSubset took 0.01 sec
> >     [junit] Testcase: testIsEmpty took 0 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestPropertiesConfiguration
> >
> >     [junit] Tests run: 7, Failures: 0, Errors: 0, Time
> > elapsed: 0.36 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestPropertiesConfigurat
> > ion
> >     [junit] Tests run: 7, Failures: 0, Errors: 0, Time
> > elapsed: 0.36 sec
> >
> >     [junit] Testcase: testLoadViaPropertyWithBasePath took 0.06 sec
> >     [junit] Testcase: testLoadViaPropertyWithBasePath2 took 0 sec
> >     [junit] Testcase: testLoad took 0 sec
> >     [junit] Testcase: testEmpty took 0 sec
> >     [junit] Testcase: testReference took 0 sec
> >     [junit] Testcase: testLoadInclude took 0 sec
> >     [junit] Testcase: testVector took 0 sec
> >     [junit] Running
> > org.apache.commons.configuration.TestPropertiesSequence
> >     [junit] Tests run: 3, Failures: 0, Errors: 0, Time
> > elapsed: 0.52 sec
> >     [junit] Testsuite:
> > org.apache.commons.configuration.TestPropertiesSequence
> >     [junit] Tests run: 3, Failures: 0, Errors: 0, Time
> > elapsed: 0.52 sec
> >
> >     [junit] Testcase:
> testConfigurationValuesInSameOrderFromFile took
> > 0.22 sec
> >     [junit] Testcase:
> testConfigurationValuesInSameOrderWithManualAdd
> > took 0.01 sec
> >     [junit] Testcase: testMappingInSameOrder took 0.01 sec
> >
> > test:
> >
> > BUILD FAILED
> > file:c:/sfw/jakarta-commons-sandbox/configuration/build.xml:82
> > : There were test failures.
> >
> >
> > Total time: 1 minute 28 seconds
> >
> > kkee@KKEE /dev/c/sfw/jakarta-commons-sandbox/configuration
> > $
> >
> > > -----Original Message-----
> > > From: epugh [mailto:epugh@upstate.com]
> > > Sent: Wednesday, July 16, 2003 4:42 AM
> > > To: 'Keith Kee'
> > > Subject: RE: commons configuration
> > >
> > >
> > > Hi Keith,
> > >
> > > Glad to hear that you like it!  C-C is used by Turbine,
> which is an
> > > pretty sophisticated web environment.  I have been running it
> > > successfully in production for a couple months. We are rapidly
> > > approaching our 1.0 release to migrate C-C out of the
> > commons-sandbox.
> > >
> > > Could you send me the output of your failing tests?  I will
> > look into
> > > the errors as I believe everything builds nicely. You are
> > using Maven
> > > to perfore the build, correct?
> > >
> > > Eric Pugh
> > >
> > > -----Original Message-----
> > > From: Keith Kee [mailto:kkee@ARCCorp.com]
> > > Sent: Monday, July 14, 2003 2:07 PM
> > > To: epugh@upstate.com
> > > Subject: commons configuration
> > >
> > >
> > > Hi Eric,
> > >    I came across this configuration component while
> > searching for such
> > > a framework/module to search our configuration
> > standardization. I have
> > > helped developed a similar module in my previous company.
> > Do you know
> > > if the commons configuration component is ready for prime
> > time? I have
> > > checked out the source and built it. Unfortunately, some of
> > the junit
> > > tests failed.
> > >     Are you aware of any other open source projects that
> > are trying to
> > > solve the same problem?
> > >
> > > Thanks in advance,
> > > Keith
> > >
> >
>


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