consciouscode.seedling.tree
Class EmptyBranch

java.lang.Object
  extended by consciouscode.seedling.tree.GenericNode
      extended by consciouscode.seedling.tree.EmptyBranch
All Implemented Interfaces:
BranchNode, LocatableNode, ServiceNode

public class EmptyBranch
extends GenericNode
implements BranchNode

A trivial branch that has no child nodes, and can't have any installed. This can be useful for unit tests, or perhaps for disabling an entire subtree by overriding construction of an existing branch.


Constructor Summary
EmptyBranch()
           
 
Method Summary
 Object availableChild(String nodeName)
          Gets a child node, provisioning and installing it if possible.
 Collection<String> availableChildNames()
          Extracts a collection of the names of child nodes that are available on request from this branch.
 Object getChild(String nodeName)
          Deprecated. 
 Object getInstalledNode(String path)
          Deprecated. 
 Object getNode(String path)
          Deprecated. 
 Object installedChild(String nodeName)
          Gets a child node, but doesn't provision it if it's not already installed.
 Collection<String> installedChildNames()
          Extracts a collection of the names of this branch's current child nodes.
 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
 
Methods inherited from interface consciouscode.seedling.BranchNode
getLocalRoot, getLog
 
Methods inherited from interface consciouscode.seedling.LocatableNode
getNodeLocation, nodeInstalled
 

Constructor Detail

EmptyBranch

public EmptyBranch()
Method Detail

startService

public void startService()
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

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)

installedChildNames

public Collection<String> installedChildNames()
Description copied from interface: BranchNode
Extracts a collection of the names of this branch's current child nodes.

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 before the name is even read from this list.

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:
installedChildNames in interface BranchNode
Returns:
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
Returns:
not null.

getNode

@Deprecated
public Object getNode(String path)
               throws NodeProvisioningException
Deprecated. 

Description copied from interface: BranchNode
Gets a node from a path relative to this branch, instantiating and installing it if necessary.

Specified by:
getNode in interface BranchNode
Parameters:
path - is interpreted relative to this branch. It may also be a (local or global) full path. It must not be null or empty.
Returns:
the requested node.
Throws:
NodeProvisioningException - if no such node exists, or if there was an error instantiating it.

getInstalledNode

@Deprecated
public Object getInstalledNode(String path)
Deprecated. 

Description copied from interface: BranchNode
Looks for a node relative to this branch, without instantiating any new nodes.

Specified by:
getInstalledNode in interface BranchNode
Parameters:
path - is interpreted relative to this branch. It may also be a (local or global) full path. It must not be null or empty.
Returns:
the requested node, or null if no node exists at the given path.

getChild

@Deprecated
public Object getChild(String nodeName)
                throws NoSuchNodeException
Deprecated. 

Description copied from interface: BranchNode
Gets a required child node, provisioning and installing it if necessary.

Provisioning of uninstalled nodes is defined by the implementation class, which may not do any dynamic provisioning at all.

This method will not return null; see BranchNode.availableChild(String) and BranchNode.installedChild(String) for alternatives.

Specified by:
getChild in interface BranchNode
Parameters:
nodeName - must not be null or empty.
Throws:
NoSuchNodeException - if the node isn't installed and if the branch cannot provision it on demand. This usually means that there's no applicable configuration for the node

availableChild

public Object availableChild(String nodeName)
Description copied from interface: BranchNode
Gets a child node, provisioning and installing it if possible.

A node is available if its already installed, or if it can be provided for installation, usually by being created from configuration. Provisioning of uninstalled nodes is defined by the implementation class, which may not do any dynamic provisioning at all, in which case this method behaves identically to BranchNode.installedChild(String).

If the requested node is not available then null is returned. This is in contrast to BranchNode.getChild(String), which throws NoSuchNodeException in that case.

Specified by:
availableChild in interface BranchNode
Parameters:
nodeName - must not be null or empty.
Returns:
the requested node, or null if it's not available.

installedChild

public Object installedChild(String nodeName)
Description copied from interface: BranchNode
Gets a child node, but doesn't provision it if it's not already installed.

Specified by:
installedChild in interface BranchNode
Parameters:
nodeName - must not be null or empty.
Returns:
the child node installed with the requested name, or null if no such child is installed.


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