|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.core.config.Config
Config
implements a static singleton pattern to provide
a single point of access for configuration data. Configuration data
in the form of Configuration
objects can be accessed from
an underlying data store, and written to an underlying data store via
Config
. The Config
is the preferred class
for accessing configuration data.
Field Summary | |
private ConfigurationService |
configService
Cached reference to the initial ConfigurationService
in the system. |
private static Config |
INSTANCE
Reference to the one and only instance of this class, following the Item 2 in Josh Bloch's "Effective Java". |
static String |
ROOT_NODE_NAME
The name of the root node for use in the fetchNode method |
Constructor Summary | |
private |
Config()
Private constructor to ensure that others do not instantiate a unique Config object. |
Method Summary | |
void |
addNodeListener(String nodeName,
ConfigurationEventListener listener)
Adds a listener to the specified node. |
void |
addNodeListener(String nodeName,
NodeEventListener listener)
Adds a listener to the specified node. |
Configuration |
createConfiguration(Class configurationType)
This method is the primary interface to create new instances of Configuration Objects. |
Configuration |
fetchConfiguration(String name)
Returns a Configuration object that contains all of the
configuration data in the ConfigurationDocument located by
configurationName . |
Node |
fetchNode(String nodeName)
Traverses the internal node hierachy and returns the named node |
Configuration |
fetchWritableConfiguration(String name)
Returns a Configuration object that contains all of the
configuration data in the ConfigurationDocument located by
configurationName . |
ConfigurationService |
getConfigurationService()
Provides static access to the Configuration Service. |
static Config |
getInstance()
Accessor to the single instance of Config . |
boolean |
nodeExists(String nodeName)
Returns true if the node exists in the configuration repository and false if it does not exist. |
void |
storeConfiguration(String name,
Configuration config)
The storeConfiguration method persists configuration data
contained in config to the underlying
ConfigurationDocument named by
configurationName . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static Config INSTANCE
public static final String ROOT_NODE_NAME
private ConfigurationService configService
ConfigurationService
in the system.
Constructor Detail |
private Config()
Config
object.
Method Detail |
public static Config getInstance()
Config
.
Config
.public Configuration fetchConfiguration(String name)
ConfigurationService
Returns a Configuration
object that contains all of the
configuration data in the ConfigurationDocument
located by
configurationName
.
The returned configuration may be a shared object that is read-only. If it is, the configuration's writable flag is set to false and exceptions will be thrown if an attempt is made to modify the object.
fetchConfiguration
in interface ConfigurationService
name
- The name of the requested configuration
ConfigurationService.fetchConfiguration(java.lang.String)
public Configuration fetchWritableConfiguration(String name)
ConfigurationService
Returns a Configuration
object that contains all of the
configuration data in the ConfigurationDocument
located by
configurationName
.
The returned configuration is a mutable object and not thread-safe. All access to this object should be in a single threaded or synchronized context. To commit the changes that have been made to this object use the storeConfiguration method.
fetchWritableConfiguration
in interface ConfigurationService
name
- The name of the requested configuration
ConfigurationService.fetchWritableConfiguration(java.lang.String)
public void storeConfiguration(String name, Configuration config) throws ConfigurationStoreException
ConfigurationService
The storeConfiguration
method persists configuration data
contained in config
to the underlying
ConfigurationDocument
named by
configurationName
. If the
ConfigurationDocument
does not exist, it is created
along with all of its parent Node
s.
storeConfiguration
in interface ConfigurationService
name
- The name of the Configuration Document
where the configuration data should be stored.config
- Configuration data to be persisted to the underlying
data store.
ConfigurationStoreException
- data can not be written to the
backing store.ConfigurationService.storeConfiguration(java.lang.String, org.sape.carbon.core.config.Configuration)
public Configuration createConfiguration(Class configurationType)
ConfigurationService
This method is the primary interface to create new instances of
Configuration
Objects. This method is capable of creating an empty configuration object
for an interface that extends the
Configuration
interface.
createConfiguration
in interface ConfigurationService
configurationType
- The Class of the configuration type to be
created
ConfigurationService.createConfiguration(java.lang.Class)
public Node fetchNode(String nodeName) throws NodeNotFoundException
ConfigurationService
fetchNode
in interface ConfigurationService
nodeName
- the '/' delimeted path to the node
NodeNotFoundException
- when the cannot be found.ConfigurationService.fetchNode(java.lang.String)
public boolean nodeExists(String nodeName)
ConfigurationService
nodeExists
in interface ConfigurationService
nodeName
- the '/' delimeted path to the node
ConfigurationService.nodeExists(java.lang.String)
public void addNodeListener(String nodeName, NodeEventListener listener) throws NodeNotFoundException
ConfigurationService
addNodeListener
in interface ConfigurationService
nodeName
- the '/' delimeted path to the nodelistener
- the object that will be notified of NodeEvents
NodeNotFoundException
- if nodeName does not existConfigurationService.addNodeListener(String, NodeEventListener)
public void addNodeListener(String nodeName, ConfigurationEventListener listener) throws NodeNotFoundException
ConfigurationService
addNodeListener
in interface ConfigurationService
nodeName
- the '/' delimeted path to the nodelistener
- the object that will be notified of NodeEvents
NodeNotFoundException
- if nodeName does not existConfigurationService.addNodeListener(String, ConfigurationEventListener)
public ConfigurationService getConfigurationService()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |