Java Reference
In-Depth Information
One last interesting part of the timer's behavior is best described with an
example. You start and stop Timer MBeans the same way as monitor MBeans: by
using the start() and stop() methods. Imagine that you add many notifications
to a Timer MBean before you invoke its start() method, and some of the added
notifications' dates have already been reached. You can configure the timer to
send all past notifications by setting its SendPastNotifications attribute to true .
If the timer's SendPastNotifications attribute is true , all one-time notifica-
tions with a date before the current date are sent. The timer then sends all peri-
odic notifications that could not be sent by updating their dates with previously
described updating rules. If a periodic notification with an earlier date must be
sent, then it will be sent as many times as it would have been if it had a correct
date. The SendPastNotifications attribute only applies to notifications whose
time has come and passed before the timer was started. The timer will ignore
any notification added with a date earlier than the date when the addNotifica-
tion() method was invoked.
The Timer class
Now that you understand the Timer MBean's behavior, let's examine some of the
methods available in the Timer class. Rather than examine every method from
the Timer class, we've listed them in table 12.9. Most of the methods in the table
correspond to pieces of the behavior described in the previous section.
Table 12.9
The public methods of the Timer class
Method
Description
Adds a notification with the specified date. This notifi-
cation will be sent only once.
Integer addNotification( String
type, String message, Object user-
data, Date date )
Adds a notification with the specified date and period.
This notification will be sent once every period after the
start date.
Integer addNotification( String
type, String message, Object user-
data, Date date, long period )
Same as the previous method, but the notification will
be sent only nbOccurrences times.
Integer addNotification( String
type, String message, Object user-
data, Date date, long period, long
nbOccurrences )
Returns all the notification ids contained in the timer.
Vector getAllNotificationIDs()
Returns the date for the notification with the id specified.
Date getDate( Integer id )
Returns the number of occurrences for the notification
with the id specified.
Long getNbOccurrences
( Integer id )
Search WWH ::




Custom Search