|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.management.NotificationBroadcasterSupport | +--javax.management.timer.Timer
This class provides the implementation of the Timer MBean. The Timer MBean sends out an alarm at a specified time that wakes up all the listeners registered to receive timer notifications.
This class manages a list of dated timer notifications. A method allows users to add/remove as many notifications as required. Added timer notifications can be made into regularly repeating notifications.
Note:
All notifications before the time when the addNotification
method is called
are ignored irrespective of the sendPastNotifications
flag.
Field Summary | |
static long |
ONE_DAY
Number of milliseconds in one day. |
static long |
ONE_HOUR
Number of milliseconds in one hour. |
static long |
ONE_MINUTE
Number of milliseconds in one minute. |
static long |
ONE_SECOND
Number of milliseconds in one second. |
static long |
ONE_WEEK
Number of milliseconds in one week. |
Constructor Summary | |
Timer()
Default constructor. |
Method Summary | |
void |
addNotification(Notification notification,
java.util.Date date)
Inserts the specified timer notification into the list of notifications with a given date and a null period and number of repetitions. |
void |
addNotification(Notification notification,
java.util.Date date,
long periodInMillis)
Inserts the specified timer notification into the list of notifications with a given date and period and a null number of repetitions. |
void |
addNotification(Notification notification,
java.util.Date date,
long periodInMillis,
long nbRepetitions)
Inserts the specified timer notification into the list of notifications with a given date, period and number of repetitions. |
java.util.Date |
getDate(int index)
Gets a copy of the date of the timer notification at the specified index. |
java.util.Date |
getDate(Notification notification)
Gets a copy of the date of the specified timer notification. |
int |
getNbNotifications()
Gets the number of notifications registered into the list of notifications. |
java.lang.Long |
getNbRepetitions(int index)
Gets a copy of the remaining number of repetitions of the timer notification at the specified index. |
java.lang.Long |
getNbRepetitions(Notification notification)
Gets a copy of the remaining number of repetitions of the specified timer notification. |
Notification[] |
getNotifications()
Gets all the notifications registered into the list of notifications. |
java.lang.Long |
getPeriodInMillis(int index)
Gets a copy of the period in milliseconds of the timer notification at the specified index. |
java.lang.Long |
getPeriodInMillis(Notification notification)
Gets a copy of the period in milliseconds of the specified timer notification. |
boolean |
getSendPastNotifications()
Gets the flag indicating if the Timer sends past notifications or not. |
boolean |
isActive()
Tests if the Timer MBean is active. |
boolean |
isEmpty()
Tests if the list of notifications is empty. |
void |
removeAllNotifications()
Removes all the notifications from the list of notifications. |
void |
removeNotification(int index)
Removes the timer notification at the specified index from the list of notifications. |
void |
removeNotification(Notification notification)
Removes the specified timer notification from the list of notifications. |
void |
setSendPastNotifications(boolean value)
Sets the flag indicating if the Timer sends past notifications or not. |
void |
start()
Starts the Timer. |
void |
stop()
Stops the Timer. |
Methods inherited from class javax.management.NotificationBroadcasterSupport |
addNotificationListener,
getNotificationInfo,
removeNotificationListener,
sendNotification |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final long ONE_SECOND
addNotification
method.public static final long ONE_MINUTE
addNotification
method.public static final long ONE_HOUR
addNotification
method.public static final long ONE_DAY
addNotification
method.public static final long ONE_WEEK
addNotification
method.Constructor Detail |
public Timer()
Method Detail |
public void start()
public void stop()
public void addNotification(Notification notification, java.util.Date date, long periodInMillis, long nbRepetitions) throws InstanceAlreadyExistsException, java.lang.IllegalArgumentException
If the timer notification to be inserted has a date that is before the current date, the method attempts to update the notification using the defined period. If the defined period is null then the method generates an exception.
If the timer notification has a non null period, the date of the notification is updated by adding the period until the notification date is later than the current date. Then the timer notification is inserted into the list of notifications.
If the specified number of repetitions is non null, the previous mechanism is employed. The number of times that the period is added is limited to the specified number of repetitions. If the notification date remains earlier than the current date, an exception is generated.
A specified timer notification can be added only once.
Note that once the timer notification has been added into the list of notifications, its associated date, period and number of repetitions cannot be updated.
notification
- The timer notification to be added.date
- The date when the notification occurs.periodInMillis
- The period of the timer notification.nbRepetitions
- The number of repetitions of the timer notification.public void addNotification(Notification notification, java.util.Date date, long periodInMillis) throws InstanceAlreadyExistsException, java.lang.IllegalArgumentException
The timer notification will repeat continuously using the timer period.
notification
- The timer notification to be added.date
- The date when the notification occurs.periodInMillis
- The period of the timer notification.public void addNotification(Notification notification, java.util.Date date) throws InstanceAlreadyExistsException, java.lang.IllegalArgumentException
The timer notification will be handled once at the specified date.
notification
- The timer notification to be added.date
- The date when the notification occurs.public void removeNotification(Notification notification) throws InstanceNotFoundException
notification
- The timer notification to be removed.public void removeNotification(int index) throws InstanceNotFoundException
index
- The index of the timer notification to remove.public void removeAllNotifications()
public Notification[] getNotifications()
public java.util.Date getDate(Notification notification)
notification
- The timer notification.public java.util.Date getDate(int index)
index
- The index of the timer notification.public java.lang.Long getPeriodInMillis(Notification notification)
notification
- The timer notification.public java.lang.Long getPeriodInMillis(int index)
index
- The index of the timer notification.public java.lang.Long getNbRepetitions(Notification notification)
notification
- The timer notification.public java.lang.Long getNbRepetitions(int index)
index
- The index of the timer notification.public int getNbNotifications()
public boolean getSendPastNotifications()
public void setSendPastNotifications(boolean value)
value
- The past notifications sending on/off flag value.public boolean isActive()
public boolean isEmpty()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |