org.infinispan.commands.tx
Class AbstractTransactionBoundaryCommand

java.lang.Object
  extended by org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
All Implemented Interfaces:
CacheRpcCommand, ReplicableCommand, TransactionBoundaryCommand, VisitableCommand
Direct Known Subclasses:
CommitCommand, LockControlCommand, PrepareCommand, RollbackCommand

public abstract class AbstractTransactionBoundaryCommand
extends Object
implements TransactionBoundaryCommand

An abstract transaction boundary command that holds a reference to a GlobalTransaction

Since:
4.0
Author:
Manik Surtani (manik@jboss.org), Mircea.Markus@jboss.com

Field Summary
protected  String cacheName
           
protected  Configuration configuration
           
protected  GlobalTransaction globalTx
           
protected  InvocationContextContainer icc
           
protected  InterceptorChain invoker
           
protected  TransactionTable txTable
           
 
Constructor Summary
AbstractTransactionBoundaryCommand(String cacheName)
           
 
Method Summary
 boolean equals(Object o)
           
 String getCacheName()
           
 Configuration getConfiguration()
           
 GlobalTransaction getGlobalTransaction()
           
 Address getOrigin()
          Get the origin of the command
 Object[] getParameters()
          Used by marshallers to stream this command across a network
 int hashCode()
           
 boolean ignoreCommandOnStatus(ComponentStatus status)
          Similar to VisitableCommand.shouldInvoke(InvocationContext) but evaluated by InvocationContextInterceptor.
 void init(InterceptorChain chain, InvocationContextContainer icc, TransactionTable txTable)
           
 void injectComponents(Configuration configuration)
           
protected  Object invalidRemoteTxReturnValue()
          This is what is returned to remote callers when an invalid RemoteTransaction is encountered.
 boolean isReturnValueExpected()
          If true, a return value will be provided when performed remotely.
 void markTransactionAsRemote(boolean isRemote)
           
 Object perform(InvocationContext ctx)
          Performs the primary function of the command.
 void setOrigin(Address origin)
          Set the origin of the command
 void setParameters(int commandId, Object[] args)
          Used by the CommandsFactory to create a command from raw data read off a stream.
 boolean shouldInvoke(InvocationContext ctx)
          Used by the InboundInvocationHandler to determine whether the command should be invoked or not.
 String toString()
           
protected  void visitRemoteTransaction(RemoteTransaction tx)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.infinispan.commands.VisitableCommand
acceptVisitor
 
Methods inherited from interface org.infinispan.commands.ReplicableCommand
getCommandId
 

Field Detail

globalTx

protected GlobalTransaction globalTx

cacheName

protected final String cacheName

invoker

protected InterceptorChain invoker

icc

protected InvocationContextContainer icc

txTable

protected TransactionTable txTable

configuration

protected Configuration configuration
Constructor Detail

AbstractTransactionBoundaryCommand

public AbstractTransactionBoundaryCommand(String cacheName)
Method Detail

injectComponents

public void injectComponents(Configuration configuration)

getConfiguration

public Configuration getConfiguration()

init

public void init(InterceptorChain chain,
                 InvocationContextContainer icc,
                 TransactionTable txTable)

getCacheName

public String getCacheName()
Specified by:
getCacheName in interface CacheRpcCommand
Returns:
the name of the cache that produced this command. This will also be the name of the cache this command is intended for.

getGlobalTransaction

public GlobalTransaction getGlobalTransaction()
Specified by:
getGlobalTransaction in interface TransactionBoundaryCommand

markTransactionAsRemote

public void markTransactionAsRemote(boolean isRemote)
Specified by:
markTransactionAsRemote in interface TransactionBoundaryCommand

invalidRemoteTxReturnValue

protected Object invalidRemoteTxReturnValue()
This is what is returned to remote callers when an invalid RemoteTransaction is encountered. Can happen if a remote node propagates a transactional call to the current node, and the current node has no idea of the transaction in question. Can happen during rehashing, when ownerships are reassigned during a transactions. Returning a null usually means the transactional command succeeded.

Returns:
return value to respond to a remote caller with if the transaction context is invalid.

perform

public Object perform(InvocationContext ctx)
               throws Throwable
Description copied from interface: ReplicableCommand
Performs the primary function of the command. Please see specific implementation classes for details on what is performed as well as return types. Important: this method will be invoked at the end of interceptors chain. It should never be called directly from a custom interceptor.

Specified by:
perform in interface ReplicableCommand
Parameters:
ctx - invocation context
Returns:
arbitrary return value generated by performing this command
Throws:
Throwable - in the event of problems.

visitRemoteTransaction

protected void visitRemoteTransaction(RemoteTransaction tx)

getParameters

public Object[] getParameters()
Description copied from interface: ReplicableCommand
Used by marshallers to stream this command across a network

Specified by:
getParameters in interface ReplicableCommand
Returns:
an object array of arguments, compatible with pre-2.2.0 MethodCall args.

setParameters

public void setParameters(int commandId,
                          Object[] args)
Description copied from interface: ReplicableCommand
Used by the CommandsFactory to create a command from raw data read off a stream.

Specified by:
setParameters in interface ReplicableCommand
Parameters:
commandId - command id to set. This is usually unused but *could* be used in the event of a command having multiple IDs, such as PutKeyValueCommand.
args - object array of args

shouldInvoke

public boolean shouldInvoke(InvocationContext ctx)
Description copied from interface: VisitableCommand
Used by the InboundInvocationHandler to determine whether the command should be invoked or not.

Specified by:
shouldInvoke in interface VisitableCommand
Returns:
true if the command should be invoked, false otherwise.

ignoreCommandOnStatus

public boolean ignoreCommandOnStatus(ComponentStatus status)
Description copied from interface: VisitableCommand
Similar to VisitableCommand.shouldInvoke(InvocationContext) but evaluated by InvocationContextInterceptor. Commands can opt to be discarded in case the cache status is not suited (as InvalidateCommand)

Specified by:
ignoreCommandOnStatus in interface VisitableCommand
Returns:
true if the command should NOT be invoked.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getOrigin

public Address getOrigin()
Description copied from interface: CacheRpcCommand
Get the origin of the command

Specified by:
getOrigin in interface CacheRpcCommand
Returns:

setOrigin

public void setOrigin(Address origin)
Description copied from interface: CacheRpcCommand
Set the origin of the command

Specified by:
setOrigin in interface CacheRpcCommand

isReturnValueExpected

public boolean isReturnValueExpected()
Description copied from interface: ReplicableCommand
If true, a return value will be provided when performed remotely. Otherwise, a remote ResponseGenerator may choose to simply return null to save on marshalling costs.

Specified by:
isReturnValueExpected in interface ReplicableCommand
Returns:
true or false

-->

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