JBoss.orgCommunity Documentation
Diameter Sh-Server Resource Adaptor Type is defined by Mobicents team as part of effort to standardize RA Types.
Diameter Sh-Server Type 2.2.1.FINAL defines the following Activities:
This type of activity represents server side of Sh session. User-Data-Request (UDR), Profile-Update-Request (PUR) and Subscribe-Notifications-Request (SNR) are received in this Activity and respective Answers are sent from it.
This activity type can only be created implicitly by the Resource Adaptor when receiving the above mentioned Requests. It ends once underlying Sh server session ends.
This activity sessions are simple Request-Answer sessions, meaning that once the Answer is sent or received it is terminated.
This type of activity represents a subscription to User Data notifications for Sh session, based on User Identity. Push-Notification-Request (PNR) can be created and sent in this Activity, receiving the respective Answer (or timeout) later on this Activity.
This activity type can be created with call to the createShServerNotificationActivity
method of net.java.slee.resource.diameter.sh.server.ShServerProvider
. It ends once SNR with UNSUBSCRIBE as Subs-Req-Type for the affecte User Identity is received.
All activities define methods required to properly function and expose necessary information to JAIN SLEE services. Sh Server Activity is defined as follows:
public UserDataAnswer createUserDataAnswer(byte[] userData);
public UserDataAnswer createUserDataAnswer(long resultCode,
boolean isExperimentalResult);
public UserDataAnswer createUserDataAnswer();
public ProfileUpdateAnswer createProfileUpdateAnswer(long resultCode,
boolean isExperimentalResult);
public ProfileUpdateAnswer createProfileUpdateAnswer();
public SubscribeNotificationsAnswer createSubscribeNotificationsAnswer();
public SubscribeNotificationsAnswer createSubscribeNotificationsAnswer(long resultCode,
boolean isExperimentalResult);
public void sendUserDataAnswer(UserDataAnswer message) throws IOException;
public void sendProfileUpdateAnswer(ProfileUpdateAnswer message) throws IOException;
public void sendSubscribeNotificationsAnswer(SubscribeNotificationsAnswer message)
throws IOException;
This method creates a UserDataAnswer using the given parameter to populate the User-Data AVP. The Result-Code AVP is automatically set to SUCCESS. If there is no request of this type received, this method returns null.
This method creates a UserDataAnswer containing a Result-Code or Experimental-Result AVP populated with the given value. If isExperimentalResultCode
is true
, the resultCode
parameter will be set as ExperimentalResultAvp
AVP, if it is false
the result code will be set in a Result-Code AVP. If there is no request of this type received, this method returns null.
This method creates an empty UserDataAnswer that will need to have AVPs set on it before being sent.If there is no request of this type received, this method returns null.
This method creates a ProfileUpdateAnswer containing a Result-Code or Experimental-Result AVP populated with the given value. If isExperimentalResultCode
is true
, the resultCode
parameter will be set in a ExperimentalResultAvp
AVP, if it is false
the result code will be set in a Result-Code AVP.If there is no request of this type received, this method returns null.
This method creates an empty ProfileUpdateAnswer that will need to have AVPs set on it before being sent.If there is no request of this type received, this method returns null.
This method creates an empty SubscribeNotificationsAnswer that will need to have AVPs set on it before being sent.If there is no request of this type received, this method returns null.
This method creates a SubscribeNotificationsAnswer containing a Result-Code or Experimental-Result AVP populated with the given value. If there is no request of this type received, this method returns null.
This method sends a UserDataAnswer to the peer that sent the UserDataRequest.
This method sends a ProfileUpdateAnswer to the peer that sent the ProfileUpdateRequest.
This method sends a SubscribeNotificationsAnswer to the peer that sent the SubscribeNotificationsRequest.
Sh Server Notification Activity is defined as follows:
public ShServerMessageFactory getServerMessageFactory();
public void sendPushNotificationRequest(PushNotificationRequest message)
throws IOException;
This method returns a 'customized' message factory to manually create Sh Server Messages for this Activity.
This method sends a Push-Notification-Request asynchronously.
It is safe to type cast all the mentioned Diameter Activities to it's super interface net.java.slee.resource.diameter.base.DiameterActivity
defined in Diameter Base Activities section.
Diameter Sh-Server Resource Adaptor Type declares all the Diameter Sh messages related to server operations.
The following tables shows which events are fired on each activity.
Table 2.1. Events received on Sh Server Activity
Name | Vendor | Version | Class |
---|---|---|---|
net.java.slee.resource. diameter.sh.events. UserDataRequest | java.net | 0.8 | net.java.slee.resource. diameter.sh.events. UserDataRequest |
net.java.slee.resource. diameter.sh.events. ProfileUpdateRequest | java.net | 0.8 | net.java.slee.resource. diameter.sh.events. ProfileUpdateRequest |
net.java.slee.resource. diameter.sh.events. SubscribeNotificationsRequest | java.net | 0.8 | net.java.slee.resource. diameter.sh.events. SubscribeNotificationsRequest |
Table 2.2. Events received on Sh Server Notification Activity
Name | Vendor | Version | Class |
---|---|---|---|
net.java.slee.resource. diameter.sh.events. PushNotificationAnswer | java.net | 0.8 | net.java.slee.resource. diameter.sh.events. PushNotificationAnswer |
Spaces where introduced in Name
and Event Class
column values, to correctly render the table. Please remove them when using copy/paste.
The JBoss Communications Diameter Sh-Server Activity Context Interface Factory is defined as follows:
package net.java.slee.resource.diameter.sh.server;
import javax.slee.ActivityContextInterface;
import javax.slee.UnrecognizedActivityException;
public interface ShServerActivityContextInterfaceFactory {
ActivityContextInterface getActivityContextInterface(ShServerActivity activity)
throws UnrecognizedActivityException;
ActivityContextInterface getActivityContextInterface(ShServerSubscriptionActivity activity)
throws UnrecognizedActivityException;
}
The JBoss Communications Diameter Sh-Server Resource Adaptor SBB Interface provides SBBs with access to the Diameter objects required for creating and sending messages. It is defined as follows:
package net.java.slee.resource.diameter.sh.server;
import java.io.IOException;
import net.java.slee.resource.diameter.base.events.avp.DiameterIdentity;
import net.java.slee.resource.diameter.sh.DiameterShAvpFactory;
import net.java.slee.resource.diameter.sh.events.PushNotificationAnswer;
import net.java.slee.resource.diameter.sh.events.PushNotificationRequest;
public interface ShServerProvider {
public ShServerMessageFactory getServerMessageFactory();
public DiameterShAvpFactory getServerAvpFactory();
public ShServerNotificationActivity createShServerNotificationActivity()
throws CreateActivityException;
public PushNotificationAnswer pushNotificationRequest(PushNotificationRequest message)
throws IOException;
public DiameterIdentity[] getConnectedPeers();
public int getPeerCount();
}
This method returns a ShServerMessageFactory
implementation to be used to create DiameterMessage
objects.
This method returns a DiameterShAvpFactory
implementation to be used to create DiameterAvp
objects.
This method creates a new Sh Server Activity to send and receive notification related Diameter Sh messages.
This method sends a synchronous PushNotificationRequest which will block until an answer is received from the peer.
This method returns the identities of peers this Diameter resource adaptor is connected to.
This method returns the number of peers this Diameter resource adaptor is connected to.
Simple Server-Side Example that receives an User-Data-Request and sends an User-Data-Answer.
/* Method for receiving UDR and sending UDA with SUCCESS (code 2001) Result-Code. */
public void onUserDataRequest(UserDataRequest event, ActivityContextInterface aci) {
if (tracer.isInfoEnabled()) {
tracer.info("Received UDR:\r\n" + event);
}
UserDataAnswer answer = ((ShServerActivity) aci.getActivity()).
createUserDataAnswer(2001, false);
try {
if (tracer.isInfoEnabled()) {
tracer.info("Created UDA:\r\n" + answer);
}
((ShServerActivity) aci.getActivity()).sendUserDataAnswer(answer);
}
catch (IOException e) {
tracer.severe("Failed to send UDA.", e);
}
}
Simple Server-Side Example that sends an Push-Notification-Request and receives an Push-Notification-Answer.
/* Method for handling timer event where a PNR created and sent */
public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) {
ShServerNotificationActivity activity = null;
for (ActivityContextInterface _aci : this.getSbbContext().getActivities()) {
if (_aci.getActivity() instanceof ShServerNotificationActivity) {
activity = (ShServerNotificationActivity) _aci.getActivity();
break;
}
}
if (activity == null) {
tracer.severe("Activity is null, with list: " + Arrays.toString(this.getSbbContext().
getActivities()));
return;
}
PushNotificationRequest request = activity.createPushNotificationRequest();
tracer.info("Created PNR:\r\n" + request);
try {
UserIdentityAvp ui = avpFactory.createUserIdentity();
ui.setPublicIdentity("sip:user@diameter.mobicents.org");
request.setUserIdentity(ui);
request.setUserData("<xml>Some secrete user xml</xml>");
if(tracer.isInfoEnabled()) {
tracer.info("Sending PNR:\r\n" + request);
}
activity.sendPushNotificationRequest(request);
}
catch (Exception e) {
tracer.severe("Failed to send PNR.", e);
}
}
...
/* Method for handling PNA messages. Just print the Result-Code AVP. */
public void onPushNotificationAnswer(PushNotificationAnswer pna,
ActivityContextInterface aci) {
if (tracer.isInfoEnabled()) {
tracer.info("Push-Notification-Answer received. Result-Code[" + pna.getResultCode() + "].");
}
}