@ApplicationScoped public class Configuration extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CONFIG_FILE_PATH_PROPERTY_NAME
The default name of the system property referencing to the location of the configuration file.
|
| Constructor and Description |
|---|
Configuration()
Instantiates a new configuration object.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
get(Object key)
Delegates to
Hashtable.get(Object). |
Object |
getOrDefault(Object key,
Object defaultValue)
Delegates to
Hashtable.getOrDefault(Object, Object). |
Properties |
getProperties()
Gets the properties.
|
Properties |
getPropertiesWithPrefix(String prefix)
Gets the properties that begin with a specified prefix.
|
String |
getProperty(String propertyName)
Gets the property value with the specified name.
|
String |
getProperty(String propertyName,
String defaultValue)
Gets the property value with the specified name.
|
Object |
put(Object key,
Object value)
Delegates to
Hashtable.put(Object, Object). |
void |
putAll(Map<?,?> map)
Delegates to
Hashtable.putAll(Map). |
Object |
putIfAbsent(Object key,
Object value)
Delegates to
Hashtable.putIfAbsent(Object, Object). |
void |
readProperties()
Reads in the configuration properties.
|
void |
setProperties(Properties properties)
Clears existing configuration properties replaces with the specified properties.
|
void |
setProperty(String propertyName,
String propertyValue)
Sets the specified property to the specified value.
|
public static final String DEFAULT_CONFIG_FILE_PATH_PROPERTY_NAME
public Properties getProperties()
public Properties getPropertiesWithPrefix(String prefix)
prefix - the prefixpublic void setProperties(Properties properties)
properties - the propertiespublic void setProperty(String propertyName, String propertyValue)
propertyName - the property name to be setpropertyValue - the property value to set the property topublic String getProperty(String propertyName)
propertyName - the name of the property to getpublic String getProperty(String propertyName, String defaultValue)
propertyName - the name of the property to getdefaultValue - the value returned if the property does not existpublic Object get(Object key)
Hashtable.get(Object).key - the key whose associated value is to be returnednull if this map contains no mapping for the keyNullPointerException - if the specified key is nullpublic Object getOrDefault(Object key, Object defaultValue)
Hashtable.getOrDefault(Object, Object).key - the key whose associated value is to be returneddefaultValue - the value to be returned if the associated property value is nulldefaultValue if this map contains no mapping for the keypublic Object put(Object key, Object value)
Hashtable.put(Object, Object).key - the hashtable keyvalue - the valuenull if it did not have oneNullPointerException - if the key or value is
nullpublic void putAll(Map<?,?> map)
Hashtable.putAll(Map).map - mappings to be stored in this mapNullPointerException - if the specified map is nullpublic Object putIfAbsent(Object key, Object value)
Hashtable.putIfAbsent(Object, Object).key - the hashtable keyvalue - the valuenull if it did not have oneNullPointerException - if the key or value is
null@PostConstruct public void readProperties()
co.luminositylabs.configFile system property exists, the
value of this property is used as the path to read the configuration
from. If the property does not exist, a path
named co.luminositylabs.config.properties is used.
If the configuration pathname does NOT represent an absolute path, the pathname will be treated as a relative path, and the file will be searched for in a series of relative locations:
If the configuration file is not found, an IOException is thrown.
Copyright © 2017. All rights reserved.