org.sape.carbon.services.config.jndi
Class JNDIFolder

java.lang.Object
  |
  +--org.sape.carbon.core.config.node.AbstractNode
        |
        +--org.sape.carbon.core.config.node.AbstractFolder
              |
              +--org.sape.carbon.services.config.jndi.JNDIFolder
All Implemented Interfaces:
EventListener, Folder, NamespaceChangeListener, NamingListener, Node, ObjectChangeListener

public class JNDIFolder
extends AbstractFolder
implements NamespaceChangeListener, ObjectChangeListener

A node that represents a JNDI context that contains other folders or documents. This implementation implements NamespaceChangeListener and ObjectChangeListener from the javax.naming.event package in order to listen for changes in the backing datastore. Copyright 2003 Sapient

Since:
carbon 2.0
Version:
$Revision: 1.12 $($Author: dvoet $ / $Date: 2003/07/29 18:52:33 $)
Author:
Douglas Voet, March 2003

Field Summary
private  JNDILinkNodeConfiguration config
           
private  DirContext initialContext
           
private  org.apache.commons.logging.Log log
           
private  Name nodeContextName
           
private static String SUBCONTEXT_FILTER
          Filter string used in getAllChildNames to get folders and documents names
 
Fields inherited from class org.sape.carbon.core.config.node.AbstractFolder
 
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 JNDIFolder(Node parent, String name, NodeFactory subFolderFactory, NodeFactory configurationDocumentFactory, NodeFactory linkNodeFactory, DirContext initialContext, Name nodeContextName, JNDILinkNodeConfiguration config)
          Constructs the JNDIFolder and registers itself as a JNDI naming listener
 
Method Summary
protected  boolean backingDataExists()
          Checks the backing directory to see if this nodes context exists and if it does, has the right attributes.
protected  void destroyBackingData()
          Calls destroySubcontext with this context's name
protected  Set getAllChildNames()
          Called by fetchChildren to get the names of all the children from the backing data store.
(package private)  DirContext getInitialContext()
          Gets this nodes initial context.
(package private)  Name getNodeContextName()
          Gets this nodes context name.
protected  Node loadChild(String nodeName)
          Loads the child specified by nodeName from the backing data store.
private  Node loadChildLinkNode(String nodeName)
          Helper method to create a sub link
private  Node loadConfigurationDocument(String nodeName)
          Helper method to create a configuration document
private  Node loadSubFolder(String nodeName)
          Helper method to create a sub folder
 void namingExceptionThrown(NamingExceptionEvent evt)
          Logs the fact that a NamingExceptionEvent occured
 void objectAdded(NamingEvent evt)
          This implementation does not do anything if an object is added because the child could not have been loaded yet could not be cached
 void objectChanged(NamingEvent evt)
          Causes a refresh of this node
 void objectRemoved(NamingEvent evt)
          Causes a refresh of this node
 void objectRenamed(NamingEvent evt)
          Causes a refresh of this node
protected  void registerNamingListener()
          Registers this node as a NamingListener with the backing context
 
Methods inherited from class org.sape.carbon.core.config.node.AbstractFolder
addConfigurationDocument, addLink, addSubFolder, createNewConfigurationDocument, createNewFolder, getConfigurationDocumentFactory, getLinkNodeFactory, getSubFolderFactory, issueChildAddedEvent
 
Methods inherited from class org.sape.carbon.core.config.node.AbstractNode
addNodeListener, addNodeListener, addNodeListener, containsChild, fetchChild, fetchChildren, getAbsoluteName, getAddOrLoadChildLock, getAllowsChildren, getName, getParent, getReadOrAlterNodeLock, isRemoved, issueChildLoadedEvent, issueNodeRemovedEvent, 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

log

private org.apache.commons.logging.Log log

SUBCONTEXT_FILTER

private static final String SUBCONTEXT_FILTER
Filter string used in getAllChildNames to get folders and documents names

See Also:
Constant Field Values

initialContext

private DirContext initialContext

nodeContextName

private Name nodeContextName

config

private JNDILinkNodeConfiguration config
Constructor Detail

