public class ConfigurationToConnectorAdapter extends AbstractPropertyConnector
XMLConfiguration
instance and add it to the Settings4j instance as
Connector.
String connectorName = "myCommonsConfigXmlConfigConnector"; Connector connector = Settings4j.getSettings().getConnector(connectorName); if (connector == null) { XMLConfiguration configuration = new XMLConfiguration(new File(.....)); connector = new ConfigurationToConnectorAdapter(connectorName, configuration); // add the connecter after the last SystemPropertyConnector or add it as first connector. Settings4j.getSettings().addConnector(connector, // ConnectorPositions.firstValid(// ConnectorPositions.afterLast(SystemPropertyConnector.class), // ConnectorPositions.atFirst() // if no SystemPropertyConnector is configured. )// ); }
Constructor and Description |
---|
ConfigurationToConnectorAdapter(String name,
org.apache.commons.configuration.Configuration configuration) |
Modifier and Type | Method and Description |
---|---|
org.apache.commons.configuration.Configuration |
getConfiguration() |
protected String |
getProperty(String key,
String defaultValue)
Very similar to
System.getProperty except that the SecurityException is hidden. |
getContent, getObject, getString
addConnector, getConnectors, getContentResolver, getName, getObjectResolver, init, setContentResolver, setName, setObjectResolver
public ConfigurationToConnectorAdapter(String name, org.apache.commons.configuration.Configuration configuration)
name
- The unique name of this connector.configuration
- The apache commons configuration instance to wrap and use as Settings4j connector.protected String getProperty(String key, String defaultValue)
AbstractPropertyConnector
System.getProperty
except that the SecurityException
is hidden.getProperty
in class AbstractPropertyConnector
key
- The key to search for.defaultValue
- The default value to return.public org.apache.commons.configuration.Configuration getConfiguration()
Copyright © 2008–2014. All rights reserved.