commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: How to use commons config in multiple VM environment
Date Thu, 25 Mar 2010 14:15:05 GMT

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


Mime
View raw message