org.jboss.cache.commands.remote
Class ReplicateCommand

java.lang.Object
  extended by org.jboss.cache.commands.remote.ReplicateCommand
All Implemented Interfaces:
Cloneable, ReplicableCommand

public class ReplicateCommand
extends Object
implements ReplicableCommand

Command that implements cluster replication logic. Essentially mimics the replicate() and replicateAll() methods in 2.1.x, we may need to revisit the usefulness of such a command.

This is not a VisitableCommand and hence not passed up the CommandInterceptor chain.

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

Field Summary
static int MULTIPLE_METHOD_ID
           
static int SINGLE_METHOD_ID
           
 
Constructor Summary
ReplicateCommand()
           
ReplicateCommand(List<ReplicableCommand> modifications)
           
ReplicateCommand(ReplicableCommand command)
           
 
Method Summary
 ReplicateCommand clone()
          Clones this replicate command, but with an empty modification list.
 boolean containsCommandType(Class<? extends ReplicableCommand> aClass)
           
 boolean equals(Object o)
           
 int getCommandId()
          Used by marshallers to convert this command into an id for streaming.
 List<ReplicableCommand> getModifications()
           
 Object[] getParameters()
          Used by marshallers to stream this command across a network
 ReplicableCommand getSingleModification()
           
 int hashCode()
           
 void initialize(InterceptorChain interceptorChain)
           
 boolean isSingleCommand()
           
 Object perform(InvocationContext ctx)
          Executes commands replicated to the current cache instance by other cache instances.
 void setModifications(List<ReplicableCommand> modifications)
           
 void setParameters(int commandId, Object[] args)
          Used by the CommandsFactory to create a command from raw data read off a stream.
 void setSingleModification(ReplicableCommand singleModification)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SINGLE_METHOD_ID

public static final int SINGLE_METHOD_ID
See Also:
Constant Field Values

MULTIPLE_METHOD_ID

public static final int MULTIPLE_METHOD_ID
See Also:
Constant Field Values
Constructor Detail

ReplicateCommand

public ReplicateCommand(List<ReplicableCommand> modifications)

ReplicateCommand

public ReplicateCommand(ReplicableCommand command)

ReplicateCommand

public ReplicateCommand()
Method Detail

initialize

public void initialize(InterceptorChain interceptorChain)

setSingleModification

public void setSingleModification(ReplicableCommand singleModification)

setModifications

public void setModifications(List<ReplicableCommand> modifications)

perform

public Object perform(InvocationContext ctx)
               throws Throwable
Executes commands replicated to the current cache instance by other cache instances.

Specified by:
perform in interface ReplicableCommand
Parameters:
ctx - invocation context, ignored.
Returns:
if this is a single command being processed and it is a GravitateDataCommand, the result of processing this command is returned. Otherwise, null is returned.
Throws:
Throwable

getCommandId

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

Specified by:
getCommandId in interface ReplicableCommand
Returns:
the method id of this command. This is compatible with pre-2.2.0 MethodCall ids.

getModifications

public List<ReplicableCommand> getModifications()

getSingleModification

public ReplicableCommand getSingleModification()

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

isSingleCommand

public boolean isSingleCommand()

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

clone

public ReplicateCommand clone()
Clones this replicate command, but with an empty modification list.

Overrides:
clone in class Object
Returns:
a clone

containsCommandType

public boolean containsCommandType(Class<? extends ReplicableCommand> aClass)


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