Package org.km3net.clb.remote.msg
Class Response<T>
- java.lang.Object
-
- org.km3net.clb.remote.msg.Response<T>
-
- Type Parameters:
T- the type of the repsonse.
public class Response<T> extends java.lang.ObjectEncapsulates a (delayed) response from the remote CLB board.
-
-
Field Summary
Fields Modifier and Type Field Description longcreateTimeintidstatic java.lang.ObjectNO_RESULTMessageProcessorprocessorinttypejava.lang.Objectuser
-
Constructor Summary
Constructors Constructor Description Response(MessageDecoder<T> decoder, MessageProcessor messageProcessor, int id, int type, java.lang.Object user)Create a new response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageContextcontext()Returns the message context of the response.protected ResponseExceptiondecodeError(MessageContext ctx, MessageReader mr)Decodes an error into an exceptionTget()Gets the object from the response.java.lang.ExceptiongetException()booleanhasException()booleanisCompleted()Returns whether or not the response is complete.booleanisLost()Tpoll()java.lang.ObjectpollAny()voidsetHandler(ResponseHandler<T> handler)java.lang.StringtoString()
-
-
-
Field Detail
-
NO_RESULT
public static final java.lang.Object NO_RESULT
-
processor
public final MessageProcessor processor
-
id
public final int id
-
type
public final int type
-
user
public final java.lang.Object user
-
createTime
public final long createTime
-
-
Constructor Detail
-
Response
public Response(MessageDecoder<T> decoder, MessageProcessor messageProcessor, int id, int type, java.lang.Object user)
Create a new response.- Parameters:
decoder- The decoder used to decode the message into an object or value.user- Custom user objectid- The ID of the transactionmessageProcessor- The message processor
-
-
Method Detail
-
isCompleted
public boolean isCompleted()
Returns whether or not the response is complete.- Returns:
- true - Response complete, has value, false - Response net complete
-
hasException
public boolean hasException()
-
getException
public java.lang.Exception getException()
-
isLost
public boolean isLost()
-
poll
public T poll()
-
pollAny
public java.lang.Object pollAny()
-
context
public MessageContext context()
Returns the message context of the response.
-
decodeError
protected ResponseException decodeError(MessageContext ctx, MessageReader mr)
Decodes an error into an exception- Parameters:
mr- Message reader containing the body of the message.- Returns:
- The decoded exception.
-
setHandler
public void setHandler(ResponseHandler<T> handler)
-
get
public T get() throws CommandException
Gets the object from the response. If no response has yet been received this will wait for it. It will also flush the Control's batched commands.- Returns:
- The return value.
- Throws:
ResponseException- When the command executed failed on the remote side.CommandException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-