consciouscode.seedling
Class Nodes

java.lang.Object
  extended by consciouscode.seedling.Nodes

public class Nodes
extends Object

Utility methods for working with nodes in a Seedling container.


Constructor Summary
Nodes()
           
 
Method Summary
static
<T> T
availableChild(BranchNode branch, String name)
           
static
<T> T
availablePath(BranchNode branch, NodePath path)
           
static
<T> T
availablePath(BranchNode branch, String path)
           
static void installChild(BranchNode branch, String name, Object node)
          Attempts to install a child into a given branch by downcasting it to GrowingBranch.
static
<T> T
installedChild(BranchNode branch, String name)
           
static
<T> T
installedPath(BranchNode branch, NodePath path)
           
static
<T> T
installedPath(BranchNode branch, String path)
           
static void installNode(NodeReference reference, Object node)
          Installs a node at a given reference.
static void installPath(BranchNode branch, NodePath nodePath, Object node)
          Installs a node at a given location.
static void installPath(BranchNode branch, String path, Object node)
          Installs a node at a given location.
static
<T> T
requiredChild(BranchNode branch, String name)
           
static BranchNode requiredChildBranch(BranchNode branch, String name)
          Provisions and installs a child branch.
static
<T> T
requiredPath(BranchNode branch, NodePath path)
           
static
<T> T
requiredPath(BranchNode branch, String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Nodes

public Nodes()
Method Detail

availableChild

public static <T> T availableChild(BranchNode branch,
                                   String name)
                        throws NoSuchNodeException,
                               NodeProvisioningException
Throws:
NoSuchNodeException
NodeProvisioningException

availablePath

public static <T> T availablePath(BranchNode branch,
                                  String path)
                       throws NoSuchNodeException,
                              NodeProvisioningException
Throws:
NoSuchNodeException
NodeProvisioningException

availablePath

public static <T> T availablePath(BranchNode branch,
                                  NodePath path)
                       throws NoSuchNodeException,
                              NodeProvisioningException
Throws:
NoSuchNodeException
NodeProvisioningException

installedChild

public static <T> T installedChild(BranchNode branch,
                                   String name)

installedPath

public static <T> T installedPath(BranchNode branch,
                                  String path)

installedPath

public static <T> T installedPath(BranchNode branch,
                                  NodePath path)

requiredChild

public static <T> T requiredChild(BranchNode branch,
                                  String name)
                       throws NoSuchNodeException,
                              NodeProvisioningException
Throws:
NoSuchNodeException
NodeProvisioningException

requiredPath

public static <T> T requiredPath(BranchNode branch,
                                 String path)
                      throws NoSuchNodeException,
                             NodeProvisioningException
Throws:
NoSuchNodeException
NodeProvisioningException

requiredPath

public static <T> T requiredPath(BranchNode branch,
                                 NodePath path)
                      throws NoSuchNodeException,
                             NodeProvisioningException
Throws:
NoSuchNodeException
NodeProvisioningException

installChild

public static void installChild(BranchNode branch,
                                String name,
                                Object node)
                         throws NoSuchNodeException,
                                ChildExistsException,
                                ServiceException
Attempts to install a child into a given branch by downcasting it to GrowingBranch.

Parameters:
branch - must not be null.
name - must not be null or empty. It must not match the name of an existing child node.
node - must not be null.
Throws:
NoSuchNodeException - if the branch doesn't support installation of children by implementing GrowingBranch.
ChildExistsException - if a node is already installed at the given name. (The node will not have been installed in this case.)
ServiceException - if node implements ServiceNode and could not be started. (The node will not have been installed in this case.)
See Also:
GrowingBranch.installChild(String, Object)

installNode

public static void installNode(NodeReference reference,
                               Object node)
                        throws ChildExistsException,
                               WrongNodeTypeException,
                               NodeProvisioningException
Installs a node at a given reference. Intermediate branches are provisioned and installed as necessary.

Throws:
ChildExistsException - if a node is already installed at the requested location.
WrongNodeTypeException - if an intermediate node isn't a BranchNode.
NoSuchNodeException - if an intermediate node doesn't exist and can't be provisioned.
NodeProvisioningException - if an intermediate branch failed to be provisioned.
NullPointerException - if any parameter is null.

installPath

public static void installPath(BranchNode branch,
                               String path,
                               Object node)
                        throws ChildExistsException,
                               WrongNodeTypeException,
                               NodeProvisioningException
Installs a node at a given location. Intermediate branches are provisioned and installed as necessary.

Throws:
ChildExistsException - if a node is already installed at the requested location.
WrongNodeTypeException - if an intermediate node isn't a BranchNode.
NoSuchNodeException - if an intermediate node doesn't exist and can't be provisioned.
NodeProvisioningException - if an intermediate branch failed to be provisioned.
NullPointerException - if any parameter is null.

installPath

public static void installPath(BranchNode branch,
                               NodePath nodePath,
                               Object node)
                        throws ChildExistsException,
                               WrongNodeTypeException,
                               NodeProvisioningException
Installs a node at a given location. Intermediate branches are provisioned and installed as necessary.

Throws:
ChildExistsException - if a node is already installed at the requested location.
WrongNodeTypeException - if an intermediate node isn't a BranchNode.
NoSuchNodeException - if an intermediate node doesn't exist and can't be provisioned.
NodeProvisioningException - if an intermediate branch failed to be provisioned.
NullPointerException - if any parameter is null.

requiredChildBranch

public static BranchNode requiredChildBranch(BranchNode branch,
                                             String name)
                                      throws WrongNodeTypeException,
                                             NoSuchNodeException,
                                             NodeProvisioningException,
                                             ServiceException
Provisions and installs a child branch. If there's no configuration for the node, and if the branch implements BranchingBranch, then a new child branch will be provisioned and installed.

Parameters:
branch - must not be null.
name - must not be null or empty.
Throws:
WrongNodeTypeException - if the branch already has a node installed at the given childName, but it's not a BranchNode.
NoSuchNodeException - if the branch doesn't support provisioning of child branches by implementing BranchingBranch.
NodeProvisioningException - if there's a problem provisioning the requested node.
ServiceException - if the branch couldn't be started.


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