org.modeshape.connector.disk
Class DiskWorkspace

java.lang.Object
  extended by org.modeshape.graph.connector.base.MapWorkspace<DiskNode>
      extended by org.modeshape.connector.disk.DiskWorkspace
All Implemented Interfaces:
NodeCachePolicyChangedListener<UUID,DiskNode>, NodeCachingWorkspace<UUID,DiskNode>, Workspace

public class DiskWorkspace
extends MapWorkspace<DiskNode>
implements NodeCachingWorkspace<UUID,DiskNode>

Workspace implementation for disk connector


Field Summary
 
Fields inherited from class org.modeshape.graph.connector.base.MapWorkspace
name, rootNodeUuid
 
Constructor Summary
DiskWorkspace(String name, File workspaceRoot, DiskNode rootNode, DiskRepository repository)
          Create a new workspace instance.
DiskWorkspace(String name, File workspaceRoot, DiskWorkspace originalToClone)
          Create a new workspace instance.
 
Method Summary
 void cachePolicyChanged(NodeCachePolicyChangedEvent<UUID,DiskNode> event)
          Notifies this workspace that the cache policy has changed and the cache should be reset.
 void destroy()
           
 NodeCache<UUID,DiskNode> getCache()
           
 DiskNode getNode(UUID uuid)
          Get the node with the supplied UUID.
 DiskNode putNode(DiskNode node)
          Add the node into this workspace's map, 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.
 DiskNode removeNode(UUID uuid)
          Remove and return the node with the supplied UUID.
 void shutdown()
          This method shuts down the workspace and makes it no longer usable.
 
Methods inherited from class org.modeshape.graph.connector.base.MapWorkspace
getName, getRootNode, getRootNodeUuid, hasNodeCache, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiskWorkspace

public DiskWorkspace(String name,
                     File workspaceRoot,
                     DiskNode rootNode,
                     DiskRepository repository)
Create a new workspace instance.

Parameters:
name - the name of the workspace; may not be null
workspaceRoot - a pointer to the root of the workspace on disk; may not be null
rootNode - the root node for the workspace; may not be null
repository - the repository to which this workspace belongs; may not be null

DiskWorkspace

public DiskWorkspace(String name,
                     File workspaceRoot,
                     DiskWorkspace originalToClone)
Create a new workspace instance.

Parameters:
name - the name of the workspace
workspaceRoot - a pointer to the root of the workspace on disk
originalToClone - the workspace that is to be cloned
Method Detail

destroy

public void destroy()

shutdown

public void shutdown()
This method shuts down the workspace and makes it no longer usable. This method should also only be called once.


cachePolicyChanged

public void cachePolicyChanged(NodeCachePolicyChangedEvent<UUID,DiskNode> event)
Notifies this workspace that the cache policy has changed and the cache should be reset.

Specified by:
cachePolicyChanged in interface NodeCachePolicyChangedListener<UUID,DiskNode>
Parameters:
event - the cache policy changed event; may not be null

getCache

public NodeCache<UUID,DiskNode> getCache()
Specified by:
getCache in interface NodeCachingWorkspace<UUID,DiskNode>

getNode

public DiskNode getNode(UUID uuid)
Description copied from class: MapWorkspace
Get the node with the supplied UUID.

Specified by:
getNode in class MapWorkspace<DiskNode>
Parameters:
uuid - the UUID of the node
Returns:
the node state as known by this workspace, or null if no such node exists in this workspace

putNode

public DiskNode putNode(DiskNode node)
Description copied from class: MapWorkspace
Add the node into this workspace's map, overwriting any previous record of the node

Specified by:
putNode in class MapWorkspace<DiskNode>
Parameters:
node - the new node; may not be null
Returns:
the previous node state, or null if the node is new to this workspace

removeAll

public void removeAll()
Description copied from class: MapWorkspace
Remove all of the nodes in this workspace, and make sure there is a single root node with no properties and no children.

Specified by:
removeAll in class MapWorkspace<DiskNode>

removeNode

public DiskNode removeNode(UUID uuid)
Description copied from class: MapWorkspace
Remove and return the node with the supplied UUID. This method will never remove the root node.

Specified by:
removeNode in class MapWorkspace<DiskNode>
Parameters:
uuid - the UUID of the node to be removed
Returns:
the node that was removed, or null if the supplied UUID is the root node's UUID or if this workspace does not contain a node with the supplied UUID


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