org.systinet.wasp.async
Class AsyncConversation

java.lang.Object
  extended byorg.systinet.wasp.async.AsyncConversation

public abstract class AsyncConversation
extends java.lang.Object

AsyncConversation represents client handle to asynchronous invocation. Instance of this interface is obtained by calling beginX method on given invocation level(f.e. for JAX-RPC see WaspCall). It can be used for obtaining information about state of the async communication as so as a registry for client callbacks. Typical usage is as follows:

 {
 ...
 AsyncConversation async = helloService.beginHello();
 async.setCallback(this);
 ...

 }

 public void onResponse(AsyncConversation async) {
   String resonse = helloService.endHello(async);
 }
 

Since:
4.6
Component:
Core

Constructor Summary
AsyncConversation()
           
 
Method Summary
abstract  void finish()
          Finishes asynchronous communication represented by this AsyncConversation.
abstract  long getTimeout()
          Gets the timeout for waiting for given response.
abstract  boolean isResponseReady()
          Returns information, whether response is ready on client.
abstract  void setCallback(AsyncCallback callback)
          Sets the callback, which get called once the response is ready on client.
abstract  void setTimeout(long millis)
          Sets the timeout for waiting for given response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncConversation

public AsyncConversation()
Method Detail

setCallback

public abstract void setCallback(AsyncCallback callback)
Sets the callback, which get called once the response is ready on client.

Parameters:
callback - callback implementation

isResponseReady

public abstract boolean isResponseReady()
                                 throws TimeoutException
Returns information, whether response is ready on client. When true is returned by this method, proper endX method can be called for retrieving response to client.

Returns:
true when response is ready on client, false otherwise
Throws:
TimeoutException - when response didn't come in given timeout

setTimeout

public abstract void setTimeout(long millis)
Sets the timeout for waiting for given response. This timeout is measured from beginning of asynchronous invocation. Any response coming after this time period is discarded. The default value is 10 minutes.

Parameters:
millis - timeout in milis, zero value means infinite timeout

getTimeout

public abstract long getTimeout()
Gets the timeout for waiting for given response. See setTimeout(long) for further description

Returns:
timeout in millis, zero value means infinite timeout

finish

public abstract void finish()
Finishes asynchronous communication represented by this AsyncConversation. Any further asynchronous responses are discarded. This method should be called whenever response is not awaited on client f.e. response already came and client is not awaiting any other as a part of previously started communication. Note that each asynchronous communication is discarded after timeout, which can be se using setTimeout(long). This method discards given communication immediatelly.