58 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
2.1 Overview of simple notifications
Simple notifications are messages that originate from other users or applications.
The Message Center portlet provides Intelligent Notification users with a place to
send and receive simple notifications. In addition to that, Intelligent Notification
Services includes an API that lets developers build simple notification
functionality into any kind of application.
This section describes simple notifications that are implemented in the Intelligent
Notification Services component of WebSphere Everyplace Access. Figure 2-1
illustrates the basic architecture of this function where messages are sent from
other applications to users with one or more channel delivery options.
Figure 2-1 Simple notifications in Intelligent Notification Services
Simple notification applications build messages with information about the
sender, recipient, message content, and delivery preferences. These messages
are sent to the Notification Manager using CORBA/IIOP. The Notification
Manager queries the recipient’s preferences, or uses the preferences that
specified by the application, and sends out a notification that is based on those
preferences. The notification is delivered via the appropriate channel adapter to
the specified delivery channel.
Simple Notifications
Delivery
Channels
Notebook
Cellular
Phone
PDA
Voice
On
Match
Subscription
Manager
Content
Source(s)
Preferences
Subscriptions
Configurations
Preferences
Manager
Applications
Applications
Applications
Member
Services
Message
Center
Trigger
Handler
Notification
Manager
Portlets
Content
Adapter(s)
Channel
Adapters
Chapter 2. Simple notifications 59
The steps to implement a simple notification functionality in an application are:
1. Include in the Java classpath the Intelligent Notification Services JAR files
insUtil.jar and insNmClient.jar. These JAR files are located in the directory
ins_home\lib, where ins_home is in the installation directory, C:\Program
Files\WebSphere\INS.
2. Import the following packages:
javax.naming.Context
java.util.*
com.ibm.pvc.ins.nm.client.*
com.ibm.pvc.ins.nm.server.Request
com.ibm.pvc.ins.nm.server.NotificationService
3. Create a Notification Manager client instance.
The NmClientFactory class allows you to create a local Enterprise JavaBean
(EJB) or a remote EJB for the Notification Manager client instance. You must
specify a context provider URL to create this instance. By default, it is
corbaloc:iiop:localhost:2809. However, it is possible to specify an alternate
context provider URL.
The context provider URL is specified in the XML file insBaseConfig.xml that
is located in ins_home\config\xml, where ins_home is the Intelligent
Notification Services home installation directory (for example C:\Program
Files\WebSphere\INS).
The available methods to create a Notification Manager client instance are:
createLocalNmClient(): creates a local instance using default initial
context provider URL of corbaloc:iiop:localhost:2809
createLocalNmClient(java.util.Hashtable): creates a local instance using
context provider URL specified.
createRemoteNmClient(): creates a remote instance using default initial
context provider URL of corbaloc:iiop:localhost:2809
createRemoteNmClient(java.util.Hashtable): creates a remote instance
using context provider URL specified.
4. Create a notification object, which is necessary to build the message.
Note: The imported Intelligent Notification Services packages are part of
the ins_home\lib\insNmClient.jar file, where ins_home is the Intelligent
Notification Services home installation directory (for example C:\Program
Files\WebSphere\INS).
60 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
5. Set up the sender, recipient, message contents, and delivery preferences into
the notification object.
Some of the most important and available methods are:
addDeliveryChannel (Delivery Channel): adds the specified delivery
channel to the list of channels notification through which messages are
delivered.
addDeliveryChannel(java.lang.String): adds the specified delivery channel
to the list of channels notification through which messages are delivered.
The parameter specifies either the delivery channel name
(“dcname#name”) or protocol type (“type”).
setBinaryMsgType(): sets the message content type to binary.
setMultiDevices(boolean): specifies whether the message is delivered to
all of the recipients through available delivery channels or if the message
is delivered to each of the recipients delivery channels in order, until
delivery is successful.
setTextMsgType(): sets the message content type to text.
setFromUserID(java.lang.String): sets the user ID of the message sender.
setMsgPriority(int): sets the priority of the message.
setMsgText(java.lang.String): sets the text of the message.
setSubjectText(java.lang.String): sets the subject of the message.
setToGroupID(java.lang.String): sets the group ID of the message
recipients.
setToUserID(java.lang.String): sets the user ID of the message recipient.
6. Pass the message to the Notification Manager.
The sendMessage(Notification) method delivers a notification to the
Notification Manager. This method belongs to the NotificationService
interface and the NotificationServiceLocal interface, depending the kind of
Notification Manager client instance created (local or remote).
Note: For more information about Intelligent Notification Services classes and
methods, refer to the Javadoc documentation in
ins_home\javadoc\insjavadoc.jar, where ins_home is the Intelligent
Notification Services home installation directory (for example C:\Program
Files\WebSphere\INS).

Get IBM WebSphere Everyplace Access V5 Handbook for Developers and Administrators Volume IV: Advanced Topics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.