JNDIFolder

protected JNDIFolder(Node parent,
                     String name,
                     NodeFactory subFolderFactory,
                     NodeFactory configurationDocumentFactory,
                     NodeFactory linkNodeFactory,
                     DirContext initialContext,
                     Name nodeContextName,
                     JNDILinkNodeConfiguration config)
Constructs the JNDIFolder and registers itself as a JNDI naming listener

Parameters:
parent - the parent node of this node
name - the name of this node
subFolderFactory - factory used to create sub folders
configurationDocumentFactory - factory used to create sub documents
linkNodeFactory - factory used to create sub links
initialContext - the jndi initial context
nodeContextName - the name of this node's context
config - configuration used to get the names of the attributes that hold node name, node and document type, and document content as well as valid attribute values for node and document type.
Method Detail

getAllChildNames

protected Set getAllChildNames()
Description copied from class: AbstractNode
Called by fetchChildren to get the names of all the children from the backing data store. If a name appears in the returned Set, calling fetchChild with the name can not result in a NodeNotFoundException being thrown.

Specified by:
getAllChildNames in class AbstractNode
Returns:
Set of Strings, the names of all the children

loadChild

protected Node loadChild(String nodeName)
                  throws NodeNotFoundException
Description copied from class: AbstractNode
Loads the child specified by nodeName from the backing data store. Called by fetchChild when the child has not yet been cached.

Specified by:
loadChild in class AbstractNode
Parameters:
nodeName - the name of the node to load
Returns:
Node the loaded node
Throws:
NodeNotFoundException - if the backing data for the specifed node could not be found in the data store.

destroyBackingData

protected void destroyBackingData()
                           throws NodeRemovalException
Calls destroySubcontext with this context's name

Specified by:
destroyBackingData in class AbstractNode
Throws:
NodeRemovalException - if a NamingException is encountered

getInitialContext

DirContext getInitialContext()
Gets this nodes initial context. Used by JNDI node factories to pass onto child nodes

Returns:
DirContext

getNodeContextName

Name getNodeContextName()
Gets this nodes context name. Used by JNDI node factories to construct child node context names

Returns:
Name

loadSubFolder

private Node loadSubFolder(String nodeName)
                    throws NodeCreationException
Helper method to create a sub folder

Parameters:
nodeName -
Returns:
Node
Throws:
NodeCreationException

loadConfigurationDocument

private Node loadConfigurationDocument(String nodeName)
                                throws NodeCreationException
Helper method to create a configuration document

Parameters:
nodeName -
Returns:
Node
Throws:
NodeCreationException

loadChildLinkNode

private Node loadChildLinkNode(String nodeName)
                        throws NodeCreationException
Helper method to create a sub link

Parameters:
nodeName -
Returns:
Node
Throws:
NodeCreationException

backingDataExists

protected boolean backingDataExists()
Checks the backing directory to see if this nodes context exists and if it does, has the right attributes.

Specified by:
backingDataExists in class AbstractNode
Returns:
boolean true if the backing date exists, false otherwise

objectAdded

public void objectAdded(NamingEvent evt)
This implementation does not do anything if an object is added because the child could not have been loaded yet could not be cached

Specified by:
objectAdded in interface NamespaceChangeListener

objectRemoved

public void objectRemoved(NamingEvent evt)
Causes a refresh of this node

Specified by:
objectRemoved in interface NamespaceChangeListener

objectRenamed

public void objectRenamed(NamingEvent evt)
Causes a refresh of this node

Specified by:
objectRenamed in interface NamespaceChangeListener

objectChanged

public void objectChanged(NamingEvent evt)
Causes a refresh of this node

Specified by:
objectChanged in interface ObjectChangeListener

namingExceptionThrown

public void namingExceptionThrown(NamingExceptionEvent evt)
Logs the fact that a NamingExceptionEvent occured

Specified by:
namingExceptionThrown in interface NamingListener

registerNamingListener

protected void registerNamingListener()
Registers this node as a NamingListener with the backing context



Copyright 1999-2003 Sapient Corporation. All Rights Reserved.