net.tomp2p.futures
Class FutureData
java.lang.Object
net.tomp2p.futures.BaseFutureImpl
net.tomp2p.futures.FutureResponse
net.tomp2p.futures.FutureData
- All Implemented Interfaces:
- BaseFuture, Cancellable
public class FutureData
- extends FutureResponse
FutureData is used as the future object for direct DHT operations. Its adds
more logic that the generic FutureResponse
, such as converting the
received buffer to an object.
- Author:
- Thomas Bocek
Constructor Summary |
FutureData(Message requestMessage,
boolean raw)
Creates the request message for raw data. |
Method Summary |
org.jboss.netty.buffer.ChannelBuffer |
getBuffer()
Returns the raw buffer or null if the answer was empty. |
Object |
getObject()
Returns the object or null if the underlying buffer was raw or the answer
was empty. |
Message |
getResponse()
Returns the response message. |
void |
setResponse(Message responseMessage)
Gets called if a peer responds. |
Methods inherited from class net.tomp2p.futures.BaseFutureImpl |
addCancellation, addListener, await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, getFailedReason, getType, isCompleted, isFailed, isSuccess, notifyListerenrs, removeCancellation, removeListener, setCompletedAndNotify, setFailed, setFailed |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FutureData
public FutureData(Message requestMessage,
boolean raw)
- Creates the request message for raw data. Note that the response might
have a null payload. This is ok since a response might be empty and only
send an ack that the message has arrived.
- Parameters:
requestMessage
- The message that was sent to the remode peer
setResponse
public void setResponse(Message responseMessage)
- Description copied from class:
FutureResponse
- Gets called if a peer responds. Note that either this method or
responseFailed() is always called. This does not notify any listeners.
The listeners gets notified if channel is closed
- Overrides:
setResponse
in class FutureResponse
getBuffer
public org.jboss.netty.buffer.ChannelBuffer getBuffer()
- Returns the raw buffer or null if the answer was empty.
- Returns:
- The transferred buffer
getObject
public Object getObject()
- Returns the object or null if the underlying buffer was raw or the answer
was empty.
- Returns:
- The transferred object
getResponse
public Message getResponse()
- Returns the response message. This is the same message as in
response(Message message). If no response where send, then this will
return null.
- Overrides:
getResponse
in class FutureResponse
- Returns:
- The successful response message or null if failed
Copyright © 2012. All Rights Reserved.