org.mobicents.javax.servlet.sip
Interface SipApplicationSessionExt
public interface SipApplicationSessionExt
Interface Extension that adds extra features to the JSR 289 SipApplicationSession interface.
It adds the following capabilities :
-
Allows for applications to schedule work asynchronously against a SipApplicationSession in a thread-safe manner if used in conjunction with the Mobicents Concurrency Control Mechanism
Here is some sample code to show how the asynchronous work can be used :
((SipApplicationSessionExt)sipApplicationSession).scheduleAsynchronousWork(new SipApplicationSessionAsynchronousWork() {
private static final long serialVersionUID = 1L;
public void doAsynchronousWork(SipApplicationSession sipApplicationSession) {
String textMessageToSend = (String) sipApplicationSession.getAttribute("textMessageToSend");
try {
SipServletRequest sipServletRequest = sipFactory.createRequest(
sipApplicationSession,
"MESSAGE",
"sip:sender@sip-servlets.com",
"sip:receiver@sip-servlets.com");
SipURI sipUri = sipFactory.createSipURI("receiver", "127.0.0.1:5060");
sipServletRequest.setRequestURI(sipUri);
sipServletRequest.setContentLength(content.length());
sipServletRequest.setContent(content, "text/plain;charset=UTF-8");
sipServletRequest.send();
} catch (ServletParseException e) {
logger.error("Exception occured while parsing the addresses",e);
} catch (IOException e) {
logger.error("Exception occured while sending the request",e);
}
}
});
- Since:
- 1.4
- Author:
- jean.deruelle@gmail.com
scheduleAsynchronousWork
void scheduleAsynchronousWork(SipApplicationSessionAsynchronousWork work)
- This method allows an application to access a SipApplicationSession in an asynchronous manner.
This method is useful for accessing the SipApplicationSession from Web or EJB modules in a converged application
or from unmanaged threads started by the application itself.
When this API is used in conjunction with the Mobicents Concurrency Control in SipApplicationSession mode,
the container guarantees that the business logic contained within the SipApplicationSessionAsynchronousWork
will be executed in a thread-safe manner.
It has to be noted that the work may never execute if the session gets invalidated in the meantime
and the work will be executed locally on the node on a cluster.
- Parameters:
work - the work to be performed on this SipApplicationSession.
Copyright © 2010. All Rights Reserved.