org.jboss.dna.connector.jbosscache
Class JBossCacheConnection

java.lang.Object
  extended by org.jboss.dna.connector.jbosscache.JBossCacheConnection
All Implemented Interfaces:
org.jboss.dna.graph.connectors.RepositoryConnection

public class JBossCacheConnection
extends Object
implements org.jboss.dna.graph.connectors.RepositoryConnection

The repository connection to a JBoss Cache instance.

Author:
Randall Hauch

Nested Class Summary
protected  class JBossCacheConnection.Executor
           
 
Field Summary
protected static org.jboss.dna.graph.connectors.RepositorySourceListener NO_OP_LISTENER
           
 
Method Summary
protected  void changeNodeName(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> parent, org.jboss.dna.graph.properties.Path.Segment existing, org.jboss.dna.graph.properties.Path.Segment newSegment, org.jboss.dna.graph.ExecutionContext context)
          Changes the name of the node in the cache (but does not update the list of child segments stored on the parent).
protected  boolean checkChildren(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> parent)
           
 void close()
          
protected  int copyNode(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> original, org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> newParent, boolean recursive, org.jboss.dna.graph.properties.Name uuidProperty, org.jboss.dna.graph.ExecutionContext context)
           
 void execute(org.jboss.dna.graph.ExecutionContext context, org.jboss.dna.graph.commands.GraphCommand... commands)
          
protected  UUID generateUuid()
           
 org.jboss.dna.graph.cache.CachePolicy getDefaultCachePolicy()
          
protected  org.jboss.cache.Fqn<?> getFullyQualifiedName(org.jboss.dna.graph.properties.Path.Segment pathSegment)
          Get a relative fully-qualified name that consists only of the supplied segment.
protected  org.jboss.cache.Fqn<?> getFullyQualifiedName(org.jboss.dna.graph.properties.Path path)
           
protected  org.jboss.dna.graph.connectors.RepositorySourceListener getListener()
           
protected  org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> getNode(org.jboss.dna.graph.ExecutionContext context, org.jboss.dna.graph.properties.Path path)
           
protected  org.jboss.dna.graph.properties.Path getPath(org.jboss.dna.graph.properties.PathFactory factory, org.jboss.cache.Fqn<?> fqn)
           
 String getSourceName()
          
protected  org.jboss.dna.graph.properties.Name getUuidPropertyName(org.jboss.dna.graph.ExecutionContext context)
          Utility method to calculate (if required) and obtain the name that should be used to store the UUID values for each node.
 XAResource getXAResource()
          
 boolean ping(long time, TimeUnit unit)
          
 void setListener(org.jboss.dna.graph.connectors.RepositorySourceListener listener)
          
protected  org.jboss.dna.graph.properties.Path.Segment updateChildList(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> parent, org.jboss.dna.graph.properties.Name changedName, org.jboss.dna.graph.ExecutionContext context, boolean addChildWithName)
          Update (or create) the array of path segments for the children of the supplied node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_OP_LISTENER

protected static final org.jboss.dna.graph.connectors.RepositorySourceListener NO_OP_LISTENER
Method Detail

getSourceName

public String getSourceName()

Specified by:
getSourceName in interface org.jboss.dna.graph.connectors.RepositoryConnection

getDefaultCachePolicy

public org.jboss.dna.graph.cache.CachePolicy getDefaultCachePolicy()

Specified by:
getDefaultCachePolicy in interface org.jboss.dna.graph.connectors.RepositoryConnection

getXAResource

public XAResource getXAResource()

Specified by:
getXAResource in interface org.jboss.dna.graph.connectors.RepositoryConnection

ping

public boolean ping(long time,
                    TimeUnit unit)

Specified by:
ping in interface org.jboss.dna.graph.connectors.RepositoryConnection

setListener

public void setListener(org.jboss.dna.graph.connectors.RepositorySourceListener listener)

Specified by:
setListener in interface org.jboss.dna.graph.connectors.RepositoryConnection

close

public void close()

Specified by:
close in interface org.jboss.dna.graph.connectors.RepositoryConnection

execute

public void execute(org.jboss.dna.graph.ExecutionContext context,
                    org.jboss.dna.graph.commands.GraphCommand... commands)
             throws org.jboss.dna.graph.connectors.RepositorySourceException

Specified by:
execute in interface org.jboss.dna.graph.connectors.RepositoryConnection
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException

getListener

protected org.jboss.dna.graph.connectors.RepositorySourceListener getListener()
Returns:
listener

getUuidPropertyName

protected org.jboss.dna.graph.properties.Name getUuidPropertyName(org.jboss.dna.graph.ExecutionContext context)
Utility method to calculate (if required) and obtain the name that should be used to store the UUID values for each node. This method may be called without regard to synchronization, since it should return the same value if it happens to be called concurrently while not yet initialized.

Parameters:
context - the execution context
Returns:
the name, or null if the UUID should not be stored

getFullyQualifiedName

protected org.jboss.cache.Fqn<?> getFullyQualifiedName(org.jboss.dna.graph.properties.Path path)

getFullyQualifiedName

protected org.jboss.cache.Fqn<?> getFullyQualifiedName(org.jboss.dna.graph.properties.Path.Segment pathSegment)
Get a relative fully-qualified name that consists only of the supplied segment.

Parameters:
pathSegment - the segment from which the fully qualified name is to be created
Returns:
the relative fully-qualified name

getPath

protected org.jboss.dna.graph.properties.Path getPath(org.jboss.dna.graph.properties.PathFactory factory,
                                                      org.jboss.cache.Fqn<?> fqn)

getNode

protected org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> getNode(org.jboss.dna.graph.ExecutionContext context,
                                                                                   org.jboss.dna.graph.properties.Path path)

generateUuid

protected UUID generateUuid()

copyNode

protected int copyNode(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> original,
                       org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> newParent,
                       boolean recursive,
                       org.jboss.dna.graph.properties.Name uuidProperty,
                       org.jboss.dna.graph.ExecutionContext context)

updateChildList

protected org.jboss.dna.graph.properties.Path.Segment updateChildList(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> parent,
                                                                      org.jboss.dna.graph.properties.Name changedName,
                                                                      org.jboss.dna.graph.ExecutionContext context,
                                                                      boolean addChildWithName)
Update (or create) the array of path segments for the children of the supplied node. This array maintains the ordered list of children (since the Cache does not maintain the order). Invoking this method will change any existing children that a name part that matches the supplied changedName to have the appropriate same-name sibling index.

Parameters:
parent - the parent node; may not be null
changedName - the name that should be compared to the existing node siblings to determine whether the same-name sibling indexes should be updated; may not be null
context - the execution context; may not be null
addChildWithName - true if a new child with the supplied name is to be added to the children (but which does not yet exist in the node's children)
Returns:
the path segment for the new child, or null if addChildWithName was false

checkChildren

protected boolean checkChildren(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> parent)

changeNodeName

protected void changeNodeName(org.jboss.cache.Node<org.jboss.dna.graph.properties.Name,Object> parent,
                              org.jboss.dna.graph.properties.Path.Segment existing,
                              org.jboss.dna.graph.properties.Path.Segment newSegment,
                              org.jboss.dna.graph.ExecutionContext context)
Changes the name of the node in the cache (but does not update the list of child segments stored on the parent).

Parameters:
parent -
existing -
newSegment -
context -


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