@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()
Registrypublic boolean isEmpty()
Registrypublic Registry getSubset(String key)
Registrypublic List getList(String key)
Registrypublic List<Registry> getSubsetList(String key)
RegistrygetSubsetList in interface Registrykey - the key to take the subsets frompublic Properties getProperties(String key)
RegistrygetProperties in interface Registrykey - the key to lookuppublic void save() throws RegistryException
Registrysave in interface RegistryRegistryException - if there was a problem saving the registrypublic void addChangeListener(RegistryListener listener)
RegistryaddChangeListener in interface Registrylistener - the listenerpublic boolean removeChangeListener(RegistryListener listener)
removeChangeListener in interface Registrytrue if has been removedpublic int getChangeListenersSize()
public Collection<String> getKeys()
Registrypublic Collection getFullKeys()
RegistrygetFullKeys in interface Registrypublic void remove(String key)
Registrypublic void removeSubset(String key)
RegistryremoveSubset in interface Registrykey - the subset to removepublic String getString(String key)
Registrynull is returned.public String getString(String key, String defaultValue)
Registrypublic void setString(String key, String value)
Registrypublic int getInt(String key)
Registrypublic int getInt(String key, int defaultValue)
Registrypublic void setInt(String key, int value)
Registrypublic boolean getBoolean(String key)
RegistrygetBoolean in interface Registrykey - the key in the registrypublic boolean getBoolean(String key, boolean defaultValue)
RegistrygetBoolean in interface Registrykey - the key in the registrydefaultValue - the default valuepublic void setBoolean(String key, boolean value)
RegistrysetBoolean in interface Registrykey - the key in the registryvalue - the value to setpublic void addConfigurationFromResource(String resource) throws RegistryException
RegistryaddConfigurationFromResource in interface Registryresource - 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
RegistryaddConfigurationFromResource in interface Registryresource - 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
RegistryaddConfigurationFromFile in interface Registryfile - 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
RegistryaddConfigurationFromFile in interface Registryfile - 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 RegistryRegistryExceptionpublic void setProperties(String properties)
public Registry getSection(String name)
Registrynull will be
returned.getSection in interface Registryname - registry section namepublic String getPropertyDelimiter()
public void setPropertyDelimiter(String propertyDelimiter)
Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.