org.jboss.cache.optimistic
Interface WorkspaceNode<K,V>

All Superinterfaces:
Node<K,V>
All Known Implementing Classes:
WorkspaceNodeImpl

public interface WorkspaceNode<K,V>
extends Node<K,V>

Represents a type of Node that is to be copied into a TransactionWorkspace for optimistically locked nodes. Adds versioning and dirty flags over conventional Nodes.

Typically used when the cache mode configured is Configuration.NodeLockingScheme.OPTIMISTIC

Since:
1.3.0
Author:
Manik Surtani (manik@jboss.org), Steve Woodcock (stevew@jofti.com)

Method Summary
 void addChild(WorkspaceNode<K,V> workspaceNode)
          Adds a given WorkspaceNode to the current node's child map
 NodeSPI createChild(Object child_name, NodeSPI<K,V> parent, CacheSPI<K,V> cache, DataVersion version)
          Creates a child node.
 NodeSPI<K,V> getChild(Fqn f)
          Overrides Node.getChild(Fqn) to return a NodeSPI rather than a Node
 NodeSPI<K,V> getChild(Object o)
          Overrides Node.getChild(Object) to return a NodeSPI rather than a Node
 List<Set<Fqn>> getMergedChildren()
          Returns 2 Sets - a set of children added (first set) and a set of children removed.
 Map<K,V> getMergedData()
          Attempts to merge data changed during the current transaction with the data in the underlying tree.
 NodeSPI<K,V> getNode()
          Retrieves a reference to the underlying NodeSPI instance.
 TransactionWorkspace getTransactionWorkspace()
          Retrieves a TransactionWorkspace instance associated with the current transaction, which the current WorkspaceNode instance lives in.
 DataVersion getVersion()
          Retrieves the data version of the in-memory node.
 boolean isChildrenLoaded()
           
 boolean isChildrenModified()
           
 boolean isCreated()
           
 boolean isDeleted()
           
 boolean isDirty()
          A convenience method that returns whether a node is dirty, i.e., it has been created, deleted or modified.
 boolean isModified()
          A node is considered modified if it's data map has changed.
 boolean isResurrected()
           
 boolean isVersioningImplicit()
          Tests whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using DefaultDataVersion rather than a custom DataVersion passed in using Option.setDataVersion(DataVersion))
 void markAsCreated()
          Marks the instance as having been created in the current transaction.
 void markAsDeleted(boolean marker)
          Marks the node as being deleted (or not) in the current transaction.
 void markAsDeleted(boolean marker, boolean recursive)
          Same as markAsDeleted(boolean) except that the option to recurse into children is provided.
 void markAsResurrected(boolean resurrected)
          Marks a node as resurrected, i.e., deleted and created again within the same transaction
 void setVersion(DataVersion version)
          Sets the data version of this workspace node.
 void setVersioningImplicit(boolean b)
          Sets whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using DefaultDataVersion rather than a custom DataVersion passed in using Option.setDataVersion(DataVersion))
 
Methods inherited from interface org.jboss.cache.Node
addChild, clearData, dataSize, get, getChildren, getChildrenNames, getData, getFqn, getKeys, getParent, hasChild, hasChild, isLockForChildInsertRemove, isResident, isValid, put, putAll, putIfAbsent, releaseObjectReferences, remove, removeChild, removeChild, replace, replace, replaceAll, setLockForChildInsertRemove, setResident
 

Method Detail

getMergedChildren

List<Set<Fqn>> getMergedChildren()
Returns 2 Sets - a set of children added (first set) and a set of children removed.

Returns:
a merged map of child names and Nodes

getVersion

DataVersion getVersion()
Retrieves the data version of the in-memory node.

Returns:
A data version

setVersion

void setVersion(DataVersion version)
Sets the data version of this workspace node.

Parameters:
version - a DataVersion implementation.

isModified

boolean isModified()
A node is considered modified if it's data map has changed. If children are added or removed, the node is not considered modified - instead, see isChildrenModified().

Returns:
true if the data map has been modified

isDirty

boolean isDirty()
A convenience method that returns whether a node is dirty, i.e., it has been created, deleted or modified. Noe that adding or removing children does not constitute a node being dirty - see isChildrenModified()

Returns:
true if the node has been either created, deleted or modified.

getMergedData

Map<K,V> getMergedData()
Attempts to merge data changed during the current transaction with the data in the underlying tree.

Returns:
a merged map of key/value pairs.

getNode

NodeSPI<K,V> getNode()
Retrieves a reference to the underlying NodeSPI instance.

Returns:
a node

getTransactionWorkspace

TransactionWorkspace getTransactionWorkspace()
Retrieves a TransactionWorkspace instance associated with the current transaction, which the current WorkspaceNode instance lives in.

Returns:
a TransactionWorkspace.

isCreated

boolean isCreated()
Returns:
true if the instance was created in the current transaction; i.e., it did not exist in the underlying data tree.

markAsCreated

void markAsCreated()
Marks the instance as having been created in the current transaction.


createChild

NodeSPI createChild(Object child_name,
                    NodeSPI<K,V> parent,
                    CacheSPI<K,V> cache,
                    DataVersion version)
Creates a child node.

Parameters:
child_name - Object name of the child to create
parent - A reference to the parent node
cache - CacheSPI instance to create this node in
version - DataVersion to apply to the child. If null, DefaultDataVersion.ZERO will be used.
Returns:
a NodeSPI pointing to the newly created child.

isVersioningImplicit

boolean isVersioningImplicit()
Tests whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using DefaultDataVersion rather than a custom DataVersion passed in using Option.setDataVersion(DataVersion))

Returns:
true if versioning is implicit.

setVersioningImplicit

void setVersioningImplicit(boolean b)
Sets whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using DefaultDataVersion rather than a custom DataVersion passed in using Option.setDataVersion(DataVersion))

Parameters:
b - set to true if versioning is implicit, false otherwise.

isDeleted

boolean isDeleted()
Returns:
true if the instance has been deleted in the current transaction.

markAsDeleted

void markAsDeleted(boolean marker)
Marks the node as being deleted (or not) in the current transaction. This is not recursive, child nodes are not affected.

Parameters:
marker - true if the node has been deleted, false if not.

markAsDeleted

void markAsDeleted(boolean marker,
                   boolean recursive)
Same as markAsDeleted(boolean) except that the option to recurse into children is provided.

Parameters:
marker - true if the node has been deleted, false if not.
recursive - if true, child nodes (and their children) are marked as well.

getChild

NodeSPI<K,V> getChild(Object o)
Overrides Node.getChild(Object) to return a NodeSPI rather than a Node

Specified by:
getChild in interface Node<K,V>
Parameters:
o - node name
Returns:
a child node

getChild

NodeSPI<K,V> getChild(Fqn f)
Overrides Node.getChild(Fqn) to return a NodeSPI rather than a Node

Specified by:
getChild in interface Node<K,V>
Parameters:
f - node fqn
Returns:
a child node

addChild

void addChild(WorkspaceNode<K,V> workspaceNode)
Adds a given WorkspaceNode to the current node's child map

Parameters:
workspaceNode -

isChildrenModified

boolean isChildrenModified()
Returns:
true if children have been added to or removed from this node. Not the same as 'dirty'.

isChildrenLoaded

boolean isChildrenLoaded()
Returns:
true if the child map has been loaded from the underlying data structure into the workspace.

isResurrected

boolean isResurrected()
Returns:
teur if this node has been resurrected, i.e., it was deleted and re-added within the same transaction

markAsResurrected

void markAsResurrected(boolean resurrected)
Marks a node as resurrected, i.e., deleted and created again within the same transaction

Parameters:
resurrected -


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