Package com.ibm.websphere.sip
Class AsynchronousWork
- java.lang.Object
-
- com.ibm.websphere.sip.AsynchronousWork
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class AsynchronousWork extends java.lang.Object implements java.io.Serializable
TheAsynchronousWork
is an abstract class that should be overridden by an application that is interested in using asynchronous invocation of code. The propose of using such invocation would be for 2 reasons 1. The application code is executed on a certain server in a cluster while the SIP Application Session location it is referring to is unknown and might be residing on a different server in the cluster. Using this API will make sure the code is executed on the correct server. 2. SIP Container APIs are being accessed from a non-SIP container thread. This can happen if the code is not executed from a SIP servlet or any other SIP 1.0 or 1.1 API listener methods. In this case WebSphere Application Server will need this code to be executed using an extension to this AsynchronousWork, so that the code will be executed from a SIP container thread and by that eliminate the need for synchronization or other locking mechanisms on the related SIP Application Session elements.An application that extends this class should implement
doAsyncTask
abstract method that returns aSerializable
object. When an application needs to run an asynchronous work, it creates aAsynchronousWork
object providing the appSessionId to which the work relates, and callsdispatch
method with aAsynchronousWorkListener
(optional). This listener will receive a response when the work is completed.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AsynchronousWork(java.lang.String appSessionId)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
dispatch(AsynchronousWorkListener listener)
The application should call this method to dispatch the message to the right server or thread that will execute the asynchronous work task.abstract java.io.Serializable
doAsyncTask()
This abstract method should be overridden by an application with the work it wishes to invoke asynchorounously.java.lang.Object
waitForResponse(long time)
Wait until the response is received, this method will cause the current thread to be locked until the async work task is finished The application should use it if it wishes to wait until the async work is finished
-
-
-
Method Detail
-
dispatch
public final void dispatch(AsynchronousWorkListener listener)
The application should call this method to dispatch the message to the right server or thread that will execute the asynchronous work task.- Parameters:
listener
- AsynchronousWorkListener object to receive notification when the work is done.
-
waitForResponse
public final java.lang.Object waitForResponse(long time)
Wait until the response is received, this method will cause the current thread to be locked until the async work task is finished The application should use it if it wishes to wait until the async work is finished- Parameters:
time
- - the maximum time to wait in milliseconds, 0 is for waiting forever- Returns:
- Object - the result of the async task or null if it was not finished yet
-
doAsyncTask
public abstract java.io.Serializable doAsyncTask()
This abstract method should be overridden by an application with the work it wishes to invoke asynchorounously. Note: The SIP signaling code that will be implemented in this method must relate only to the SipApplicationSession which ID was passed to the constructor and not to any other SipApplicationSession. Meaning that only the state of the related SIP dialogs (represented by that SipApplicationSession SipSessions) and their timers or attributes can be modified here.- Returns:
- Serializable object that will pass to the AsynchronousWorkListener. If the return value is null, then the listener, if exists, will not be invoked.
-
-