Java Reference
In-Depth Information
emulator is installed on the same machine as the JSP container the URL to
start the system is http://localhost:8080/UbiMail .
16.6
Prototype 4: Mail notification
This prototype adds a new functionality to the UbiMail system: the notifi-
cation of new messages via GSM Short Message Service (SMS).
16.6.1
Analysis
The UbiMail system must be able to notify users of the arrival of new email
messages. The notification must be asynchronous, i.e. without the explicit
intervention of the user.
When a new message arrives for a registered user, the UbiMail system
sends an SMS message to the user mobile phone. This service is available on
the GSM network. The user must provide the number of the mobile phone
that will receive the notification messages.
Since the SMS messages have a cost, to keep the overall expense of notifi-
cation as low as possible it is important to allow the user to select the
messages of which he wishes to receive notification. The user can define a
filter that selects the messages.
16.6.2
Design
The POP protocol does not allow asynchronous notification therefore we
need to implement a mechanism to periodically check the presence of new
messages on the mail server. In addition we need a class to interact with the
GSM equipment.
The structure of the classes is presented in Figure 16.11. The class Notify
implements the Runnable interface and runs in a separate thread; it periodi-
cally checks the email status of users that have enabled the SMS notification,
and for each new message that has arrived the filter is applied. If the message
is selected then it sends an SMS message to the user's mobile.
The class SMSSender takes care of interacting with the GSM equipment
(see Sidebar 16.4). To communicate over the serial connection it uses the
Java Comm extension that is in the javax.comm package.
The notification of new email messages requires new information to be
added to the user profiles. Table 16.2 summarizes the new elements of the
user profile. These fields ought to be added to the database table that store
the user preferences.
16.6.3
Implementation
The class Notify is responsible for periodically checking the mail folders and
notifying the users via SMS. It implements the Runnable interface and the
 
Search WWH ::




Custom Search