@Service(value="commons-configuration") public class CommonsConfigurationRegistry extends Object implements Registry
properties
configuration item, the content of which should take
the format of an input to the Commons Configuration
configuration
builder.Constructor and Description |
---|
CommonsConfigurationRegistry() |
CommonsConfigurationRegistry(org.apache.commons.configuration.Configuration configuration) |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(RegistryListener listener)
Add a change listener.
|
void |
addConfigurationFromFile(File file)
Load configuration from the given file.
|
void |
addConfigurationFromFile(File file,
String prefix)
Load configuration from the given file.
|
void |
addConfigurationFromResource(String resource)
Load configuration from the given classloader resource.
|
void |
addConfigurationFromResource(String resource,
String prefix)
Load configuration from the given classloader resource.
|
String |
dump()
Dump the entire registry to a string, for debugging purposes.
|
boolean |
getBoolean(String key)
Get a boolean value from the registry.
|
boolean |
getBoolean(String key,
boolean defaultValue)
Get a boolean value from the registry.
|
int |
getChangeListenersSize() |
Collection |
getFullKeys()
Get all the keys in this registry.
|
int |
getInt(String key)
Get an integer value from the registry.
|
int |
getInt(String key,
int defaultValue)
Get an integer value from the registry.
|
Collection<String> |
getKeys()
Get all the keys in this registry.
|
List |
getList(String key)
Get a list of strings at the given key in the registry.
|
Properties |
getProperties(String key)
TODO move to Map which is more generic ?
|
String |
getPropertyDelimiter() |
Registry |
getSection(String name)
Get a subsection of the registry, identified by the given name.
|
String |
getString(String key)
Get a string value from the registry.
|
String |
getString(String key,
String defaultValue)
Get a string value from the registry.
|
Registry |
getSubset(String key)
Get a subset of the registry, for all keys descended from the given key.
|
List<Registry> |
getSubsetList(String key)
Get a list of subsets of the registry, for all keys descended from the given key.
|
void |
initialize() |
boolean |
isEmpty()
Determine if the registry contains any elements.
|
void |
remove(String key)
Remove a keyed element from the registry.
|
boolean |
removeChangeListener(RegistryListener listener) |
void |
removeSubset(String key)
Remove a keyed subset of the registry.
|
void |
save()
Save any changes to the registry since it was loaded.
|
void |
setBoolean(String key,
boolean value)
Set a boolean value in the registry.
|
void |
setInt(String key,
int value)
Set an integer value in the registry.
|
void |
setProperties(String properties) |
void |
setPropertyDelimiter(String propertyDelimiter) |
void |
setString(String key,
String value)
Set a string value in the registry.
|
public CommonsConfigurationRegistry()
public CommonsConfigurationRegistry(org.apache.commons.configuration.Configuration configuration)
public String dump()
Registry
public boolean isEmpty()
Registry
public Registry getSubset(String key)
Registry
public List getList(String key)
Registry
public List<Registry> getSubsetList(String key)
Registry
getSubsetList
in interface Registry
key
- the key to take the subsets frompublic Properties getProperties(String key)
Registry
getProperties
in interface Registry
key
- the key to lookuppublic void save() throws RegistryException
Registry
save
in interface Registry
RegistryException
- if there was a problem saving the registrypublic void addChangeListener(RegistryListener listener)
Registry
addChangeListener
in interface Registry
listener
- the listenerpublic boolean removeChangeListener(RegistryListener listener)
removeChangeListener
in interface Registry
true
if has been removedpublic int getChangeListenersSize()
public Collection<String> getKeys()
Registry
public Collection getFullKeys()
Registry
getFullKeys
in interface Registry
public void remove(String key)
Registry
public void removeSubset(String key)
Registry
removeSubset
in interface Registry
key
- the subset to removepublic String getString(String key)
Registry
null
is returned.public String getString(String key, String defaultValue)
Registry
public void setString(String key, String value)
Registry
public int getInt(String key)
Registry
public int getInt(String key, int defaultValue)
Registry
public void setInt(String key, int value)
Registry
public boolean getBoolean(String key)
Registry
getBoolean
in interface Registry
key
- the key in the registrypublic boolean getBoolean(String key, boolean defaultValue)
Registry
getBoolean
in interface Registry
key
- the key in the registrydefaultValue
- the default valuepublic void setBoolean(String key, boolean value)
Registry
setBoolean
in interface Registry
key
- the key in the registryvalue
- the value to setpublic void addConfigurationFromResource(String resource) throws RegistryException
Registry
addConfigurationFromResource
in interface Registry
resource
- the location to load the configuration fromRegistryException
- if a problem occurred reading the resource to add to the registrypublic void addConfigurationFromResource(String resource, String prefix) throws RegistryException
Registry
addConfigurationFromResource
in interface Registry
resource
- the location to load the configuration fromprefix
- the location to add the configuration at in the registryRegistryException
- if a problem occurred reading the resource to add to the registrypublic void addConfigurationFromFile(File file) throws RegistryException
Registry
addConfigurationFromFile
in interface Registry
file
- the location to load the configuration fromRegistryException
- if a problem occurred reading the resource to add to the registrypublic void addConfigurationFromFile(File file, String prefix) throws RegistryException
Registry
addConfigurationFromFile
in interface Registry
file
- the location to load the configuration fromprefix
- the location to add the configuration at in the registryRegistryException
- if a problem occurred reading the resource to add to the registry@PostConstruct public void initialize() throws RegistryException
initialize
in interface Registry
RegistryException
public void setProperties(String properties)
public Registry getSection(String name)
Registry
null
will be
returned.getSection
in interface Registry
name
- registry section namepublic String getPropertyDelimiter()
public void setPropertyDelimiter(String propertyDelimiter)
Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.