org.modeshape.graph.connector.inmemory
Class InMemoryTransaction

java.lang.Object
  extended by org.modeshape.graph.connector.base.BaseTransaction<NodeType,WorkspaceType>
      extended by org.modeshape.graph.connector.base.MapTransaction<InMemoryNode,InMemoryWorkspace>
          extended by org.modeshape.graph.connector.inmemory.InMemoryTransaction
All Implemented Interfaces:
Transaction<InMemoryNode,InMemoryWorkspace>

@NotThreadSafe
public class InMemoryTransaction
extends MapTransaction<InMemoryNode,InMemoryWorkspace>


Nested Class Summary
 
Nested classes/interfaces inherited from class org.modeshape.graph.connector.base.MapTransaction
MapTransaction.Children, MapTransaction.WorkspaceChanges
 
Field Summary
 
Fields inherited from class org.modeshape.graph.connector.base.BaseTransaction
context, nameFactory, pathFactory, propertyFactory, rootLocation, rootNodeUuid, valueFactories
 
Constructor Summary
protected InMemoryTransaction(ExecutionContext context, InMemoryRepository repository, UUID rootNodeUuid, Lock lock)
           
 
Method Summary
 void commit()
          Commit any changes that have been made to the repository.
protected  InMemoryNode createNode(UUID uuid, Path.Segment name, UUID parentUuid, Iterable<Property> properties)
          Create a new instance of the node, given the supplied UUID.
 boolean destroyWorkspace(InMemoryWorkspace workspace)
          Destroy the workspace with the supplied name.
 InMemoryWorkspace getWorkspace(String name, InMemoryWorkspace originalToClone)
          Creates a new workspace with the given name containing only a root node.
 void rollback()
          Rollback any changes that have been made to this repository.
 
Methods inherited from class org.modeshape.graph.connector.base.MapTransaction
addChild, addChild, cloneNode, copyBranch, copyNode, destroyNode, findLatest, findNode, getChangesFor, getChild, getChildren, getChildrenLocations, getNode, getParent, getUuidsUnderNode, print, query, removeAllChildren, removeNode, removeProperty, search, setProperties, verifyNodeExists
 
Methods inherited from class org.modeshape.graph.connector.base.BaseTransaction
getContext, getFirstChild, getNode, getRepository, getRootLocation, getRootNode, getRootUuid, getWorkspaceNames, lockNode, pathFor, readable, unlockNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InMemoryTransaction

protected InMemoryTransaction(ExecutionContext context,
                              InMemoryRepository repository,
                              UUID rootNodeUuid,
                              Lock lock)
Method Detail

getWorkspace

public InMemoryWorkspace getWorkspace(String name,
                                      InMemoryWorkspace originalToClone)
Creates a new workspace with the given name containing only a root node. If the workspace already exists, it is left untouched and returned.

Parameters:
name - the name of the workspace; may not be null
originalToClone - the workspace that should be cloned, or null if the new workspace is to only contain a root node
Returns:
the newly created workspace; may not be null
See Also:
Transaction.getWorkspace(java.lang.String, org.modeshape.graph.connector.base.Workspace)

destroyWorkspace

public boolean destroyWorkspace(InMemoryWorkspace workspace)
Destroy the workspace with the supplied name.

Parameters:
workspace - the workspace that is to be destroyed; may not be null
Returns:
true if the workspace was destroyed, or false if the workspace did not exist
See Also:
Transaction.destroyWorkspace(org.modeshape.graph.connector.base.Workspace)

createNode

protected InMemoryNode createNode(UUID uuid,
                                  Path.Segment name,
                                  UUID parentUuid,
                                  Iterable<Property> properties)
Create a new instance of the node, given the supplied UUID. This method should do nothing but instantiate the new node; the caller will add to the appropriate maps.

Overrides:
createNode in class MapTransaction<InMemoryNode,InMemoryWorkspace>
Parameters:
uuid - the desired UUID; never null
name - the name of the new node; may be null if the name is not known
parentUuid - the UUID of the parent node; may be null if this is the root node
properties - the properties; may be null if there are no properties
Returns:
the new node; never null
See Also:
MapTransaction.createNode(java.util.UUID, org.modeshape.graph.property.Path.Segment, java.util.UUID, java.lang.Iterable)

commit

public void commit()
Commit any changes that have been made to the repository. This method may throw runtime exceptions if there are failures committing the changes, but the transaction is still expected to be closed.

Specified by:
commit in interface Transaction<InMemoryNode,InMemoryWorkspace>
Overrides:
commit in class MapTransaction<InMemoryNode,InMemoryWorkspace>
See Also:
Transaction.commit()

rollback

public void rollback()
Rollback any changes that have been made to this repository. This method may throw runtime exceptions if there are failures rolling back the changes, but the transaction is still expected to be closed.

Specified by:
rollback in interface Transaction<InMemoryNode,InMemoryWorkspace>
Overrides:
rollback in class MapTransaction<InMemoryNode,InMemoryWorkspace>
See Also:
Transaction.rollback()


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.