public class

CommonsConfigurationRegistry

extends Object
implements Registry
java.lang.Object
   ↳ org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry

Class Overview

Implementation of the registry component using Commons Configuration. The use of Commons Configuration enables a variety of sources to be used, including XML files, properties, JNDI, JDBC, etc.

The component can be configured using the #properties configuration item, the content of which should take the format of an input to the Commons Configuration configuration builder.

Summary

Public Constructors
CommonsConfigurationRegistry()
CommonsConfigurationRegistry(Configuration configuration)
Public Methods
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, boolean defaultValue)
Get a boolean value from the registry.
boolean getBoolean(String key)
Get a boolean value from the registry.
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 ? Get the properties at the given key in the registry.
String getPropertyDelimiter()
Registry getSection(String name)
Get a subsection of the registry, identified by the given name.
String getString(String key, String defaultValue)
Get a string value from the registry.
String getString(String key)
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 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.
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.archiva.redback.components.registry.Registry

Public Constructors

public CommonsConfigurationRegistry ()

public CommonsConfigurationRegistry (Configuration configuration)

Public Methods

public void addChangeListener (RegistryListener listener)

Add a change listener. Note that settings this on the base registry will only detect 'invalidation' events, not individual changes. You should retrieve the named sub-registry to listen for changes.

Parameters
listener the listener

public void addConfigurationFromFile (File file)

Load configuration from the given file.

Parameters
file the location to load the configuration from

public void addConfigurationFromFile (File file, String prefix)

Load configuration from the given file.

Parameters
file the location to load the configuration from
prefix the location to add the configuration at in the registry

public void addConfigurationFromResource (String resource)

Load configuration from the given classloader resource.

Parameters
resource the location to load the configuration from

public void addConfigurationFromResource (String resource, String prefix)

Load configuration from the given classloader resource.

Parameters
resource the location to load the configuration from
prefix the location to add the configuration at in the registry

public String dump ()

Dump the entire registry to a string, for debugging purposes.

Returns
  • the registry contents

public boolean getBoolean (String key, boolean defaultValue)

Get a boolean value from the registry. If not found, the default value is used.

Parameters
key the key in the registry
defaultValue the default value
Returns
  • the value

public boolean getBoolean (String key)

Get a boolean value from the registry. If not found, an exception is thrown.

Parameters
key the key in the registry
Returns
  • the value

public Collection getFullKeys ()

Get all the keys in this registry.

Returns
  • the set of keys

public int getInt (String key)

Get an integer value from the registry. If not found, an exception is thrown.

Parameters
key the key in the registry
Returns
  • the value

public int getInt (String key, int defaultValue)

Get an integer value from the registry. If not found, the default value is used.

Parameters
key the key in the registry
defaultValue the default value
Returns
  • the value

public Collection<String> getKeys ()

Get all the keys in this registry. Keys are only retrieved at a depth of 1.

Returns
  • the set of keys

public List getList (String key)

Get a list of strings at the given key in the registry.

Parameters
key the key to lookup
Returns
  • the list of strings

public Properties getProperties (String key)

TODO move to Map which is more generic ? Get the properties at the given key in the registry.

Parameters
key the key to lookup
Returns
  • the properties

public String getPropertyDelimiter ()

public Registry getSection (String name)

Get a subsection of the registry, identified by the given name. If it doesn't exist, null will be returned.

Parameters
name registry section name
Returns
  • the registry

public String getString (String key, String defaultValue)

Get a string value from the registry. If not found, the default value is used.

Parameters
key the key in the registry
defaultValue the default value
Returns
  • the value

public String getString (String key)

Get a string value from the registry. If not found, null is returned.

Parameters
key the key in the registry
Returns
  • the value

public Registry getSubset (String key)

Get a subset of the registry, for all keys descended from the given key.

Parameters
key the key to take the subset from
Returns
  • the registry subset

public List getSubsetList (String key)

Get a list of subsets of the registry, for all keys descended from the given key.

Parameters
key the key to take the subsets from
Returns
  • the registry subsets

public void initialize ()

public boolean isEmpty ()

Determine if the registry contains any elements.

Returns
  • whether the registry contains any elements

public void remove (String key)

Remove a keyed element from the registry.

Parameters
key the key to remove

public void removeSubset (String key)

Remove a keyed subset of the registry.

Parameters
key the subset to remove

public void save ()

Save any changes to the registry since it was loaded.

public void setBoolean (String key, boolean value)

Set a boolean value in the registry.

Parameters
key the key in the registry
value the value to set

public void setInt (String key, int value)

Set an integer value in the registry.

Parameters
key the key in the registry
value the value to set

public void setProperties (String properties)

public void setPropertyDelimiter (String propertyDelimiter)

public void setString (String key, String value)

Set a string value in the registry.

Parameters
key the key in the registry
value the value to set