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

java.lang.Object
  |
  +--org.sape.carbon.core.config.node.AbstractNode
        |
        +--org.sape.carbon.core.config.node.AbstractFolder
All Implemented Interfaces:
Folder, Node
Direct Known Subclasses:
ClassloaderFolder, FileFolder, JarFolder, JNDIFolder

public abstract class AbstractFolder
extends AbstractNode
implements Folder

This implementation of the Folder interface caches its children as they are requested. This implementation interfaces with the backing data store through sub-classes implementing the methods loadChild and getAllChildNames. Copyright 2002 Sapient

Since:
carbon 1.0
Version:
$Revision: 1.33 $($Author: dvoet $ / $Date: 2003/12/11 18:43:31 $)
Author:
Douglas Voet, February 2002

Field Summary
private  NodeFactory configurationDocumentFactory
          factory used to construct all ConfigurationDocuments within this folder.
private  NodeFactory linkNodeFactory
          factory used to construct all LinkNodes within this folder.
private  NodeFactory subFolderFactory
          Factory used to construct all Folders within this folder.
 
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
AbstractFolder(Node parent, String name, NodeFactory subFolderFactory, NodeFactory configurationDocumentFactory, NodeFactory linkNodeFactory)
          Constructor for AbstractFolder.
AbstractFolder(Node parent, String name, Object readOrAlterNodeLock, Object addOrLoadChildLock, NodeFactory subFolderFactory, NodeFactory configurationDocumentFactory, NodeFactory linkNodeFactory)
          Constructor for AbstractFolder.
 
Method Summary
 ConfigurationDocument addConfigurationDocument(String name, Configuration config)
          Creates a new child ConfigurationDocument and returns a reference to the newly created ConfigurationDocument.
 LinkNode addLink(String name, LinkNodeConfiguration linkConfiguration)
          Adds a link to the folder.
 Folder addSubFolder(String name)
          Creates a new child Folder and returns a reference to the newly created Folder.
protected  ConfigurationDocument createNewConfigurationDocument(String name, Configuration config)
          Uses the configurationDocumentFactory to create a child ConfigurationDocument and adds it to childNodes.
protected  Folder createNewFolder(String name)
          Uses the subFolderFactory to create a child Folder and adds it to childNodes
 NodeFactory getConfigurationDocumentFactory()
          Gets the factory this node used in the addConfigurationDocument method to create children.
 NodeFactory getLinkNodeFactory()
          Gets the factory this node used in the addLinkNode method to create children.
 NodeFactory getSubFolderFactory()
          Gets the factory this node used in the addSubFolder method to create children.
protected  void issueChildAddedEvent(Node child)
          Notifies all listenters that a child has been added to this Folder.
 
Methods inherited from class org.sape.carbon.core.config.node.AbstractNode
addNodeListener, addNodeListener, addNodeListener, backingDataExists, containsChild, destroyBackingData, fetchChild, fetchChildren, getAbsoluteName, getAddOrLoadChildLock, getAllChildNames, getAllowsChildren, getName, getParent, getReadOrAlterNodeLock, isRemoved, issueChildLoadedEvent, issueNodeRemovedEvent, loadChild, refresh, remove, 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, refresh, remove
 

Field Detail

subFolderFactory

private final NodeFactory subFolderFactory
Factory used to construct all Folders within this folder. Final because the reference to the factory should never change.


configurationDocumentFactory

private final NodeFactory configurationDocumentFactory
factory used to construct all ConfigurationDocuments within this folder. Final because the reference to the factory should never change.


linkNodeFactory

private final NodeFactory linkNodeFactory
factory used to construct all LinkNodes within this folder. Final because the reference to the factory should never change.

Constructor Detail

AbstractFolder

public AbstractFolder(Node parent,
                      String name,
                      Object readOrAlterNodeLock,
                      Object addOrLoadChildLock,
                      NodeFactory subFolderFactory,
                      NodeFactory configurationDocumentFactory,
                      NodeFactory linkNodeFactory)
Constructor for AbstractFolder.

Parameters:
parent - the node's parent
name - the node's name
subFolderFactory - factory to use for sub folders
configurationDocumentFactory - factory to use for creating configuration documents
linkNodeFactory - factory to use for creating link nodes.
Throws:
InvalidParameterException - if name, subFolderFactory, or configurationDocumentFactory is null

AbstractFolder

