|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.sape.carbon.core.config.node.AbstractNode
|
+--org.sape.carbon.core.config.node.AbstractConfigurationDocument
This implementation of ConfigurationDocument uses a
ConfigurationFormatService to read and write
Configurations from and to the backing data store and
caches the results for future use.
This implementation interfaces with the backing data store via sub-classes
implementing the methods openInputStream and
openOutputStream. This implementation caches the
Configuration object upon the first call to readConfiguration.
The cached version is cleared when writeConfiguration is called.
Copyright 2002 Sapient
| Field Summary | |
protected Configuration |
configuration
Cached copy of the Configuration |
private ConfigurationFormatService |
formatter
The ConfigurationFormatService used by this class. |
private org.apache.commons.logging.Log |
log
Provides a handle to Apache-commons logger |
private NodeFactory |
nestedNodeFactory
Document factory for nested configurations. |
| Fields inherited from class org.sape.carbon.core.config.node.AbstractNode |
childNodes, nodeListeners |
| Fields inherited from interface org.sape.carbon.core.config.node.Node |
DELIMITER |
| Constructor Summary | |
AbstractConfigurationDocument(Node parent,
String name,
ConfigurationFormatService formatter)
Constructor for AbstractConfigurationDocument. |
|
AbstractConfigurationDocument(Node parent,
String name,
Object readOrAlterNodeLock,
Object addOrLoadChildLock,
ConfigurationFormatService formatter)
|
|
| Method Summary | |
ConfigurationDocument |
addNestedConfigurationDocument(String name,
Configuration config)
Adds a nested configuration object within this document with the name given by name and the value given by config. |
protected void |
closeInputStream(InputStream in)
Closes the input stream. |
protected void |
closeOutputStream(OutputStream out)
Closes the output stream. |
protected Set |
getAllChildNames()
Retreives the names of all child configurations. |
ConfigurationFormatService |
getFormatService()
Method getFormatService. |
NodeFactory |
getNestedNodeFactory()
Returns the nested node factory for the configuration. |
protected void |
issueNodeModifiedEvent()
Notifies all listenters that this document has been modified. |
protected Node |
loadChild(String nodeName)
Loads the child specified by nodeName from the backing data store. |
protected void |
notifyNestedDocuments()
This method notifies all nested configuration documents that the document has changed and their listeners should be notified. |
protected abstract InputStream |
openInputStream()
This method should be overridden by classes implementing ConfigurationDocuments for specific data stores. |
protected abstract OutputStream |
openOutputStream()
This method should be overridden by classes implementing ConfigurationDocuments for specific data stores. |
Configuration |
readConfiguration()
This implementation uses the ConfigurationFormatService
to read from the backing data store. |
void |
refresh()
Refreshes the Node's underlying cache of data (assuming is has one) |
int |
remove()
Permanently deletes the node and all of its child nodes from the backing store returning the total number of nodes deleted. |
protected void |
writeChildReferences(Configuration config)
Writes out references to child configuration documents inside a config. |
void |
writeConfiguration(Configuration config)
This implementation uses the ConfigurationFormatService
to write to the backing data store. |
| Methods inherited from class org.sape.carbon.core.config.node.AbstractNode |
addNodeListener, addNodeListener, addNodeListener, backingDataExists, containsChild, destroyBackingData, fetchChild, fetchChildren, getAbsoluteName, getAddOrLoadChildLock, getAllowsChildren, getName, getParent, getReadOrAlterNodeLock, isRemoved, issueChildLoadedEvent, issueNodeRemovedEvent, removeRemovedChildren, setRemoved, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.sape.carbon.core.config.node.Node |
addNodeListener, addNodeListener, containsChild, fetchChild, fetchChildren, getAbsoluteName, getAllowsChildren, getName, getParent, isRemoved |
| Field Detail |
private org.apache.commons.logging.Log log
protected Configuration configuration
Configuration
private final ConfigurationFormatService formatter
private final NodeFactory nestedNodeFactory
| Constructor Detail |
public AbstractConfigurationDocument(Node parent,
String name,
Object readOrAlterNodeLock,
Object addOrLoadChildLock,
ConfigurationFormatService formatter)
parent - name - readOrAlterNodeLock -
public AbstractConfigurationDocument(Node parent,
String name,
ConfigurationFormatService formatter)
parent - the node's parentname - the node's nameformatter - the ConfigurationFormatService object used
to read and write Configuration to the backing data store
NullPointerException - if formatter is null| Method Detail |
public Configuration readConfiguration()
throws NodeIOException,
ConfigurationFormatException
ConfigurationFormatService
to read from the backing data store. It calls the abstract method
openInputStream to open an InputStream
to read the Configuration from then closes it before
it exits.
This method is synchronized to prevent multiple readers from loading
the Configuration at once and to make sure that
no one is writing a new Configuration while someone else
is reading.
readConfiguration in interface ConfigurationDocumentConfiguration object within this
ConfigurationDocument
NodeIOException - indicates a generic exception writing the
configuration
ConfigurationFormatException - indicates an error formating
the config documentConfigurationService.fetchConfiguration(String)
public void writeConfiguration(Configuration config)
throws NodeIOException,
ConfigurationFormatException
ConfigurationFormatService
to write to the backing data store. It calls the abstract method
openOutpuStream to open an OutputStream
to write the Configuration to then closes it before
it exits.
This method is synchronized internally to prevent multiple writes from
saving Configurations concurrently and to make sure that
no one is writing a new Configuration while someone else
is reading.
writeConfiguration in interface ConfigurationDocumentconfig - the Configuration to write to the backing
data store
NodeIOException - indicates a generic exception writing the
configuration
ConfigurationFormatException - indicates an error formating
the config documentConfigurationService.storeConfiguration(String, Configuration)
public int remove()
throws NodeRemovalException
Node
remove in interface Noderemove in class AbstractNodeNodeRemovalException - when the node or one of its children
can not be deleted. When this exception is thrown, some nodes may have
been deleted while other may have not.synchronized to ensure no one is fetching or adding children while
this method is removing them
public ConfigurationDocument addNestedConfigurationDocument(String name,
Configuration config)
throws NodeCreationException
ConfigurationDocument
addNestedConfigurationDocument in interface ConfigurationDocumentname - the name of the configuration to add. This should not use
indexed notation. If the property is indexed, config will
be added to the end of the list. Retrieval then needs to
use the indexed notation.config - the config object to add. If this object belongs to
another configuration document, a reference is created
to that document. Otherwise, the config is embedded
within this document.
NodeCreationException - if there is a problem creating the
nested document.AbstractNode#addNestedConfigurationDocumentpublic ConfigurationFormatService getFormatService()
ConfigurationDocument
getFormatService in interface ConfigurationDocumentConfigurationDocument.getFormatService()public void refresh()
Node
refresh in interface Noderefresh in class AbstractNodeNode.refresh()protected void notifyNestedDocuments()
protected abstract InputStream openInputStream()
throws Exception
ConfigurationDocuments for specific data stores.
The returned InputStream should be a stream of data
that can be read by the ConfigurationFormatService and
converted to a Configuration object.
This method is called by readConfiguration.
InputStream from which to read
the Configuration object within this
ConfigurationDocument
Exception - if an exception occurs openning the stream
protected void closeInputStream(InputStream in)
throws Exception
in - the stream to open
Exception - indicates an exception occured closing the stream
protected abstract OutputStream openOutputStream()
throws Exception
ConfigurationDocuments for specific data stores.
The returned OutputStream should be a stream of data
that can be written to by the ConfigurationFormatService.
This method is called by writeConfiguration.
OutputStream to which to write
the Configuration object within this
ConfigurationDocument
Exception - if an exception occurs openning the stream
protected void closeOutputStream(OutputStream out)
throws Exception
out - the stream to close
Exception - indicates an error closing the streamprotected Set getAllChildNames()
getAllChildNames in class AbstractNode
protected Node loadChild(String nodeName)
throws NodeNotFoundException
AbstractNode
loadChild in class AbstractNodenodeName - the name of the node to load
NodeNotFoundException - if the backing data for the specifed
node could not be found in the data store.AbstractNode.loadChild(String)
protected void writeChildReferences(Configuration config)
throws ConfigurationFormatException
config - config to persist out child references
ConfigurationFormatException - indicates an error
writing out the child referencepublic NodeFactory getNestedNodeFactory()
ConfigurationDocument
getNestedNodeFactory in interface ConfigurationDocumentConfigurationDocument.getNestedNodeFactory()protected void issueNodeModifiedEvent()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||