consciouscode.seedling.webConsole
Class NodeIndex

java.lang.Object
  extended by consciouscode.seedling.tree.GenericNode
      extended by consciouscode.seedling.webConsole.NodeIndex
All Implemented Interfaces:
BranchChangeListener, LocatableNode, ServiceNode, EventListener

public class NodeIndex
extends GenericNode
implements ServiceNode, BranchChangeListener


Constructor Summary
NodeIndex()
           
 
Method Summary
 void childInstalled(BranchChangeEvent event)
          Notifies this listener that a child has been added to a branch.
 void childUninstalled(BranchChangeEvent event)
          Removes uninstalled nodes from the index, ignoring events where the node and path don't match what we've indexed.
 int getIndexSize()
           
 String getMapContents()
           
 int getQueueSize()
           
 BranchNode getStartingBranch()
           
 boolean isRunning()
           
 String lookupNode(Object node)
          Finds a potential path in the tree for a requested object.
 void setStartingBranch(BranchNode branch)
           
 void startService()
          Starts a Seedling service.
 void stopService()
          Stops a Seedling service.
 
Methods inherited from class consciouscode.seedling.tree.GenericNode
getLocalRoot, getLog, getNodeLocation, getNodeName, getParentBranch, isLoggingDebug, nodeInstalled, setLog, setLoggingDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeIndex

public NodeIndex()
Method Detail

getStartingBranch

public BranchNode getStartingBranch()

setStartingBranch

public void setStartingBranch(BranchNode branch)

lookupNode

public String lookupNode(Object node)
Finds a potential path in the tree for a requested object. Note that the returned path may not be correct, since things may have changed or the index may be incomplete. Thus the caller should check the path for accuracy before relying on it.

Parameters:
node - must not be null.
Returns:
the global path to the requested node.

startService

public void startService()
                  throws InterruptedException
Description copied from interface: ServiceNode
Starts a Seedling service. This is called by the Seedling runtime after the node has been installed and all properties have been set to their configured values. Any exceptions thrown by an implementation of this method are handled by the Seedling. Instances of RuntimeException are propagated to the application, but any other kind of exception is wrapped in a ServiceException and rethrown.

Specified by:
startService in interface ServiceNode
Throws:
InterruptedException

stopService

public void stopService()
Description copied from interface: ServiceNode
Stops a Seedling service. This is called by the Seedling runtime as the node is uninstalled, either explicitly or by the Seedling itself being stopped.

Implementations of this method must not do anything that may change the state of the parent Seedling. In particular, it cannot call any overload of the following methods: BranchNode.getNode(java.lang.String), BranchNode.getChild(java.lang.String), GrowingBranch.installChild(java.lang.String, java.lang.Object), GrowingBranch.uninstallChild(java.lang.String).

Furthermore, this method may be called from within a JVM shutdown hook, which implies that it must work promptly and carefully.

Specified by:
stopService in interface ServiceNode
See Also:
Runtime.addShutdownHook(java.lang.Thread)

isRunning

public boolean isRunning()

getMapContents

public String getMapContents()

getQueueSize

public int getQueueSize()

getIndexSize

public int getIndexSize()

childInstalled

public void childInstalled(BranchChangeEvent event)
Description copied from interface: BranchChangeListener
Notifies this listener that a child has been added to a branch.

Specified by:
childInstalled in interface BranchChangeListener
Parameters:
event - contains information about the event; not null.

childUninstalled

public void childUninstalled(BranchChangeEvent event)
Removes uninstalled nodes from the index, ignoring events where the node and path don't match what we've indexed. We can allow some imprecision here, because we can let nodes drain out of the index as the garbage collector works.

Specified by:
childUninstalled in interface BranchChangeListener
Parameters:
event - contains information about the event; not null.


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.