public class PropertyFileConnector extends AbstractPropertyConnector
Properties
-File implementation of an Connector
.
Example usage read property File from Classpath with ClasspathConnector
(<param name="propertyFromContent"
... />):
<settings4j:configuration xmlns:settings4j='http://settings4j.org/'> <connector name="PropertyFileConnector" class="org.settings4j.connector.PropertyFileConnector"> <param name="propertyFromContent" value="${connectors.content['org/settings4j/config/propertyFile.properties']}" /> <connector-ref ref="ClasspathConnector" /> </connector> <connector name="ClasspathConnector" class="org.settings4j.connector.ClasspathConnector" /> </settings4j:configuration>You can also use other connectors which have a nativ implementation for
Connector.getContent(String)
(doesn't use contentResolver). FSConnector
for FileSystem paths.
Example usage read property File from Classpath with ClasspathConnector
:
If you don't like ExpressionLanguage, then you can set the path to your PropertyFile directly. But in this case a
prefix "file:" or "classpath" is required. And only "file:" and "classpath" are supported.
Example usage read property File from Classpath with classpathString (<param name="propertyFromPath" ... />):
<settings4j:configuration xmlns:settings4j='http://settings4j.org/'> <connector name="PropertyFileConnector" class="org.settings4j.connector.PropertyFileConnector"> <param name="propertyFromPath" value="classpath:org/settings4j/config/propertyFile.properties" /> </connector> </settings4j:configuration>
Constructor and Description |
---|
PropertyFileConnector() |
Modifier and Type | Method and Description |
---|---|
protected String |
getProperty(String key,
String def)
Very similar to
System.getProperty except that the SecurityException is hidden. |
void |
setProperty(Properties property) |
void |
setPropertyFromContent(byte[] content) |
void |
setPropertyFromPath(String propertyPath) |
getContent, getObject, getString
addConnector, getConnectors, getContentResolver, getName, getObjectResolver, init, setContentResolver, setName, setObjectResolver
protected String getProperty(String key, String def)
System.getProperty
except that the SecurityException
is hidden.getProperty
in class AbstractPropertyConnector
key
- The key to search for.def
- The default value to return.public void setProperty(Properties property)
public void setPropertyFromContent(byte[] content)
content
- The byte[] Content of a Property-File.public void setPropertyFromPath(String propertyPath)
propertyPath
- The filepath to a Property-File. Supported prefixes: "file:" and "classpath:".Copyright © 2008–2014. All rights reserved.