|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.connector.base.PathWorkspace<NodeType>
NodeType
- the type of node@NotThreadSafe public abstract class PathWorkspace<NodeType extends PathNode>
The Workspace
implementation that represents all nodes as PathNode
objects and stores them in an internal data
structure that allows for nodes to be accessed via a Path
.
Subclasses are required to provide thread-safe access and modification of the state within the encapsulated data structure,
since multiple Transaction
implementations may be committing
changes to the data structure
at the same time. However, this class does not provide any thread-safety, since the nature of the thread-safety will almost
certainly depend on the actual implementation. For example, a subclass may use a lock
, or it may use a
map implementation that provides the thread-safety.
Nested Class Summary | |
---|---|
static interface |
PathWorkspace.ChangeCommand<NodeType extends PathNode>
A specific operation that mutates the underlying persistent repository. |
Field Summary | |
---|---|
protected PathFactory |
pathFactory
|
Constructor Summary | |
---|---|
PathWorkspace(ExecutionContext context,
String name,
UUID rootNodeUuid)
Create a new instance of the workspace. |
|
PathWorkspace(String name,
PathWorkspace<NodeType> originalToClone)
Create a new instance of the workspace. |
Method Summary | |
---|---|
void |
commit(List<PathWorkspace.ChangeCommand<NodeType>> commands)
Successively (and in order) apply the changes from the list of pending commands All validation for each of the objects (including validation of resource availability in the underlying persistent store) should be performed prior to invoking this method. |
PathWorkspace.ChangeCommand<NodeType> |
createMoveCommand(NodeType source,
NodeType target)
Create a change command that represents the movement of a node. |
PathWorkspace.ChangeCommand<NodeType> |
createPutCommand(NodeType oldNode,
NodeType node)
Create a change command for the required update to the given node |
PathWorkspace.ChangeCommand<NodeType> |
createRemoveCommand(Path path)
Create a change command for the removal of the given node and its descendants |
String |
getName()
Returns the name of the workspace. |
abstract NodeType |
getNode(Path path)
Get the node with the supplied path. |
abstract NodeType |
getRootNode()
Get the root node in this workspace. |
protected UUID |
getRootNodeUuid()
|
boolean |
hasNodeCache()
Indicates whether this workspace has a node cache. |
NodeType |
moveNode(NodeType source,
NodeType target)
Move the node from it's previous location to the new location, overwriting any previous node at that location. |
NodeType |
putNode(NodeType node)
Save this node into the workspace, overwriting any previous record of the node. |
void |
removeAll()
Remove all of the nodes in this workspace, and make sure there is a single root node with no properties and no children. |
NodeType |
removeNode(Path path)
Remove this node and its descendants from the workspace. |
String |
toString()
|
Location |
verifyNodeExists(Path path)
Verify that the supplied node exists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final PathFactory pathFactory
Constructor Detail |
---|
public PathWorkspace(ExecutionContext context, String name, UUID rootNodeUuid)
context
- the execution context for this workspace; may not be nullname
- the workspace name; may not be nullrootNodeUuid
- the root node that is expected to already exist in the mappublic PathWorkspace(String name, PathWorkspace<NodeType> originalToClone)
name
- the workspace name; may not be nulloriginalToClone
- the workspace that is to be cloned; may not be nullMethod Detail |
---|
public String getName()
getName
in interface Workspace
Workspace.getName()
protected UUID getRootNodeUuid()
public abstract NodeType getRootNode()
public abstract NodeType getNode(Path path)
path
- the path to the node
public Location verifyNodeExists(Path path)
path
- the path of the node; may not be null
public NodeType putNode(NodeType node)
PathWorkspace.ChangeCommand
implementations.
node
- the new node; may not be null
UnsupportedOperationException
- by default, subclasses should override this method so that this exception is not
throwncreateMoveCommand(PathNode, PathNode)
,
createPutCommand(PathNode, PathNode)
,
createRemoveCommand(Path)
public NodeType moveNode(NodeType source, NodeType target)
PathWorkspace.ChangeCommand
implementations.
The move operation is intended to reflect changes to the node's name
or
parent
only. Changes to the children or properties of the node should be reflected separately
in a put command
of some sort. The details of the put command are implementation-specific.
source
- the original version of the node to be moved; may not be nulltarget
- the new version (implying a change to the name or parent) of the node to be moved; may not be null
UnsupportedOperationException
- by default, subclasses should override this method so that this exception is not
throwncreateMoveCommand(PathNode, PathNode)
,
createPutCommand(PathNode, PathNode)
,
createRemoveCommand(Path)
public NodeType removeNode(Path path)
PathWorkspace.ChangeCommand
implementations.
path
- the path to the node to be removed; may not be null
UnsupportedOperationException
- by default, subclasses should override this method so that this exception is not
throwncreateMoveCommand(PathNode, PathNode)
,
createPutCommand(PathNode, PathNode)
,
createRemoveCommand(Path)
public void removeAll()
public String toString()
toString
in class Object
Object.toString()
public boolean hasNodeCache()
NoCachePolicy
.
hasNodeCache
in interface Workspace
Workspace.hasNodeCache()
public void commit(List<PathWorkspace.ChangeCommand<NodeType>> commands)
All validation for each of the objects (including validation of resource availability in the underlying persistent store) should be performed prior to invoking this method.
commands
- the list of commands to applypublic PathWorkspace.ChangeCommand<NodeType> createPutCommand(NodeType oldNode, NodeType node)
oldNode
- the prior version of the node; may be null if this is a new nodenode
- the new version of the node; may not be null
PathWorkspace.ChangeCommand
instance that reflects the changes to the nodecommit(List)
public PathWorkspace.ChangeCommand<NodeType> createRemoveCommand(Path path)
path
- the path to the node at the root of the branch to be removed; may not be null
PathWorkspace.ChangeCommand
instance that reflects the changes to the nodecreatePutCommand(PathNode, PathNode)
,
commit(List)
public PathWorkspace.ChangeCommand<NodeType> createMoveCommand(NodeType source, NodeType target)
put command
should be used to reflect these changes.
source
- the original version of the node; may not be nulltarget
- the new version of the node; may not be null
PathWorkspace.ChangeCommand
instance that reflects the changes to the nodecreateMoveCommand(PathNode, PathNode)
,
commit(List)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |