org.jboss.cache.mvcc
Class MVCCNodeFactory<K,V>

java.lang.Object
  extended by org.jboss.cache.AbstractNodeFactory<K,V>
      extended by org.jboss.cache.mvcc.MVCCNodeFactory<K,V>
All Implemented Interfaces:
NodeFactory<K,V>

public class MVCCNodeFactory<K,V>
extends AbstractNodeFactory<K,V>

Creates nodes specific to MVCC logic.

Since:
3.0
Author:
Manik Surtani (manik AT jboss DOT org)

Field Summary
 
Fields inherited from class org.jboss.cache.AbstractNodeFactory
cache, commandsFactory, componentRegistry, configuration, dataContainer, interceptorChain, invocationContextContainer, useVersionedNode
 
Constructor Summary
MVCCNodeFactory()
           
 
Method Summary
 InternalNode<K,V> createChildNode(Fqn fqn, InternalNode<K,V> parent, InvocationContext ctx, boolean attachToParent)
          Creates a new node, and optionally attaches the node to its parent.
 InternalNode<K,V> createInternalNode(Fqn fqn)
          Creates an internal node.
 NodeSPI<K,V> createNode(Fqn fqn, NodeSPI<K,V> parent)
          Creates a new, empty node.
 NodeSPI<K,V> createNode(Fqn fqn, NodeSPI<K,V> parent, Map<K,V> data)
          Creates a new node and populates its attributes.
 NodeSPI<K,V> createNode(Object childName, NodeSPI<K,V> parent)
          Creates a new, empty node.
 NodeSPI<K,V> createNode(Object childName, NodeSPI<K,V> parent, Map<K,V> data)
          Creates a new node and populates its attributes.
 NodeSPI<K,V> createRootNode()
           
 ReadCommittedNode createWrappedNode(InternalNode<K,V> node, InternalNode<K,V> parent)
          Creates an MVCC wrapped node - either a ReadCommittedNode or its subclass, a RepeatableReadNode based on cache configuration.
 ReadCommittedNode createWrappedNodeForRemoval(Fqn fqn, InternalNode<K,V> node, InternalNode<K,V> parent)
           
 void init()
          Initialises the node factory with the configuration from the cache.
 
Methods inherited from class org.jboss.cache.AbstractNodeFactory
createInternalNode, createWrappedNode, injectDependencies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MVCCNodeFactory

public MVCCNodeFactory()
Method Detail

init

public void init()
Initialises the node factory with the configuration from the cache.


createWrappedNode

public ReadCommittedNode createWrappedNode(InternalNode<K,V> node,
                                           InternalNode<K,V> parent)
Creates an MVCC wrapped node - either a ReadCommittedNode or its subclass, a RepeatableReadNode based on cache configuration. If a null is passed in as the InternalNode, this method will return a special NullMarkerNode instance if using repeatable read, or a null if read committed.

Specified by:
createWrappedNode in interface NodeFactory<K,V>
Overrides:
createWrappedNode in class AbstractNodeFactory<K,V>
Parameters:
node - internal node to wrap.
Returns:
a ReadCommittedNode

createWrappedNodeForRemoval

public ReadCommittedNode createWrappedNodeForRemoval(Fqn fqn,
                                                     InternalNode<K,V> node,
                                                     InternalNode<K,V> parent)
Specified by:
createWrappedNodeForRemoval in interface NodeFactory<K,V>
Overrides:
createWrappedNodeForRemoval in class AbstractNodeFactory<K,V>

createNode

public NodeSPI<K,V> createNode(Fqn fqn,
                               NodeSPI<K,V> parent,
                               Map<K,V> data)
Description copied from interface: NodeFactory
Creates a new node and populates its attributes.

Note that the data map passed in must not be null, and must not be referenced anywhere else as a defensive copy is NOT made when injecting it into the node.

Specified by:
createNode in interface NodeFactory<K,V>
Overrides:
createNode in class AbstractNodeFactory<K,V>
Returns:
a new node

createNode

public NodeSPI<K,V> createNode(Fqn fqn,
                               NodeSPI<K,V> parent)
Description copied from interface: NodeFactory
Creates a new, empty node.

Specified by:
createNode in interface NodeFactory<K,V>
Overrides:
createNode in class AbstractNodeFactory<K,V>
Returns:
a new node

createRootNode

public NodeSPI<K,V> createRootNode()
Specified by:
createRootNode in interface NodeFactory<K,V>
Overrides:
createRootNode in class AbstractNodeFactory<K,V>

createInternalNode

public InternalNode<K,V> createInternalNode(Fqn fqn)
Description copied from interface: NodeFactory
Creates an internal node. Similar to NodeFactory.createNode(Fqn, NodeSPI) except that the resultant node is not wrapped in a NodeInvocationDelegate.

Specified by:
createInternalNode in interface NodeFactory<K,V>
Overrides:
createInternalNode in class AbstractNodeFactory<K,V>
Returns:
a new node

createNode

public NodeSPI<K,V> createNode(Object childName,
                               NodeSPI<K,V> parent,
                               Map<K,V> data)
Description copied from interface: NodeFactory
Creates a new node and populates its attributes.

Note that the data map passed in must not be null, and must not be referenced anywhere else as a defensive copy is NOT made when injecting it into the node.

Specified by:
createNode in interface NodeFactory<K,V>
Overrides:
createNode in class AbstractNodeFactory<K,V>
Returns:
a new node

createNode

public NodeSPI<K,V> createNode(Object childName,
                               NodeSPI<K,V> parent)
Description copied from interface: NodeFactory
Creates a new, empty node.

Specified by:
createNode in interface NodeFactory<K,V>
Overrides:
createNode in class AbstractNodeFactory<K,V>
Returns:
a new node

createChildNode

public InternalNode<K,V> createChildNode(Fqn fqn,
                                         InternalNode<K,V> parent,
                                         InvocationContext ctx,
                                         boolean attachToParent)
Description copied from interface: NodeFactory
Creates a new node, and optionally attaches the node to its parent.

The assumption here is that any locks are acquired to prevent concurrent creation of the same node. Implementations of the NodeFactory should not attempt to synchronize or guard against concurrent creation.

Specified by:
createChildNode in interface NodeFactory<K,V>
Overrides:
createChildNode in class AbstractNodeFactory<K,V>
Parameters:
fqn - fqn of node to create. Must not be null or root.
parent - parent to attach to. Must not be null, even if attachToParent is false.
ctx - invocation context to register with. Must not be null.
attachToParent - if true, the node is registered in the parent's child map. If false, it is not.
Returns:
a new node, or the existing node if one existed.


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