JBoss.orgCommunity Documentation

Chapter 4. Source Code Overview

4.1. Service Descriptor
4.2. The Root SBB
4.2.1. The Root SBB Abstract Class
4.2.2. Root SBB XML Descriptor

The example application is defined by a service descriptor, which refers the Root SBB. The Root SBB does not defines child relations, which means the application is a single SBB.

Important

To obtain the example's complete source code please refer to Section 2.2, “Mobicents JAIN SLEE SIP UAS Example Source Code”.

The service descriptor is plain simple, it just defines the service ID, the ID of the root SBB and its default priority. The complete XML is:



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE service-xml PUBLIC 
    "-//Sun Microsystems, Inc.//DTD JAIN SLEE Service 1.1//EN"
    "http://java.sun.com/dtd/slee-service-xml_1_1.dtd">
<service-xml>
    <service>
        <service-name>SIP UAS</service-name>
        <service-vendor>org.mobicents</service-vendor>
        <service-version>1.0</service-version>
        <root-sbb>
            <sbb-name>SIP UAS</sbb-name>
            <sbb-vendor>org.mobicents</sbb-vendor>
            <sbb-version>1.0</sbb-version>
        </root-sbb>
        <default-priority>0</default-priority>
    </service>
</service-xml>
        
        

The SIP UAS Example's Root SBB is composed by the abstract class and the XML descriptor.

The class org.mobicents.slee.example.sip.SipUASExampleSbb includes all the service logic for the example.

The SIP INVITE is the starting point of each instance of the service logic, its responsibility is:

The event handler code:



        // Initial request
public void onInviteEvent(RequestEvent event, ActivityContextInterface aci) {
    final SbbLocalObject sbbLocalObject = this.sbbContext
            .getSbbLocalObject();
    aci.detach(sbbLocalObject);
    final ServerTransaction serverTransaction = requestEvent
            .getServerTransaction();
    try {
        // create dialog and attach this entity to it's aci
        final DialogActivity dialog = (DialogActivity) sleeSipProvider
                .getNewDialog(serverTransaction);
        final ActivityContextInterfaceExt dialogAci =
             (ActivityContextInterfaceExt) sipActivityContextInterfaceFactory
                .getActivityContextInterface(dialog);
        dialogAci.attach(sbbLocalObject);
        // set timer of 60 secs on the dialog aci
        timerFacility.setTimer(dialogAci, null,
                System.currentTimeMillis() + 60000L, getTimerOptions());
        // send 180
        Response response = messageFactory.createResponse(Response.RINGING,
                requestEvent.getRequest());
        response.addHeader(getContactHeader());
        serverTransaction.sendResponse(response);
        // send 200 ok
        response = messageFactory.createResponse(Response.OK, requestEvent
                .getRequest());
        response.addHeader(getContactHeader());
        serverTransaction.sendResponse(response);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
                
                

The Root SBB XML Descriptor has to be provided and match the abstract class code.

First relevant part is the declaration of the sbb-classes element, where the sbb class abstract name must be specified:



        <sbb-classes>
            <sbb-abstract-class reentrant="True">
                <sbb-abstract-class-name>org.mobicents.slee.example.sip.SipUASExampleSbb</sbb-abstract-class-name>
            </sbb-abstract-class>
        </sbb-classes>
            
            

Then the events handled by the SBB must be specified too:



        <event event-direction="Receive" initial-event="True">
            <event-name>ServiceStartedEvent</event-name>
            <event-type-ref>
                <event-type-name>
                    javax.slee.serviceactivity.ServiceStartedEvent
            </event-type-name>
                <event-type-vendor>javax.slee</event-type-vendor>
                <event-type-version>1.1</event-type-version>
            </event-type-ref>
            <initial-event-select variable="ActivityContext" />
        </event>
                
        <event event-direction="Receive" initial-event="True">
            <event-name>InviteEvent</event-name>
            <event-type-ref>
                <event-type-name>javax.sip.message.Request.INVITE</event-type-name>
                <event-type-vendor>net.java.slee</event-type-vendor>
                <event-type-version>1.2</event-type-version>
            </event-type-ref>
            <initial-event-select variable="ActivityContext"/>
        </event>
         
        <event event-direction="Receive" initial-event="False">
            <event-name>TimerEvent</event-name>
            <event-type-ref>
                <event-type-name>javax.slee.facilities.TimerEvent</event-type-name>
                <event-type-vendor>javax.slee</event-type-vendor>
                <event-type-version>1.0</event-type-version>
            </event-type-ref>
        </event>
            
            

Note that there is a single event defined as initial, which triggers the sbb logic, remaining events all happen in activities that the service instance is already attached, abstracting the application from calculating which session it handles.

Finally, the SIP11 Resource Adaptor must be specified also, otherwise SLEE won't put its SBB Interface in the SBB's JNDI Context:



        <resource-adaptor-type-binding>
            <resource-adaptor-type-ref>
                <resource-adaptor-type-name>
                    JAIN SIP
                </resource-adaptor-type-name>
                <resource-adaptor-type-vendor>
                    javax.sip
                </resource-adaptor-type-vendor>
                <resource-adaptor-type-version>
                    1.2
                </resource-adaptor-type-version>
            </resource-adaptor-type-ref>
            <activity-context-interface-factory-name>
                slee/resources/jainsip/1.2/acifactory
            </activity-context-interface-factory-name>
            <resource-adaptor-entity-binding>
                <resource-adaptor-object-name>
                    slee/resources/jainsip/1.2/provider
                </resource-adaptor-object-name>
                <resource-adaptor-entity-link>
                    SipRA
                </resource-adaptor-entity-link>
            </resource-adaptor-entity-binding>
        </resource-adaptor-type-binding>