org.axonframework.commandhandling.distributed.jgroups
Class ReplyMessage

java.lang.Object
  extended by org.axonframework.commandhandling.distributed.jgroups.ReplyMessage
All Implemented Interfaces:
Externalizable, Serializable, org.jgroups.util.Streamable

public class ReplyMessage
extends Object
implements org.jgroups.util.Streamable, Externalizable

JGroups Message representing a reply to a dispatched command.

Since:
2.0
Author:
Allard Buijze
See Also:
Serialized Form

Constructor Summary
ReplyMessage()
          Default constructor required by the Streamable and Externalizable interfaces.
ReplyMessage(String commandIdentifier, Object returnValue, Throwable error, Serializer serializer)
          Constructs a message containing a reply to the command with given commandIdentifier, containing either given returnValue or error, which uses the given serializer to deserialize its contents.
 
Method Summary
 String getCommandIdentifier()
          Returns the identifier of the command for which this message is a reply.
 Throwable getError(Serializer serializer)
          Returns the error of the command processing.
 Object getReturnValue(Serializer serializer)
          Returns the returnValue of the command processing.
 boolean isSuccess()
          Whether the reply message represents a successfully executed command.
 void readExternal(ObjectInput in)
           
 void readFrom(DataInput in)
           
 void writeExternal(ObjectOutput out)
           
 void writeTo(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplyMessage

public ReplyMessage()
Default constructor required by the Streamable and Externalizable interfaces. Do not use directly.


ReplyMessage

public ReplyMessage(String commandIdentifier,
                    Object returnValue,
                    Throwable error,
                    Serializer serializer)
Constructs a message containing a reply to the command with given commandIdentifier, containing either given returnValue or error, which uses the given serializer to deserialize its contents.

Parameters:
commandIdentifier - The identifier of the command to which the message is a reply
returnValue - The return value of command process
error - The error that occuered during event processing. When provided (i.e. not null, the given returnValue is ignored.
serializer - The serializer to serialize the message contents with
Method Detail

isSuccess

public boolean isSuccess()
Whether the reply message represents a successfully executed command. In this case, successful means that the command's execution did not result in an exception.

Returns:
true if this reply contains a return value, false if it contains an error.

getReturnValue

public Object getReturnValue(Serializer serializer)
Returns the returnValue of the command processing. If isSuccess() return false, this method returns null. This method also returns null if response processing returned a null value.

Parameters:
serializer - The serializer to deserialize the result with
Returns:
The return value of command processing

getError

public Throwable getError(Serializer serializer)
Returns the error of the command processing. If isSuccess() return true, this method returns null.

Parameters:
serializer - The serializer to deserialize the result with
Returns:
The exception thrown during command processing

getCommandIdentifier

public String getCommandIdentifier()
Returns the identifier of the command for which this message is a reply.

Returns:
the identifier of the command for which this message is a reply

writeTo

public void writeTo(DataOutput out)
             throws IOException
Specified by:
writeTo in interface org.jgroups.util.Streamable
Throws:
IOException

readFrom

public void readFrom(DataInput in)
              throws IOException
Specified by:
readFrom in interface org.jgroups.util.Streamable
Throws:
IOException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Specified by:
readExternal in interface Externalizable
Throws:
IOException


Copyright © 2010-2016. All Rights Reserved.