public AbstractFolder(Node parent,
                      String name,
                      NodeFactory subFolderFactory,
                      NodeFactory configurationDocumentFactory,
                      NodeFactory linkNodeFactory)
Constructor for AbstractFolder.

Parameters:
parent - the node's parent
name - the node's name
subFolderFactory - factory to use for sub folders
configurationDocumentFactory - factory to use for creating configuration documents
linkNodeFactory - factory to use for creating link nodes.
Throws:
InvalidParameterException - if name, subFolderFactory, or configurationDocumentFactory is null
Method Detail

addConfigurationDocument

public ConfigurationDocument addConfigurationDocument(String name,
                                                      Configuration config)
                                               throws NodeCreationException
Description copied from interface: Folder
Creates a new child ConfigurationDocument and returns a reference to the newly created ConfigurationDocument.

Specified by:
addConfigurationDocument in interface Folder
Parameters:
name - Name of the ConfigurationDocument to be created.
config - the document to add to the Folder
Returns:
The newly created ConfigurationDocument.
Throws:
NodeCreationException - when the node can not be created, possibly because the node element already exists in this node, or creation of the node is otherwise forbidden. An exception should also be thrown when this node's getAllowsChildren method returns false.
See Also:
synchronized to ensure no one is fetching or removing children while this method is removing them

addSubFolder

public Folder addSubFolder(String name)
                    throws NodeCreationException
Description copied from interface: Folder
Creates a new child Folder and returns a reference to the newly created Folder.

Specified by:
addSubFolder in interface Folder
Parameters:
name - Name of the Folder to be created.
Returns:
The newly created Folder.
Throws:
NodeCreationException - when the node can not be created, possibly because the node element already exists in this node, or creation of the node is otherwise forbidden. An exception should also be thrown when this node's getAllowsChildren method returns false.
See Also:
synchronized to ensure no one is fetching or removing children while this method is removing them

addLink

public LinkNode addLink(String name,
                        LinkNodeConfiguration linkConfiguration)
                 throws NodeCreationException
Description copied from interface: Folder
Adds a link to the folder.

Specified by:
addLink in interface Folder
Parameters:
name - name of the link to add
linkConfiguration - the link configuration to create
Returns:
newly created LinkNode
Throws:
NodeCreationException - indicates an error adding the link
See Also:
Folder.addLink(java.lang.String, org.sape.carbon.core.config.node.link.LinkNodeConfiguration)

getConfigurationDocumentFactory

public NodeFactory getConfigurationDocumentFactory()
Description copied from interface: Folder
Gets the factory this node used in the addConfigurationDocument method to create children. This can be used by sub Folders to create their own children.

Specified by:
getConfigurationDocumentFactory in interface Folder
Returns:
NodeFactory factory object used to create ConfigurationDocuments
See Also:
Folder.getConfigurationDocumentFactory()

getSubFolderFactory

public NodeFactory getSubFolderFactory()
Description copied from interface: Folder
Gets the factory this node used in the addSubFolder method to create children. This can be used by sub Folders to create their own children.

Specified by:
getSubFolderFactory in interface Folder
Returns:
NodeFactory factory object used to create Folders
See Also:
Folder.getSubFolderFactory()

createNewFolder

protected Folder createNewFolder(String name)
                          throws NodeCreationException
Uses the subFolderFactory to create a child Folder and adds it to childNodes

Parameters:
name - name of the Folder
Returns:
Folder the new child
Throws:
NodeCreationException - if the child could not be created for any reason

createNewConfigurationDocument

protected ConfigurationDocument createNewConfigurationDocument(String name,
                                                               Configuration config)
                                                        throws NodeCreationException
Uses the configurationDocumentFactory to create a child ConfigurationDocument and adds it to childNodes.

Parameters:
name - name of the ConfigurationDocument
config - the new config to write
Returns:
ConfigurationDocument the new child
Throws:
NodeCreationException - if the child could not be created for any reason

getLinkNodeFactory

public NodeFactory getLinkNodeFactory()
Description copied from interface: Folder
Gets the factory this node used in the addLinkNode method to create children. This can be used by sub Folders to create their own children.

Specified by:
getLinkNodeFactory in interface Folder
Returns:
NodeFactory factory object used to create ConfigurationDocuments
See Also:
Folder.getSubFolderFactory()

issueChildAddedEvent

protected void issueChildAddedEvent(Node child)
Notifies all listenters that a child has been added to this Folder. Note that this should be not be called from a synchronized context.

Since:
carbon 2.2


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.