public interface Settings4jInstance
Settings4j
Modifier and Type | Method and Description |
---|---|
void |
addConnector(Connector connector)
Add a
Connector . |
void |
addConnector(Connector connector,
ConnectorPosition position)
Add a custom
Connector to the right position in relation to the other connectors. |
Connector |
getConnector(String connectorName)
Return the
Connector for the given Name. |
List<Connector> |
getConnectors()
Return a List off
Connector who can be used with this Settings4jInstance instance. |
byte[] |
getContent(String key)
return the found byte[]-Value for the given key.
|
Map |
getMapping()
The key mapping defined in settings4j.xml.
|
Object |
getObject(String key)
return the found Object-Value for the given key.
|
String |
getString(String key)
return the found String-Value for the given key.
|
void |
removeAllConnectors()
Remove all Settings.
|
void |
setMapping(Map mapping)
Set the mapping for this Settings-Object without inheritance.
|
String getString(String key)
Settings4jInstance
Instance iterates all his Connector
s and return the first found Value.
Returns null if no connector found a Value for the given key
key
- the Key for the configuration-property. e.g.: "com/mycompany/myapp/myParameterKey"byte[] getContent(String key)
Settings4jInstance
Instance iterates all his Connector
s and return the first found Value.
Returns null if no connector found a Value for the given key
key
- the Key for the configuration-property. e.g.: "com/mycompany/myapp/myParameterKey"Object getObject(String key)
Settings4jInstance
iterates all his Connector
s and return the first found Value. key
- the Key for the configuration-property. e.g.: "com/mycompany/myapp/myParameterKey"void addConnector(Connector connector)
Connector
.Example configuration in settings4j.xml: -------------------------------------- <settings name="com.mycompany" > <connector-ref name="DBConnector" /> </settings> --------------------------------------
connector
- The connector to add.void addConnector(Connector connector, ConnectorPosition position)
Connector
to the right position in relation to the other connectors.Settings4jInstance
--------------------------------------
Connector myConnector = ...
addConnector(myConnector, ConnectorPositions
.afterLast(SystemPropertyConnector.class));
--------------------------------------
ConnectorPositions
.afterLast(SystemPropertyConnector.class)
will throw an exception if the
Settings4jInstance
doesn't have a SystemPropertyConnector. -------------------------------------- Connector myConnector = ... addConnector(myConnector, ConnectorPositions.firstValid(// ConnectorPositions.afterLast(SystemPropertyConnector.class), ConnectorPositions.atFirst() // fallback if no SystemPropertyConnector exists. ) ); --------------------------------------
addConnector(Connector)
will throw an exception if a connector with the same name already exists. getConnector(String)
if the Connector already
exists:
-------------------------------------- Connector myConnector = ... if(getConnector(myConnector.getName()) == null) { addConnector(myConnector, ConnectorPositions.firstValid(// ConnectorPositions.afterLast(SystemPropertyConnector.class), ConnectorPositions.atFirst() // fallback if no SystemPropertyConnector exists. ) ); } --------------------------------------
connector
- The connector to add.position
- The position where the connector should be added.void removeAllConnectors()
Map getMapping()
if some Sub-Modules of your App defines separated Keys for e.g. the DataSource, you can refer it to one unique Key:
Example: <mapping name="defaultMapping"> <entry key="com/mycompany/moduleX/datasource" ref-key="global/datasource"/> <entry key="com/mycompany/moduleY/datasource" ref-key="global/datasource"/> </mapping>Settings4j.getXXX("com/mycompany/moduleX/datasource");
void setMapping(Map mapping)
Example: <root mapping-ref="defaultMapping" > ... </root> <mapping name="defaultMapping"> <entry key="com/mycompany/moduleX/datasource" ref-key="global/datasource"/> <entry key="com/mycompany/moduleY/datasource" ref-key="global/datasource"/> </mapping>
mapping
- The Mapping between available settings to used settings.List<Connector> getConnectors()
Connector
who can be used with this Settings4jInstance
instance.Settings4jInstance
instanceCopyright © 2008–2014. All rights reserved.