SLEE applications must declare the event types that they want to receive.

Events may be fired by RAs, the SLEE, or other applications. Servlet and listener classes can use annotations to designate certain methods as event handler methods, and the SLEE takes care of routing events to those methods.

For example:

import com.opencloud.sipservlet.slee.*;
import javax.slee.annotations.*;
import javax.servlet.sip.*;

@SleeListener
public class MyServlet extends SipServlet {

    @EventMethod(eventType = @ComponentId(name = "com.opencloud.slee.resources.http.HttpResponse", vendor = "OpenCloud", version = "2.2"))
    public void onHttpResponse(HttpResponse response, ActivityContextInterface aci, SipApplicationSession appSession) {
        log("servlet received HTTP response: " + response);
    }
}

Here a servlet class is declaring that it wants to receive a SLEE event.

@SleeListener

This annotation marks those classes in the application that may receive SLEE events. Servlet and Listener classes may use this annotation.

@EventMethod

Marks an event handler method. The SLEE invokes this method when a matching event is received.

eventType = @ComponentId(name = "...", vendor = "...", version = "...")

Like other SLEE components, event types are identified by name, vendor, and version.

Event handler methods

As well as the @EventMethod annotation, event handler methods must have a particular signature.

  • They must be public, not-static methods that return void.

  • The method name must be on <event-name>. The event name must be a unique name within the servlet application.

  • The first parameter is the event object. The parameter type is defined by the SLEE event type’s definition, usually part of the RA type definition.

  • The second parameter is the ACI of the activity that the event was fired on.

  • The last parameter is the SipApplicationSession instance that is processing the event.

The event handler method can process the event just like a SLEE SBB event handler method. The activity object associated with the event can be obtained using ActivityContextInterface.getActivity() on the ACI passed to the event handler method.

Initial events

SIP servlet application instances are typically created when a new initial SIP request arrives, which is not associated with any existing SipSession. A new SipSession and SipApplicationSession are created to process the request, and the SipApplicationSession will hold any state for the new application instance.

It is also possible to trigger a new application instance using events from other SLEE RAs. To do this, the application must declare that one or more event types are initial events. This is done by adding the initialEvent=true attribute to an @EventMethod annotation:

@EventMethod(eventType = @ComponentId(name = "com.opencloud.slee.resources.http.HttpRequest.GET", vendor = "OpenCloud", version = "2.2"), initialEvent = true)
public void onHttpRequest(HttpRequest request, ActivityContextInterface aci, SipApplicationSession appSession) {
    log("servlet received HTTP request: " + request);
}

Here this means that an HTTP GET request will create a new SipApplicationSession instance. It could then initiate a new SipSession with another SIP device, to implement a "click-to-dial" service.

Initial events can also enable converged applications.

Previous page Next page