net.rim.device.api.io.messaging
Class MessageFuture

java.lang.Object
  extended by net.rim.device.api.io.messaging.MessageFuture

public final class MessageFuture
extends Object

Provides a Future, which allows an application to send a message and receive an object as a placeholder for the reply. This allows an application to process addtional code after a Message transmission, but before blocking the execution thread. When the message response arrives, the data will populate the MessageFuture.

Invoking either get method in a MessageFuture blocks thread execution until the Message is available.

Since:
BlackBerry API 6.0.0

Method Summary
 Message get()
          Return the Message encapsulated by this object.
 Message get(long timeout)
          Returns the Message represented by this future.
 boolean isCancelled()
          Indicates whether or not the message was cancelled.
 boolean isDone()
          Indicates whether the response message was delivered.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Method Detail

isDone

public boolean isDone()
Indicates whether the response message was delivered. If this method returns true, invocation of the get method will return immmediately.

Returns:
true if MessageFuture contains a message; false otherwise.
See Also:
get
Since:
BlackBerry API 6.0.0

isCancelled

public boolean isCancelled()
Indicates whether or not the message was cancelled.

Returns:
true if the message was cancelled; false otherwise.
Since:
BlackBerry API 6.0.0

get

public Message get()
            throws MessageFailureException
Return the Message encapsulated by this object. If the message has not yet arrived, this call will block until the message arrives. If you do not wish to block, test the future first using hasResult()

Returns:
Message the Message containing the response
Throws:
MessageFailureException
See Also:
isDone
Since:
BlackBerry API 6.0.0

get

public Message get(long timeout)
            throws MessageFailureException
Returns the Message represented by this future. If the message has not arrived yet, this call will block the execution thread until the message arrives, or until the timeout is reached.

Parameters:
timeout - Maximum amount of time to wait for message to be delivered in milliseconds.
Returns:
The Message if one was delivered within the timeout; otherwise null.
Throws:
MessageFailureException
Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal