public class ConfigurationToConnectorAdapter extends AbstractPropertyConnector
Create a 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() |
String |
getString(String key)
return a String-Value for the given key.
|
getContent, getObject
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.public String getString(String key)
Connector
key
- the Key for the configuration-property. e.g.: "com/mycompany/myapp/myParameterKey"public org.apache.commons.configuration.Configuration getConfiguration()
Copyright © 2008–2016 Brabenetz Harald, Austria. All rights reserved.