org.jboss.cache
Class AbstractNodeFactory<K,V>

java.lang.Object
  extended by org.jboss.cache.AbstractNodeFactory<K,V>
All Implemented Interfaces:
NodeFactory<K,V>
Direct Known Subclasses:
MVCCNodeFactory, OptimisticNodeFactory, PessimisticNodeFactory

public abstract class AbstractNodeFactory<K,V>
extends Object
implements NodeFactory<K,V>

Generates new nodes based on the CacheSPI configuration.

Author:
Manik Surtani (manik AT jboss DOT org)

Field Summary
protected  CacheSPI<K,V> cache
           
protected  CommandsFactory commandsFactory
           
protected  ComponentRegistry componentRegistry
           
protected  Configuration configuration
           
protected  DataContainer dataContainer
           
protected  InterceptorChain interceptorChain
           
protected  InvocationContextContainer invocationContextContainer
           
protected  boolean useVersionedNode
           
 
Constructor Summary
AbstractNodeFactory()
           
 
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.
protected  UnversionedNode<K,V> createInternalNode(Object childName, Fqn fqn, NodeSPI<K,V> parent, Map<K,V> data)
           
 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)
           
 WorkspaceNode<K,V> createWrappedNode(NodeSPI<K,V> dataNode, TransactionWorkspace workspace)
           
 void injectDependencies(CacheSPI<K,V> cache, Configuration configuration, InvocationContextContainer invocationContextContainer, InterceptorChain interceptorChain, CommandsFactory commandsFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected CacheSPI<K,V> cache

useVersionedNode

protected boolean useVersionedNode

configuration

protected Configuration configuration

invocationContextContainer

protected InvocationContextContainer invocationContextContainer

interceptorChain

protected InterceptorChain interceptorChain

commandsFactory

protected CommandsFactory commandsFactory

componentRegistry

protected ComponentRegistry componentRegistry

dataContainer

protected DataContainer dataContainer
Constructor Detail

AbstractNodeFactory

public AbstractNodeFactory()
Method Detail

injectDependencies

public void injectDependencies(CacheSPI<K,V> cache,
                               Configuration configuration,
                               InvocationContextContainer invocationContextContainer,
                               InterceptorChain interceptorChain,
                               CommandsFactory commandsFactory)

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>
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>
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>
Returns:
a new node

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>
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>
Returns:
a new node

createInternalNode

protected UnversionedNode<K,V> createInternalNode(Object childName,
                                                  Fqn fqn,
                                                  NodeSPI<K,V> parent,
                                                  Map<K,V> data)

createWrappedNode

public WorkspaceNode<K,V> createWrappedNode(NodeSPI<K,V> dataNode,
                                            TransactionWorkspace workspace)
Specified by:
createWrappedNode in interface NodeFactory<K,V>

createWrappedNode

public ReadCommittedNode createWrappedNode(InternalNode<K,V> node,
                                           InternalNode<K,V> parent)
Specified by:
createWrappedNode in interface NodeFactory<K,V>

createRootNode

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

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>
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.