JBoss.orgCommunity Documentation
To obtain the example's complete source code please refer to Section 2.2, “Mobicents JAIN SLEE SleeConnectivity Example Source Code”.
For full descirption of XML please refer to simpler examples, like sip-wakeup
SBB descriptor is very simple. Its only purpose is to define SBB abstract class and event handler. Abstract class is defined as follows:
<sbb-name>SleeConnectivitySbb</sbb-name>
<sbb-vendor>org.mobicents</sbb-vendor>
<sbb-version>1.0</sbb-version>
<sbb-classes>
<sbb-abstract-class>
<sbb-abstract-class-name>
org.mobicents.slee.service.SleeConnectivitySbb
</sbb-abstract-class-name>
</sbb-abstract-class>
</sbb-classes>
Handler definition looks as follows:
<event event-direction="Receive" initial-event="True">
<event-name>CustomEvent</event-name>
<event-type-ref>
<event-type-name>org.mobicents.slee.service.connectivity.Event_1</event-type-name>
<event-type-vendor>org.mobicents</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
<initial-event-select variable="ActivityContext" />
</event>
JMX Client is defined by two elements: XML descriptor and POJO class.
XML descriptor is very simple. It looks as follows(jboss-beans.xml
):
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:jboss:bean-deployer:2.0">
<bean name="SleeConnectionTest"
class="org.mobicents.example.slee.connection.SleeConnectionTest">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(
name="org.mobicents.slee:name=SleeConnectivityExample",exposedInterface=
org.mobicents.example.slee.connection.SleeConnectionTestMBean.class
,registerDirectly=true)
</annotation>
</bean>
</deployment>
Descriptor has following elements present:
definition of POJO bean with human readable name and class
marks POJO as JMX exposed bean
sets value of java bean property with matching name
creates requirement - bean with name passed in this tag must be present for declared bean to be deployed
Client contract is defined by implemented interface class, that is org.mobicents.example.slee.connection.SleeConnectionTestMBean
Fires event using to JAIN SLEE container. The event will contain the specified message parameter.
Concrete implementation can be found in org.mobicents.example.slee.connection.SleeConnectionTest
class.
public void fireEvent(String messagePassed) {
// depending on deployment it does following:
// 1. lookup RA and make RMI calls through it
// 2. lookup local Bean, which makes direct calls to container!
logger.info("Attempting call to SleeConnectionFactory.");
try {
InitialContext ic = new InitialContext();
// this is call to local JNDI space, private, it cant be accessed
// from other JVM
SleeConnectionFactory factory = (SleeConnectionFactory) ic
.lookup("java:/MobicentsConnectionFactory");
SleeConnection conn1 = null;
try {
conn1 = factory.getConnection();
ExternalActivityHandle handle = conn1.createActivityHandle();
EventTypeID requestType = conn1.getEventTypeID(eventName,
eventVendor, eventVersion);
CustomEvent customEvent = new CustomEvent();
customEvent.setMessage(messagePassed);
logger.info("The event type is: " + requestType);
conn1.fireEvent(customEvent, requestType, handle, null);
} finally {
if (conn1 != null)
conn1.close();
}
} catch (Exception e) {
logger.error("Exception caught in event fire method!", e);
}
}