org.sape.carbon.core.config.node
Class NestedConfigurationDocument

java.lang.Object
  |
  +--org.sape.carbon.core.config.node.AbstractNode
        |
        +--org.sape.carbon.core.config.node.AbstractConfigurationDocument
              |
              +--org.sape.carbon.core.config.node.NestedConfigurationDocument
All Implemented Interfaces:
ConfigurationDocument, Node

public class NestedConfigurationDocument
extends AbstractConfigurationDocument

ConfigurationDocument implementation for configurations nested within other ConfigurationDocuments. Parents of this Node can only be AbsractConfigurationDocuments. Copyright 2002 Sapient

Since:
carbon 1.1
Version:
$Revision: 1.12 $($Author: dvoet $ / $Date: 2003/12/11 18:43:31 $)
Author:
Douglas Voet, Sep 11, 2002

Field Summary
 
Fields inherited from class org.sape.carbon.core.config.node.AbstractConfigurationDocument
configuration
 
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
protected NestedConfigurationDocument(AbstractConfigurationDocument parent, String name)
          This should only be called by NestedConfigurationDocumentFactory
 
Method Summary
protected  boolean backingDataExists()
          Method called from the refresh method to see if the backing data still exists.
protected  void destroyBackingData()
          This method is called by remove to destroy the data backing this node in the data source.
private  Configuration getConfiguration()
          Helper method to get the configuration for this node.
 boolean isRemoved()
          Used to tell whether or not the backing data of a node has been removed.
 void onChange()
          Called by parent documents when the have changed in order for this node to notify its listeners that a change has occured
protected  InputStream openInputStream()
          This should never be called.
protected  OutputStream openOutputStream()
          This should never be called.
 Configuration readConfiguration()
          This implementation uses the ConfigurationFormatService to read from the backing data store.
 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.AbstractConfigurationDocument
addNestedConfigurationDocument, closeInputStream, closeOutputStream, getAllChildNames, getFormatService, getNestedNodeFactory, issueNodeModifiedEvent, loadChild, notifyNestedDocuments, refresh, remove, writeChildReferences
 
Methods inherited from class org.sape.carbon.core.config.node.AbstractNode
addNodeListener, addNodeListener, addNodeListener, containsChild, fetchChild, fetchChildren, getAbsoluteName, getAddOrLoadChildLock, getAllowsChildren, getName, getParent, getReadOrAlterNodeLock, 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
 

Constructor Detail

NestedConfigurationDocument

protected NestedConfigurationDocument(AbstractConfigurationDocument parent,
                                      String name)
This should only be called by NestedConfigurationDocumentFactory

Parameters:
parent -
name -
Method Detail

readConfiguration

public Configuration readConfiguration()
                                throws NodeIOException,
                                       ConfigurationFormatException
Description copied from class: AbstractConfigurationDocument
This implementation uses the 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.

Specified by:
readConfiguration in interface ConfigurationDocument
Overrides:
readConfiguration in class AbstractConfigurationDocument
Returns:
the Configuration object within this ConfigurationDocument
Throws:
NodeIOException - indicates a generic exception writing the configuration
ConfigurationFormatException - indicates an error formating the config document
See Also:
ConfigurationDocument.readConfiguration()

writeConfiguration

public void writeConfiguration(Configuration config)
                        throws NodeIOException,
                               ConfigurationFormatException
Description copied from class: AbstractConfigurationDocument
This implementation uses the 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.

Specified by:
writeConfiguration in interface ConfigurationDocument
Overrides:
writeConfiguration in class AbstractConfigurationDocument
Parameters:
config - the Configuration to write to the backing data store
Throws:
NodeIOException - indicates a generic exception writing the configuration
ConfigurationFormatException - indicates an error formating the config document
See Also:
ConfigurationDocument.writeConfiguration(Configuration)

onChange

public void onChange()
Called by parent documents when the have changed in order for this node to notify its listeners that a change has occured


openInputStream

protected InputStream openInputStream()
                               throws IOException
This should never be called. If it is, this class was not written correctly. All reads should be done via parent's document

Specified by:
openInputStream in class AbstractConfigurationDocument
Returns:
never returns
Throws:
IOException - never thrown
UnsupportedOperationException - always thrown to indicate this method is not supported.

openOutputStream

protected OutputStream openOutputStream()
                                 throws IOException
This should never be called. If it is, this class was not written correctly. All writes should be done via parent's document

Specified by:
openOutputStream in class AbstractConfigurationDocument
Returns:
never returns
Throws:
IOException - never thrown
UnsupportedOperationException - always thrown to indicate this method is not supported.

destroyBackingData

protected void destroyBackingData()
                           throws NodeRemovalException
Description copied from class: AbstractNode
This method is called by remove to destroy the data backing this node in the data source. Implementations of this method should remove all traces of the Node's existence

Specified by:
destroyBackingData in class AbstractNode
Throws:
NodeRemovalException - indicates an error removing the node
See Also:
AbstractNode.destroyBackingData()

backingDataExists

protected boolean backingDataExists()
Description copied from class: AbstractNode
Method called from the refresh method to see if the backing data still exists. If it exists, the isRemoved flag is set to false, if it does not, the isRemoved flag is set to true.

Specified by:
backingDataExists in class AbstractNode
Returns:
boolean true if the backing date exists, false otherwise
See Also:
AbstractNode.backingDataExists()

isRemoved

public boolean isRemoved()
Description copied from interface: Node
Used to tell whether or not the backing data of a node has been removed.

Specified by:
isRemoved in interface Node
Overrides:
isRemoved in class AbstractNode
Returns:
true if the backing data of a node has been removed
See Also:
Node.isRemoved()

getConfiguration

private Configuration getConfiguration()
                                throws NodeIOException,
                                       ConfigurationFormatException
Helper method to get the configuration for this node.

Returns:
the configuration document
Throws:
NodeIOException - indicates an error reading the node
ConfigurationFormatException - indicates an error with the configuration document


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.