Chapter 2. Simple notifications 69
Example 2-5 getResults method and auxiliary variables
public String getResults() {
String msgID = null;
int ipriority =0;
String hostName = "wea5d.itso.ral.ibm.com";
String port = "9814";
String providerUrl = "corbaloc:iiop:" + hostName + ":" + port;
e. Create a remote Notification Manager client instance, as shown in
Example 2-6.
Example 2-6 Notification Manager client instance
NotificationService nmClient = null;
try {
Hashtable env = new Hashtable();
env.put (Context.PROVIDER_URL, providerUrl);
nmClient = NmClientFactory.createRemoteNmClient(env);
f. Create a Notification object and set up the message information and
delivery preferences, as shown in Example 2-7.
Example 2-7 Notification object
Notification notf = new Notification();
notf.addDeliveryChannel (new MessageCenterDeliveryChannel() );
notf.addDeliveryChannel (new SametimeDeliveryChannel() );
notf.addDeliveryChannel (new EmailDeliveryChannel() );
if (formPriority.equals("MSG_PRIORITY_DEFAULT"))
ipriority = Request.MSG_PRIORITY_DEFAULT;
if (formPriority.equals("MSG_PRIORITY_FYI"))
ipriority = Request.MSG_PRIORITY_FYI;
if (formPriority.equals("MSG_PRIORITY_NORMAL"))
ipriority = Request.MSG_PRIORITY_NORMAL;
if (formPriority.equals("MSG_PRIORITY_URGENT"))
ipriority = Request.MSG_PRIORITY_URGENT;
notf.setMsgPriority(ipriority);
notf.setMultiDevices(true);
notf.setTextMsgType();
if (formTo.equals("UserID"))
notf.setToUserID(formToUID);
if (formTo.equals("UserGroup"))
notf.setToGroupID(formToUID);
notf.setFromUserID(formFromUID);
notf.setSubjectText(formSubject);
notf.setMsgText(formText);