|
|||||||||||
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
Abstract implementation of the Node
interface. This
implementation is designed to be extended with the logic specific to the
backing data store placed in the destroyBackingData
method.
Copyright 2002 Sapient
Field Summary | |
private Object |
addOrLoadChildLock
This lock is used to ensure that nodes are not added or loaded concurrently. |
protected Map |
childNodes
Map of child Nodes keyed by the Node's name (String). |
private org.apache.commons.logging.Log |
log
Provides a handle to Apache-commons logger |
private String |
name
this Node's name |
protected Set |
nodeListeners
Contains the list of node listeners for this node. |
private Node |
parent
link to the Node's parent |
private Object |
readOrAlterNodeLock
This object is syncrhonized upon whenever this node's state is read or altered. |
private boolean |
removed
this node's removed status |
Fields inherited from interface org.sape.carbon.core.config.node.Node |
DELIMITER |
Constructor Summary | |
AbstractNode(Node parent,
String name)
Constructor |
|
AbstractNode(Node parent,
String name,
Object readOrAlterNodeLock,
Object addOrLoadChildLock)
Constructor |
Method Summary | |
void |
addNodeListener(ConfigurationEventListener listener)
Method addNodeListener. |
void |
addNodeListener(EventListener listener)
|
void |
addNodeListener(NodeEventListener listener)
Method addNodeListener. |
protected abstract boolean |
backingDataExists()
Method called from the refresh method to see if the backing data still exists. |
boolean |
containsChild(String childName)
Checks if this Folder contains the child specified
by childName |
protected abstract void |
destroyBackingData()
This method is called by remove to destroy the data
backing this node in the data source. |
Node |
fetchChild(String childName)
synchronized to ensure no one is adding or removing children while childName is being fetched |
Node[] |
fetchChildren()
Returns an array of all children nodes, including standard ConfigurationDocument s and Folder . |
String |
getAbsoluteName()
This implementation is recursive. |
protected Object |
getAddOrLoadChildLock()
Gets the lock object to synchronized upon when creating new children or loading existing children. |
protected abstract Set |
getAllChildNames()
Called by fetchChildren to get the names of all the children from the backing data store. |
boolean |
getAllowsChildren()
Allows determination of whether or not this node supports children |
String |
getName()
Returns the name of this node. |
Node |
getParent()
Gets the parent folder of the node. |
protected Object |
getReadOrAlterNodeLock()
Gets the lock object to synchronize upon when reading or altering the removed flag or the childNodes Map. |
boolean |
isRemoved()
Used to tell whether or not the backing data of a node has been removed. |
protected void |
issueChildLoadedEvent(Node child)
Notifies all listenters that a child of this node has been loaded. |
protected void |
issueNodeRemovedEvent()
Notifies all listenters that this node has been removed. |
protected abstract Node |
loadChild(String nodeName)
Loads the child specified by nodeName from the backing data store. |
void |
refresh()
This implementation refreshes all children and toggles the isRemoved flag depending on the return value of the backingDataExists method. |
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 |
removeRemovedChildren()
Removes all nodes from this.childNodes for which isRemoved returns true. |
protected void |
setRemoved()
Sets the node state to be removed. |
String |
toString()
Returns the name of the node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private org.apache.commons.logging.Log log
private final String name
private final Node parent
private boolean removed
private final Object addOrLoadChildLock
private final Object readOrAlterNodeLock
protected final Map childNodes
protected final Set nodeListeners
Constructor Detail |
public AbstractNode(Node parent, String name)
parent
- the node's parentname
- the node's name
InvalidParameterException
- if name is nullpublic AbstractNode(Node parent, String name, Object readOrAlterNodeLock, Object addOrLoadChildLock)
parent
- the node's parentname
- the node's namereadOrAlterNodeLock
- the lock object that will be synchronized
upon for all operations that access or modify this node's state
InvalidParameterException
- if name is null or readOrAlterNodeLock
is nullMethod Detail |
public String getName()
Node
/
'. The name of the root node is
an empty String
(""
).
getName
in interface Node
Node.getName()
public Node getParent()
Node
getParent
in interface Node
Node.getParent()
public String getAbsoluteName()
getAbsoluteName
in interface Node
Node.getAbsoluteName()
public boolean getAllowsChildren()
Node
getAllowsChildren
in interface Node
true
if the node can support children,
false
otherwiseNode.getAllowsChildren()
public int remove() throws NodeRemovalException
Node
remove
in interface Node
NodeRemovalException
- 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 String toString()
toString
in class Object
public boolean isRemoved()
Node
isRemoved
in interface Node
Node.isRemoved()
public void refresh()
refresh
in interface Node
Node.refresh()
public Node fetchChild(String childName) throws NodeNotFoundException
fetchChild
in interface Node
childName
- The name of the child node to be returned.
NodeNotFoundException
- when
childName
does not exist in the backing data storeNode.fetchChild(String)
public Node[] fetchChildren()
Node
ConfigurationDocument
s and Folder
. If this
particular node does not have any children, an array of length zero
is be returned.
fetchChildren
in interface Node
Node.fetchChildren()
public boolean containsChild(String childName)
Node
Folder
contains the child specified
by childName
containsChild
in interface Node
childName
- the name of the child Node
synchronized to ensure no one is adding or removing children
while childName is being checking to see if childName exists
public void addNodeListener(EventListener listener)
Node.addNodeListener(NodeEventListener)
public void addNodeListener(NodeEventListener listener)
Node
addNodeListener
in interface Node
listener
- lister for the nodeNode.addNodeListener(NodeEventListener)
public void addNodeListener(ConfigurationEventListener listener)
Node
addNodeListener
in interface Node
listener
- lister for the nodeNode.addNodeListener(ConfigurationEventListener)
protected abstract void destroyBackingData() throws NodeRemovalException
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
NodeRemovalException
- indicates an error removing the nodeprotected abstract Set getAllChildNames()
String
s, the names of all the childrenprotected abstract Node loadChild(String nodeName) throws NodeNotFoundException
nodeName
- the name of the node to load
NodeNotFoundException
- if the backing data for the specifed
node could not be found in the data store.protected abstract boolean backingDataExists()
protected void removeRemovedChildren()
protected void setRemoved()
protected void issueChildLoadedEvent(Node child)
protected void issueNodeRemovedEvent()
protected final Object getReadOrAlterNodeLock()
This method is final because the design of the abstract node implementations requires that the return value of this method never change once this object is constructed. The return value can be set in one of the constructors.
AbstractNode(Node, String, Object, Object)
protected final Object getAddOrLoadChildLock()
This method is final because the design of the abstract node implementations requires that the return value of this method never change once this object is constructed. The return value can be set in one of the constructors.
AbstractNode(Node, String, Object, Object)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |