Java Reference
In-Depth Information
Table 12.9
The public methods of the Timer class (continued)
Method
Description
Returns the ids of all the notifications with the supplied
notification type.
Vector getNotificationIDs( String
type )
Returns the message for the notification with the id
specified.
String getNotificationMessage
( Integer id )
Returns the type for the notification with the id specified.
String getNotificationType( Inte-
ger id )
Returns the user data for the notification with the id
specified.
Object getNotificationUserData
( Integer id )
Returns the period for the notification with the id specified.
Long getPeriod( Integer id )
boolean getSendPastNotifications() Returns the value of the SendPastNotifications
attribute.
Removes the notification with the id supplied.
void removeNotification( Integer
id )
Removes notifications with the specified notification
type.
void removeNotifications( String
type )
Sets the SendPastNotifications attribute.
void setSendPastNotifications
( boolean value )
Starts the timer.
void start()
Stops the timer.
void stop()
As you can tell, the timer service is a fairly simple concept, and we don't need
to cover each method. The best way to get a better understanding of the timer
is to write an example. The following section presents an example of using the
timer service.
12.5 Using the timer service
To build a working example of the timer service, you will again use your JMX-
BookAgent class. Listing 12.4 shows a new method to add to the JMXBookAgent
class. The startTimerService() method creates and registers a timer service for
your agent.
Listing 12.4
The startTimerService() of the JMXBookAgent class
protected void startTimerService()
{
Timer timer = new Timer();
Search WWH ::




Custom Search