JBoss.orgCommunity Documentation
In the last chapter we integrated the Enabler in the JAIN SLEE Service's Sbb, the Parent Sbb, in this chapter it is explained how to use the Enabler's Sbb, the Child Sbb.
Enabler performs following tasks:
send subscription events on behalf of Parent Sbb
based on values exchanged between Enabler and Server, Enabler keeps track of subscription life time(expiration) and issues refresh requests to Server
JAIN SLEE SIP Subscription Client Enabler control flow
The JBoss Communications
JAIN SLEE SIP Subscription Client
Enabler Sbb, the Child Sbb, implements the
org.mobicents.slee.enabler.sip.SubscriptionClientChildSbbLocalObject
, which extends the
javax.slee.SbbLocalObject
and
org.mobicents.slee.enabler.sip.SubscriptionClientChild
interfaces, the latter declares the methods which can be used to
interact with the SIP Event Server:
package org.mobicents.slee.enabler.sip;
public void setParentSbb(SubscriptionClientParentSbbLocalObject parent);
public String getSubscriber();
public String getEventPackage();
public String getNotifier();
public void subscribe(String subscriber, String subscriberdisplayName, String notifier,
int expires, String eventPackage, Map<String, String> eventsParameters,
String acceptedContentType, String acceptedContentSubtype) throws SubscriptionException;
public void subscribe(String subscriber, String subscriberdisplayName, String notifier,
int expires, String eventPackage, Map<String, String> eventParameters,
String acceptedContentType, String acceptedContentSubtype, String contentType,
String contentSubType, String content) throws SubscriptionException;
public void unsubscribe() throws SubscriptionException;
setParentSbb(SubscriptionClientParentLocalObject parent);
method:
Passes the Parent's SbbLocalObject, which will be used by the Child Sbb to provide async results. If not invoked after the child creation the Enabler won't be able to callback the Parent Sbb.
getSubscriber();
method:
returns subscriber used for subscription in Server.
getNotifier();
method:
returns notifier used as target for subscription.
getEventPackage();
method:
returns event package used in subscrption, ie.
presence
or
presence.winfo
public void subscribe(String subscriber, String subscriberdisplayName,
String notifier, int expires, String eventPackage, Map<String, String> eventsParameters
, String acceptedContentType, String acceptedContentSubtype) throws SubscriptionException;
method:
this method should be called to subscribe enabler to certain
document in Server, optionally user may pass
eventsParameters
. Event Parameters are sent with each SUBSCRIBE. Accepted content type arguments indicate
type of expected content generated by Presence Server.
It throws exception in case of transport error or wrong arguments.
public void subscribe(String subscriber, String subscriberdisplayName, String notifier,
int expires, String eventPackage, Map<String, String> eventParameters,
String acceptedContentType, String acceptedContentSubtype, String contentType,
String contentSubType, String content) throws SubscriptionException;
method:
this method is similar to previously defined method. In addition, this method allows to pass filter
document
in each SUBSCRIBE sent to Presence Server. This is useful, for instance in case of subscribtion to RLS service in XDM server.
Content type arguments must match type of document passed to Presence Server.
unsubscribe() throws SubscriptionException;
method:
this method should be called to explicitly unsubscribe from publication. If enabler is refreshing, when this method is called, it will throw exception.
The Child Relation in the Parent Sbb Abstract Class is used to create and retrieve the Child Sbb, it is important to not forget to pass the Parent's SbbLocalObject to the Child after creation:
public SubscriptionClientChildLocalObject getPublicationClientChildSbb() {
final ChildRelation childRelation = getSipPublicationClientChildRelation();
if (childRelation.isEmpty()) {
try {
// creates new instance
SubscriptionClientChildLocalObject sbb =
(SubscriptionClientChildLocalObject) childRelation.create();
// passes the parent sbb local object to the child
sbb.setParentSbb((SubscriptionClientParentLocalObject)
sbbContext.getSbbLocalObject());
return sbb;
} catch (Exception e) {
tracer.severe("Failed to create child sbb", e);
return null;
}
}
else {
return (SubscriptionClientChildLocalObject)
childRelation.iterator().next();
}
}
The SbbLocalObject of the Child could also be stored in a CMP Field for the simplest retrieval, but unless you are going to reuse each instance several times it's better to have less state, specially in clustered environments.
Enabler can be configured with SLEE environment entries. Currently following entries are supported:
Table 4.1. Environment entry table
Name | Type | Description |
---|---|---|
server.address |
java.lang.String |
Specifies address to which requests should be forwarded. It has form of ip:port pair. |
expires.drift |
java.lang.Integer |
Specifies time drift, in seconds, between value of Expires/Min-Expires values and automatic refresh performed by enabler. For instance if Expires value passed(and accepted by Server) is 3600, time drift set to 10, Enabler will refresh publication after 3590 |