Overview of the Profile Service API Creating a Document Selector Key for Application-Managed Profile Data

Using the Profile Service API 9-5

9.6 Monitoring Profile Data with ProfileListener

The IMS Sh interface enables applications to receive automatic notifications when a subscribers profile data changes. WebLogic Server provides an easy-to-use API for managing profile data subscriptions. A SIP Servlet registers to receive notifications by implementing the com.bea.wcp.profile.ProfileListener interface, which consists of a single update method that is automatically invoked when a change occurs to profile to which the Servlet is subscribed. Notifications are not sent if that same Servlet modifies the profile information for example, if a user modifies their own profile data.

9.6.1 Prerequisites for Listener Implementations

In order to receive a call back for subscribed profile data, a SIP Servlet must do the following: ■ Implement com.bea.wcp.profile.ProfileListener. ■ Create one or more subscriptions using the subscribe method in the com.bea.wcp.profile.ProfileService helper class. ■ Register itself as a listener using the listener element in sip.xml. Implementing ProfileListener describes how to implement ProfileListener and use the susbscribe method. In addition to having a valid listener implementation, the Servlet must declare itself as a listener in the sip.xml deployment descriptor file. For example, it must add a listener element declaration similar to: listener lisener-classcom.mycompany.MyLisenerServletlistener-class listener

9.6.2 Implementing ProfileListener

Actual subscriptions are managed using the subscribe method of the com.bea.wcp.profile.ProfileService helper class. The subscribe method requires that you supply the current SipApplicationSession and the key for the profile data document you want to monitor. See Creating a Document Selector Key for Application-Managed Profile Data . Applications can cancel subscriptions by calling ProfileSubscription.cancel. Also, pending subscriptions for an application are automatically cancelled if the application session is terminated. Example 9–2 shows sample code for a Servlet that implements the ProfileListener interface. Example 9–2 Sample Servlet Implementing ProfileListener Interface package demo; import com.bea.wcp.profile.; import javax.servlet.sip.SipServletRequest; Note: In a replicated environment, Diameter relay nodes always attempt to push notifications directly to the engine tier server that subscribed for profile updates. If that engine tier server is unavailable, another server in the engine tier cluster is chosen to receive the notification. This model succeeds because session information is stored in the SIP data tier, rather than the engine tier. 9-6 Oracle WebLogic Server SIP Container Developer’s Guide import javax.servlet.sip.SipServlet; import org.w3c.dom.Document; import java.io.IOException; public class MyServlet extends SipServlet implements ProfileListener { private ProfileService psvc; public void init { psvc = ProfileService getServletContext.getAttributeProfileService.PROFILE_SERVICE; } protected void doInviteSipServletRequest req throws IOException { String docSel = sh: + req.getTo + IMSUserState; Subscribe to profile data. psvc.subscribereq.getApplicationSession, docSel, null; } public void updateProfileSubscription ps, Document document { System.out.printlnIMSUserState updated: + ps.getDocumentSelector; } } Developing Custom Profile Service Providers 10-1 10 Developing Custom Profile Service Providers This chapter describes how to use the Profile Service API to develop custom profile rovider, in the following sections: ■ Section 10.1, Overview of the Profile Service API ■ Section 10.2, Implementing Profile Service API Methods ■ Section 10.3, Configuring and Packaging Profile Providers ■ Section 10.4, Configuring Profile Providers Using the Administration Console

10.1 Overview of the Profile Service API

WebLogic Server includes a profile service API, com.bea.wcp.profile.API, that may have multiple profile service provider implementations. A profile provider performs the work of accessing XML documents from a data repository using a defined protocol. Deployed SIP Servlets and other applications need not understand the underlying protocol or the data repository in which the document is stored; they simply reference profile data using a custom URL, and WebLogic Server delegates the request processing to the correct profile provider. The provider performs the necessary protocol operations for manipulating the document. All providers work with documents in XML DOM format, so client code can work with many different types of profile data in a common way. Figure 10–1 Profile Service API and Provider Implementation Each profile provider implemented using the API may enable the following operations against profile data: