You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The existing org.apache.commons.configuration.EnvironmentConfiguration provides access to the environment variables via an abstract Configuration API. However the problem is that while the more abstract Configuration operates with properties (that in turn implies a dot-separated key notation considered a standard in Java world) the EnvironmentConfiguration preserves original environment variable names which is usually an upper-cased snake notation. This discrepancy spill out the particular class implementational details over its API, and logically couples the caller to the implementation.
One of the use-cases where the issue pops is CompositeConfiguration. Combining EnvironmentConfiguration with almost any other Configuration implementation in one bucket won't work as expected.
Example:
valconf=newCompositeConfiguration(asList(
newEnvironmentConfiguration,
newSystemConfiguration,
newJNDIConfiguration("java:comp/env")
))
conf.getString("java.vm.vendor") should not be null// OK - defined in JVM system properties as "java.vm.vendor"
conf.getString("env.jdbc.datasource") should not be null// OK - defined in JNDI as "java:comp/env/jdbc/datasource"
conf.getString("scala.home") should not be null// FAILS !!!
conf.getString("SCALA_HOME") should not be null// OK - defined in System environment, so I have to use a proper notation
Solution
Create an extension to the EnvironmentConfiguration that would respect domain naming convention for keys, so that calling
(newEnvironmentConfiguration).getString("scala.home") // would lookup for SCALA_HOME in system environment
Similarly to how it's done in JNDIConfiguration for instance.
The text was updated successfully, but these errors were encountered:
Problem
The existing
org.apache.commons.configuration.EnvironmentConfiguration
provides access to the environment variables via an abstractConfiguration
API. However the problem is that while the more abstractConfiguration
operates with properties (that in turn implies a dot-separated key notation considered a standard in Java world) theEnvironmentConfiguration
preserves original environment variable names which is usually an upper-cased snake notation. This discrepancy spill out the particular class implementational details over its API, and logically couples the caller to the implementation.One of the use-cases where the issue pops is
CompositeConfiguration
. CombiningEnvironmentConfiguration
with almost any otherConfiguration
implementation in one bucket won't work as expected.Example:
Solution
Create an extension to the
EnvironmentConfiguration
that would respect domain naming convention for keys, so that callingSimilarly to how it's done in
JNDIConfiguration
for instance.The text was updated successfully, but these errors were encountered: