org.jboss.cache.commands.tx
Class PrepareCommand

java.lang.Object
  extended by org.jboss.cache.commands.tx.AbstractTransactionCommand
      extended by org.jboss.cache.commands.tx.PrepareCommand
All Implemented Interfaces:
Cloneable, ReplicableCommand, VisitableCommand
Direct Known Subclasses:
OptimisticPrepareCommand

public class PrepareCommand
extends AbstractTransactionCommand

The prepare phase of a 2-phase commit, or the single prepare/commit phase of a single-phase commit.

Since:
2.2
Author:
Mircea.Markus@jboss.com

Field Summary
protected  org.jgroups.Address localAddress
           
static int METHOD_ID
           
protected  List<ReversibleCommand> modifications
           
protected  boolean onePhaseCommit
           
 
Fields inherited from class org.jboss.cache.commands.tx.AbstractTransactionCommand
globalTransaction
 
Constructor Summary
PrepareCommand()
           
PrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, org.jgroups.Address localAddress, boolean onePhaseCommit)
           
 
Method Summary
 Object acceptVisitor(InvocationContext ctx, Visitor visitor)
          Accept a visitor, and return the result of accepting this visitor.
 PrepareCommand clone()
           
 boolean containsModificationType(Class<? extends ReplicableCommand> replicableCommandClass)
           
 boolean equals(Object o)
           
 boolean existModifications()
           
 int getCommandId()
          Used by marshallers to convert this command into an id for streaming.
 org.jgroups.Address getLocalAddress()
           
 List<ReversibleCommand> getModifications()
           
 int getModificationsCount()
           
 Object[] getParameters()
          Used by marshallers to stream this command across a network
 int hashCode()
           
 boolean isOnePhaseCommit()
           
 void removeModifications(Collection<ReversibleCommand> modificationsToRemove)
           
 void setParameters(int commandId, Object[] args)
          Used by the CommandsFactory to create a command from raw data read off a stream.
 String toString()
           
 
Methods inherited from class org.jboss.cache.commands.tx.AbstractTransactionCommand
getGlobalTransaction, perform, setGlobalTransaction
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

METHOD_ID

public static final int METHOD_ID
See Also:
Constant Field Values

modifications

protected List<ReversibleCommand> modifications

localAddress

protected org.jgroups.Address localAddress

onePhaseCommit

protected boolean onePhaseCommit
Constructor Detail

PrepareCommand

public PrepareCommand(GlobalTransaction gtx,
                      List<ReversibleCommand> modifications,
                      org.jgroups.Address localAddress,
                      boolean onePhaseCommit)

PrepareCommand

public PrepareCommand()
Method Detail

removeModifications

public void removeModifications(Collection<ReversibleCommand> modificationsToRemove)

acceptVisitor

public Object acceptVisitor(InvocationContext ctx,
                            Visitor visitor)
                     throws Throwable
Description copied from interface: VisitableCommand
Accept a visitor, and return the result of accepting this visitor.

Parameters:
ctx - invocation context
visitor - visitor to accept
Returns:
arbitrary return value
Throws:
Throwable - in the event of problems

getModifications

public List<ReversibleCommand> getModifications()

getLocalAddress

public org.jgroups.Address getLocalAddress()

isOnePhaseCommit

public boolean isOnePhaseCommit()

existModifications

public boolean existModifications()

getModificationsCount

public int getModificationsCount()

getCommandId

public int getCommandId()
Description copied from interface: ReplicableCommand
Used by marshallers to convert this command into an id for streaming.

Returns:
the method id of this command. This is compatible with pre-2.2.0 MethodCall ids.

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
Overrides:
getParameters in class AbstractTransactionCommand
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
Overrides:
setParameters in class AbstractTransactionCommand
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

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractTransactionCommand

clone

public PrepareCommand clone()
                     throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

toString

public String toString()
Overrides:
toString in class AbstractTransactionCommand

containsModificationType

public boolean containsModificationType(Class<? extends ReplicableCommand> replicableCommandClass)


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