public final class Settings4j extends Object
Example usage java: -------------------------------------- public class SettingsManager { public static String getMyFormula() { return Settings4j.getString("com/mycompany/mycalculation/my-formula"); } } --------------------------------------
Modifier and Type | Method and Description |
---|---|
static Connector |
getConnector(String connectorName)
Return the
Connector for the given Name. |
static List<Connector> |
getConnectors()
Return a List off
Connector who can be used with this Settings4j instance. |
static byte[] |
getContent(String key)
return the found byte[]-Value for the given key.
|
static Object |
getObject(String key)
return the found Object-Value for the given key.
|
static Settings4jRepository |
getSettingsRepository()
Get the
Settings4jRepository where this Settings-Object is stored. |
static String |
getString(String key)
return the found String-Value for the given key.
|
public static String getString(String key)
Settings4j
Instance iterates all his Connector
and return the first found Value.If no custom settings4j.xml exist in classpath, the following default order will be used:
System.getProperty(String)
exist (see
SystemPropertyConnector
),InitialContext.lookup(String)
exist (see
JNDIConnector
),Preferences.userRoot()
and
Preferences.systemRoot()
the Value for
Preferences.get(String, String)
exist (see
PreferencesConnector
),ClasspathConnector
).key
- the Key for the configuration-property. e.g.: "com/mycompany/myapp/myParameterKey"public static byte[] getContent(String key)
Settings4j
Instance iterates all his Connector
and
return the first found Value.
Returns null if no connector found a Value for the given key
If no custom settings4j.xml exist in classpath, the behavior is like getString(String)
,
but only the ClasspathConnector
can return a byte[] content directly.
The other Connectors calls there getString(...) Method to get a valid Filesystempath or Classpath.
e.g SystemPropertyConnector
:
Start the Application with -Dcom/mycompany/myapp/myParameterKey=file:D:/PathToMyFileContent
Then: getContent("com/mycompany/myapp/myParameterKey")
will return the byte[] Content
of "file:D:/PathToMyFileContent"
.
Valid Path-Prefixes are "file:" and "classpath:".
See ContentResolver
and FSContentResolver
and
ClasspathContentResolver
.
key
- the Key for the configuration-property. e.g.: "com/mycompany/myapp/myParameterKey"public static Object getObject(String key)
Settings4j
Instance iterates all his Connector
and return the first found Value.
Returns null if no connector found a Value for the given key
If no custom settings4j.xml exist in classpath, the behavior is like getString(String)
,
but only the JNDIConnector
can return an Object directly.
The other Connectors calls there getContent(...) Method to get a content which can be transformed to
an Object.
See ObjectResolver
.
key
- the Key for the configuration-property. e.g.: "com/mycompany/myapp/myParameterKey"public static Settings4jRepository getSettingsRepository()
Settings4jRepository
where this Settings-Object is stored.Settings4jRepository
where this Settings-Object is stored.public static List<Connector> getConnectors()
Connector
who can be used with this Settings4j
instance.Settings4j
instanceCopyright © 2008–2014. All rights reserved.