consciouscode.seedling.scope
Class ScopeManager

java.lang.Object
  extended by consciouscode.seedling.tree.GenericNode
      extended by consciouscode.seedling.tree.GenericBranch
          extended by consciouscode.seedling.scope.ScopeManager
All Implemented Interfaces:
BranchingBranch, BranchNode, EventfulBranch, GrowingBranch, LocatableNode, ServiceNode

public class ScopeManager
extends GenericBranch

A branch that creates and manages ScopeRoots. Each scope that is created is installed as a child of this branch. Attempts to install child nodes in any other way will fail.


Constructor Summary
ScopeManager(String managedScopeTag)
           
 
Method Summary
 ScopeRoot createScope()
          Creates and installs a new child scope.
protected  String generateScopeName()
          Generate a unique name for a new child scope.
 int getCreatedScopeCount()
          Returns the number of child scopes this manager has created in its lifetime.
 String getManagedScopeTag()
          Returns the scope tag that will be assigned to managed scopes.
 NodeProvider getScopeNodeProvider()
           
 void nodeInstalled(NodeLocation location)
          Register the Seedling address at which this node has been installed.
 void uninstallScope(ScopeRoot scope)
          Uninstalls the given scope, stopping every node within it.
 
Methods inherited from class consciouscode.seedling.tree.GenericBranch
addBranchChangeListener, availableChild, availableChildNames, constructChildBranch, createChild, fireChildInstalled, fireChildUninstalled, getChild, getInstalledNode, getLocalPathForChild, getLocalRoot, getNode, installChild, installedChild, installedChildNames, provisionChild, 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.BranchNode
getLog
 
Methods inherited from interface consciouscode.seedling.LocatableNode
getNodeLocation
 

Constructor Detail

ScopeManager

public ScopeManager(String managedScopeTag)
Method Detail

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()

getScopeNodeProvider

public NodeProvider getScopeNodeProvider()

getManagedScopeTag

public String getManagedScopeTag()
Returns the scope tag that will be assigned to managed scopes.


getCreatedScopeCount

public int getCreatedScopeCount()
Returns the number of child scopes this manager has created in its lifetime.


createScope

public ScopeRoot createScope()
Creates and installs a new child scope. The name of the scope, which can be used to access the scope as a child of this branch, can be found via ScopeRoot.getNameInManager().


uninstallScope

public void uninstallScope(ScopeRoot scope)
Uninstalls the given scope, stopping every node within it.

Parameters:
scope - may be null.

generateScopeName

protected String generateScopeName()
Generate a unique name for a new child scope. By default, this concatenates the managedScopeTag with the current createdScopeCount, but subclasses may override this to implement a different naming convention.

Note that this method must always be called from within a block synchronized on this.



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