|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.core.config.DefaultRootConfigurationService
Implementation of RootConfigurationService
that traverses
the node tree to fetch and store configuration data.
Copyright 2001 Sapient
Field Summary | |
private ConfigurationCache |
cache
Cache storing previously accessed configuration objects. |
private org.apache.commons.logging.Log |
log
Provides a handle to Apache-commons logger |
private Node |
rootNode
Handle to the root node used by this ConfigurationService . |
Constructor Summary | |
protected |
DefaultRootConfigurationService(ConfigurationDocument configurationDocument)
protected constructor prevents direct instantiation by classes other than the DefaultConfigurationServiceFactory but does not
prevent extension. |
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 configurationName)
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 configurationName)
Returns a Configuration object that contains all of the
configuration data in the ConfigurationDocument located by
configurationName . |
private String |
getRemainingTokens(StringTokenizer tokenizer)
Assembles the remaining tokens into a string, used for error messages. |
private void |
initialize(ConfigurationDocument rootConfigurationDoc)
Reads a LinkNodeConfiguration from the rootConfigurationDoc and uses the configured LinkNodeFactoryClass to create a new Node that is then set as the root node for the ConfigurationService. |
boolean |
nodeExists(String nodeName)
Returns true if the node exists in the configuration repository and false if it does not exist. |
private Node |
recursiveNodeTraversal(Node node,
StringTokenizer tokenizer)
Returns the Node found by recursively fetching the
next node name from tokenizer
and scaling the node tree. |
private void |
recursiveStoreConfiguration(Node node,
Configuration config,
StringTokenizer tokenizer)
Traverses down the node adding the sub-nodes. |
private boolean |
recursiveTraverseNodeTreeForNodeExists(Node node,
StringTokenizer tokenizer)
Returns true if a node is found by recursively tokenizing the configurationName by '/ ' characters
and scaling the node tree. |
void |
storeConfiguration(String configurationName,
Configuration config)
The storeConfiguration method persists configuration data
contained in config to the underlying
ConfigurationDocument named by
configurationName . |
private Node |
traverseNodeTree(String configurationName)
Returns the Node found by recursively tokenizing the
configurationName by '/ ' characters
and scaling the node tree. |
private boolean |
traverseNodeTreeForNodeExists(String configurationName)
Returns true if a node is found by recursively tokenizing the configurationName by '/ ' characters
and scaling the node tree. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private org.apache.commons.logging.Log log
private Node rootNode
ConfigurationService
.
private ConfigurationCache cache
Constructor Detail |
protected DefaultRootConfigurationService(ConfigurationDocument configurationDocument)
DefaultConfigurationServiceFactory
but does not
prevent extension.
configurationDocument
- the configuration document being
loadedMethod Detail |
public Configuration fetchConfiguration(String configurationName)
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
configurationName
- The name of the requested configuration
ConfigurationService.fetchConfiguration(java.lang.String)
public Configuration fetchWritableConfiguration(String configurationName)
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
configurationName
- The name of the requested configuration
ConfigurationService.fetchWritableConfiguration(java.lang.String)
public void storeConfiguration(String configurationName, 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
configurationName
- 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 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 boolean nodeExists(String nodeName)
ConfigurationService
nodeExists
in interface ConfigurationService
nodeName
- the '/' delimeted path to the node
ConfigurationService.nodeExists(java.lang.String)
private void initialize(ConfigurationDocument rootConfigurationDoc)
rootConfigurationDoc
- Contains data required to initialize this
instance of ConfigurationService
and its root node.LinkNode
,
LinkNodeConfiguration
private Node traverseNodeTree(String configurationName) throws NodeNotFoundException
Node
found by recursively tokenizing the
configurationName
by '/
' characters
and scaling the node tree.
configurationName
- The full logical name of the configuration
to be fetched, such as /nodeA/nodeB/configuration1
.
NodeNotFoundException
- when a node can not be fetched.private Node recursiveNodeTraversal(Node node, StringTokenizer tokenizer) throws NodeNotFoundException
Node
found by recursively fetching the
next node name from tokenizer
and scaling the node tree.
node
- the current parent node in the node traversal.tokenizer
- The StringTokenizer used to access the next
node to be traversed.
tokenizer
.
NodeNotFoundException
- when a node can not be fetched.private boolean traverseNodeTreeForNodeExists(String configurationName)
configurationName
by '/
' characters
and scaling the node tree.
configurationName
- The full logical name of the configuration
to be fetched, such as /nodeA/nodeB/configuration1
.
private boolean recursiveTraverseNodeTreeForNodeExists(Node node, StringTokenizer tokenizer)
configurationName
by '/
' characters
and scaling the node tree.
node
- the current parent node in the node traversal.tokenizer
- The StringTokenizer used to access the next
node to be traversed.
private void recursiveStoreConfiguration(Node node, Configuration config, StringTokenizer tokenizer) throws NodeCreationException, NodeIOException, ConfigurationFormatException
node
- the node to add the children toconfig
- configuration to storetokenizer
- tokenizer of the full node name
NodeCreationException
- indicates an error creating the node
NodeIOException
- indicates an error reading the node
ConfigurationFormatException
- indicates an error in format
of the configurationprivate String getRemainingTokens(StringTokenizer tokenizer)
tokenizer
- the tokenizer to pull tokens from
Node.DELIMITER
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |