consciouscode.seedling.tree
Class StandardBranch

java.lang.Object
  extended by consciouscode.seedling.tree.GenericNode
      extended by consciouscode.seedling.tree.GenericBranch
          extended by consciouscode.seedling.tree.StandardBranch
All Implemented Interfaces:
BranchingBranch, BranchNode, EventfulBranch, GrowingBranch, LocatableNode, ServiceNode
Direct Known Subclasses:
ScopeRoot, StandardRoot

public class StandardBranch
extends GenericBranch
implements BranchingBranch

The canonical implementation of BranchNode, providing dynamic node provisioning via a NodeProvider.


Field Summary
protected  NodeProvider myNodeProvider
           
 
Constructor Summary
StandardBranch()
          Constructs a new branch, inheriting its NodeProvider from its parent branch.
StandardBranch(NodeProvider nodeProvider)
           
 
Method Summary
 Collection<String> availableChildNames()
          Extracts a collection of the names of child nodes that are available on request from this branch.
protected  StandardBranch constructChildBranch()
          Strategy method called by GenericBranch.provisionChildBranch() to do initial construction of child branches.
 NodeProvider getNodeProvider()
          Returns the object responsible for provisioning nodes for this branch.
 void nodeInstalled(NodeLocation location)
          Register the Seedling address at which this node has been installed.
protected  Object provisionChild(String nodeName)
          Attempts to provision a child node, where one doesn't currently exist.
 
Methods inherited from class consciouscode.seedling.tree.GenericBranch
addBranchChangeListener, availableChild, createChild, fireChildInstalled, fireChildUninstalled, getChild, getInstalledNode, getLocalPathForChild, getLocalRoot, getNode, installChild, installedChild, installedChildNames, provisionChildBranch, startService, stopService, uninstallChild
 
Methods inherited from class consciouscode.seedling.tree.GenericNode
getLog, getNodeLocation, getNodeName, getParentBranch, isLoggingDebug, setLog, setLoggingDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface consciouscode.seedling.BranchingBranch
provisionChildBranch
 
Methods inherited from interface consciouscode.seedling.GrowingBranch
installChild, uninstallChild
 
Methods inherited from interface consciouscode.seedling.BranchNode
availableChild, getChild, getInstalledNode, getLocalRoot, getLog, getNode, installedChild, installedChildNames
 
Methods inherited from interface consciouscode.seedling.LocatableNode
getNodeLocation
 
Methods inherited from interface consciouscode.seedling.ServiceNode
startService, stopService
 

Field Detail

myNodeProvider

protected NodeProvider myNodeProvider
Constructor Detail

StandardBranch

public StandardBranch()
Constructs a new branch, inheriting its NodeProvider from its parent branch. This can only be installed inside another instance of StandardBranch.

See Also:
nodeInstalled(NodeLocation)

StandardBranch

public StandardBranch(NodeProvider nodeProvider)
Method Detail

getNodeProvider

public NodeProvider getNodeProvider()
Returns the object responsible for provisioning nodes for this branch.

Returns:
this branch's node provider (not null).

availableChildNames

public Collection<String> availableChildNames()
Description copied from interface: BranchNode
Extracts a collection of the names of child nodes that are available on request from this branch. This set includes all installed children, as well as any other nodes that could be created on demand (usually via automated injection from configuration files).

The result is a snapshot of the current state: subsequent changes to the branch are not reflected in the result. Thus the actual children may have changed by the time the collection is inspected; in particular, another thread may uninstall a node named in this collection (thereby making it unavailable) before the name is even read from this collection.

Implementations must ensure that the result stays usable even when the branch changes in another thread. For example, iterating the result must not throw ConcurrentModificationException if the branch changes during iteration.

Specified by:
availableChildNames in interface BranchNode
Overrides:
availableChildNames in class GenericBranch
Returns:
not null.

nodeInstalled

public void nodeInstalled(NodeLocation location)
Description copied from class: GenericBranch
Register the Seedling address at which this node has been installed. This is called immediately after the node has been installed into the tree.

Note: This is not called setNodeLocation because the location is not intended as a writable property. This implementation calls super and then caches the location's local root.

Specified by:
nodeInstalled in interface LocatableNode
Overrides:
nodeInstalled in class GenericBranch
Parameters:
location - is this node's new location. It must not be null.
See Also:
GenericBranch.getLocalRoot()

constructChildBranch

protected StandardBranch constructChildBranch()
Description copied from class: GenericBranch
Strategy method called by GenericBranch.provisionChildBranch() to do initial construction of child branches. Subclasses will generally override this to construct a new instance of their own class.

Overrides:
constructChildBranch in class GenericBranch
Returns:
a new GenericBranch.
See Also:
GenericBranch.provisionChildBranch()

provisionChild

protected Object provisionChild(String nodeName)
                         throws NodeProvisioningException
Description copied from class: GenericBranch
Attempts to provision a child node, where one doesn't currently exist. This is not guaranteed to succeed; for instance there may be no appropriate configuration, or the branch may not support automatic child provisioning.

This implementation always returns null.

Overrides:
provisionChild in class GenericBranch
Returns:
the newly-created child node, or null if the node is not available.
Throws:
NodeProvisioningException - if there's a problem provisioning the node.


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