Chapter 3. Subscription-based notifications 109
<triglet-mapping>
<triglet-name>StockHandler Sample for WAS</triglet-name>
<url-pattern>/StockHandler</url-pattern>
</triglet-mapping>
<triglet-mapping>
<triglet-name>WeatherHandler Sample for WAS</triglet-name>
<url-pattern>/WeatherHandler</url-pattern>
</triglet-mapping>
<triglet-mapping>
<triglet-name>MonitoringHandler Sample for WAS</triglet-name>
<url-pattern>/MonitoringHandler</url-pattern>
</triglet-mapping>
</triglet-app>
Notice that the <triglet-name> parameters for the <triglet> and
<triglet-mapping> tags must match.
4. Restart the Intelligent Notification Service server.
3.5 Subscription portlet
Subscription portlets are used for Intelligent Notification Services users to
subscribe to content source notifications. The subscribers can add, edit, or
delete subscriptions using these portlets.
This section explains how to develop and deploy a subscription portlet.
3.5.1 Developing a subscription portlet
The following base classes are needed to create subscription portlets:
򐂰 Subscription base controller (SubscriptionBaseController.java), which
contains basic logic common to all subscription portlets.
򐂰 Subscription bean (SubscriptionBean.java), which stores data for the
subscription.
򐂰 Subscription manager (SubscriptionManager.java), the utility class for
managing subscriptions which the subscription manager implementation
class implements.
򐂰 Subscription manager factory (SubscriptionManagerFactory.java), which
creates subscription manager instances.
110 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
򐂰 Subscription manager implementation (SubscriptionManagerImpl.java), the
utility class for managing subscriptions which implements the subscription
manager interface.
In general, to develop a new subscription portlet, you must create the following
files:
򐂰 A class named <My_subscription>SubscriptionBaseController.class that
extends the subscription base controller class.
򐂰 A class named <My_subscription>SubscriptionBean.class that extends of
subscription bean class.
򐂰 A JavaServer Pages (JSP) file named
<My_subscription>SubscriptionConfig.jsp that is used to add or to modify a
subscription.
򐂰 A JSP file named <My_subscription>SubscriptionView.jsp that is used to list
current subscriptions.
򐂰 A JPS file named DeliveryChannelOrdering.jsp that is used to change the
delivery channels order of the subscription.
򐂰 XML files for registering the subscription portlet:
web.xml, for registering the portlet as a Web application with WebSphere
Application Server.
portlet.xml, for registering the portlet as portlet with the WebSphere Portal
Server.
To use the MonitoringNotify subscription portlet as a base to create a
subscription portlet project, follow these steps:
1. Create a Portlet Application Project.
a. Open the IBM WebSphere Studio Site Developer and select File
New
Project.
Note: The prefix <My_subscription> is the name that identifies the
subscription, for example Stocks, Weather, and so forth.
Note: The easiest way to develop a new subscription portlet is to base it in an
existing subscription portlet. We use the MonitoringNotify portlet that is
provided in this book to explain how subscription portlets work. This
subscription portlet is ready to work for the sample scenario that is defined in
this chapter. In addition, we include notes to indicate the changes you need to
make if you use the MonitoringNotify portlet as a base to develop your own
subscription portlets.
Chapter 3. Subscription-based notifications 111
b. Select Portlet Development from the left panel and Portlet Application
Project from the right panel. Click Next.
c. Enter a project name. In this example, it is MonitoringNotify. Select Create
a basic portlet as your portlet type. Click Next.
d. Set the EAR project, context root, and J2EE. Click Finish.
2. Import the MonitoringNotify.war file that is provided in this book by following
these steps:
Right-click the project that you created in the previous step.
–Select Import
WAR file. Click Next.
Select the WAR file location and the Overwrite existing resources
without warning option.
–Click Finish.
3. Into the project, go to the JavaResources directory and delete the default
package directory by right-clicking this package and selecting Delete as
shown in Figure 3-7.
Figure 3-7 Delete the default package directory
112 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
4. In the WebContent directory, delete the default JSP directory by right-clicking
this directory and selecting Delete as shown in Figure 3-8.
Figure 3-8 Delete the default JSP directory
Chapter 3. Subscription-based notifications 113
Figure 3-9 shows the subscription portlet project structure in WebSphere Studio.
Figure 3-9 Subscription portlet project structure
Subscription base controller Java class
This class controls the subscription portlet itself. In this example, this class is
named MonitoringSubscriptionBaseController and extends the
SubscriptionBaseController class.
To develop this class:
1. Import the required packages as shown in Example 3-34.
Example 3-34 Required packages for subscription base controller
import org.apache.jetspeed.portlets.*;
import org.apache.jetspeed.portlet.*;
import org.apache.jetspeed.portlet.event.*;
import com.ibm.wps.portlets.*;
Note: The subscription base controller class must reside in the package
com.ibm.pvc.we.ins.portlets.

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.