You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by yogen <ya...@gmail.com> on 2010/03/25 14:55:31 UTC
How to use commons config in multiple VM environment
Hi,
I am using commons configuration in a multi process and multi vm
environment.
Today, we have one config per process and this leads to a overload of
duplicate parameters and a nightmare to maintain.
Does anyone have best practices on how to unify the config, but still
maintain flexibility for developers to test each process on its own in
development lifer cycle?
Thanks.
--
View this message in context: http://n4.nabble.com/How-to-use-commons-config-in-multiple-VM-environment-tp1690655p1690655.html
Sent from the Commons - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: How to use commons config in multiple VM environment
Posted by Ralph Goers <ra...@dslextreme.com>.
On Mar 25, 2010, at 6:55 AM, yogen wrote:
>
> Hi,
>
> I am using commons configuration in a multi process and multi vm
> environment.
>
> Today, we have one config per process and this leads to a overload of
> duplicate parameters and a nightmare to maintain.
>
> Does anyone have best practices on how to unify the config, but still
> maintain flexibility for developers to test each process on its own in
> development lifer cycle?
>
Sure. We use DefaultConfigurationBuilder and the configuration shown below. This allows us to have default values mixed with overrides.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Test configuration definition file that demonstrates complex initialization
-->
<configuration systemProperties="app-config.properties">
<header>
<result delimiterParsingDisabled="true" forceReloadCheck="true"
config-class="org.apache.commons.configuration.DynamicCombinedConfiguration" keyPattern="$${mdc:bcId}">
<expressionEngine config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine" />
<nodeCombiner config-class="org.apache.commons.configuration.tree.MergeCombiner" />
</result>
<entity-resolver catalogFiles="${sys:repoURL}/repositoryResolver.xml" debug="true" />
<lookups>
<lookup config-prefix="mdc" config-class="org.slf4j.ext.MDCStrLookup" />
</lookups>
<providers>
<provider config-tag="multifile"
config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$FileConfigurationProvider"
configurationClass="org.apache.commons.configuration.MultiFileHierarchicalConfiguration" />
</providers>
</header>
<override>
<multifile
filePattern="${sys:repoURL}/fi/$$${mdc:bcIndex}/$$${mdc:canonicalId}/$$${mdc:canonicalId}-env.xml"
delimiterParsingDisabled="true" attributeSplittingDisabled="true"
config-name="fiConfig" schemaValidation="${sys:schemaValidation}">
<reloadingStrategy refreshDelay="60000"
config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy" />
</multifile>
<xml fileName="${sys:repoURL}/defaults/env-defaults.xml" config-name="defaultConfig" optional="${sys:envDefaultConfigOptional}"
delimiterParsingDisabled="true" attributeSplittingDisabled="true"
schemaValidation="${sys:schemaValidation}">
<reloadingStrategy refreshDelay="60000" config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy" />
</xml>
</override>
</configuration>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: How to use commons config in multiple VM environment
Posted by yogen <ya...@gmail.com>.
Not sure what you mean.
Can you attach an example source and config?
Thanks.
--
View this message in context: http://n4.nabble.com/How-to-use-commons-config-in-multiple-VM-environment-tp1690655p1690698.html
Sent from the Commons - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: How to use commons config in multiple VM environment
Posted by Tom <tb...@tbee.org>.
> Does anyone have best practices on how to unify the config, but still
> maintain flexibility for developers to test each process on its own in
> development lifer cycle?
>
What works for us, is a configuration class which supports context
dependent values, e.g.
port=1234
port[system|dev1]=4567
Or when using XML:
<port>1234</port>
<port system="dev1">4567</port>
This means that there are default values and more specific settings
override the default / less specific.
Aside from specialized values, the class also searches for multiple
configuration files. This is so production can have it settings (e.g.
usernames and passwords) in separate files, so these do not need to be
included in CVS/SVN/BZR/GIT/... for easy deployment.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org