| java.lang.Object javax.management.NotificationBroadcasterSupport javax.management.timer.Timer
Timer | public class Timer extends NotificationBroadcasterSupport implements TimerMBean,MBeanRegistration(Code) | | 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.
When a timer notification is emitted by the timer and becomes obsolete,
it is automatically removed from the list of timer notifications.
Additional timer notifications can be added into regularly repeating notifications.
Note:
- All notifications before the time when the
addNotification method is called
are ignored, irrespective of the sendPastNotifications flag.
- When sending timer notifications, the timer updates the notification sequence number
irrespective of the notification type.
- The timer service relies on the system date of the host where the
Timer class is loaded.
Listeners may receive untimely notifications
if their host has a different system date.
To avoid such problems, synchronize the system date of all host machines where timing is needed.
- The default behaviour for periodic notifications is fixed-delay execution, as
specified in
java.util.Timer . In order to use fixed-rate execution, use the
overloaded
Timer.addNotification(String,String,Object,Date,long,long,boolean) method.
- Notification listeners are potentially all executed in the same
thread. Therefore, they should execute rapidly to avoid holding up
other listeners or perturbing the regularity of fixed-delay
executions. See
NotificationBroadcasterSupport .
author: Young Yang |
Constructor Summary | |
public | Timer() |
Method Summary | |
public synchronized Integer | addNotification(String type, String message, Object userData, Date date, long period, long nbOccurences) add a notification to the Timer
Parameters: type - The notification type string. Parameters: message - The notification¡¯s detailed message string. Parameters: userData - The notification¡¯s user data object. Parameters: date - The date when the notification will occur. | public synchronized Integer | addNotification(String type, String message, Object userData, Date date, long period) | public synchronized Integer | addNotification(String type, String message, Object userData, Date date) | public Integer | addNotification(String type, String message, Object userData, Date date, long period, long nbOccurences, boolean fixedRate) | public synchronized Vector | getAllNotificationIDs() | public Date | getDate(Integer id) | public Boolean | getFixedRate(Integer id) | public int | getNbNotifications() | public Long | getNbOccurences(Integer id) | public synchronized Vector | getNotificationIDs(String type) | public MBeanNotificationInfo[] | getNotificationInfo() | public String | getNotificationMessage(Integer id) | public String | getNotificationType(Integer id) | public Object | getNotificationUserData(Integer id) | public Long | getPeriod(Integer id) | public boolean | getSendPastNotifications() | public boolean | isActive() | public boolean | isEmpty() | public void | postDeregister() | public void | postRegister(Boolean boolean1) | public void | preDeregister() | public ObjectName | preRegister(MBeanServer mbeanserver, ObjectName objectname) | public synchronized void | removeAllNotifications() | public synchronized void | removeNotification(Integer id) | public synchronized void | removeNotifications(String type) | public void | setSendPastNotifications(boolean flag) | public void | start() | public synchronized void | stop() |
addNotification | public synchronized Integer addNotification(String type, String message, Object userData, Date date, long period, long nbOccurences) throws IllegalArgumentException(Code) | | add a notification to the Timer
Parameters: type - The notification type string. Parameters: message - The notification¡¯s detailed message string. Parameters: userData - The notification¡¯s user data object. Parameters: date - The date when the notification will occur. The Timer class includesinteger constants for expressing durations in milliseconds, which can then beused to doCreate java.util.Date objects. Parameters: period - The interval in milliseconds between notification occurrences.Repeating notifications are not enabled if this parameter is zero or null. Parameters: nbOccurences - The total number of times that the notification will occur. Ifthe value of this parameter is zero or is not defined (null), and if the period isnot zero or null, then the notification will repeat indefinitely. throws: IllegalArgumentException - |
getAllNotificationIDs | public synchronized Vector getAllNotificationIDs()(Code) | | |
getNbNotifications | public int getNbNotifications()(Code) | | |
getSendPastNotifications | public boolean getSendPastNotifications()(Code) | | |
isActive | public boolean isActive()(Code) | | |
isEmpty | public boolean isEmpty()(Code) | | |
postDeregister | public void postDeregister()(Code) | | |
removeAllNotifications | public synchronized void removeAllNotifications()(Code) | | |
setSendPastNotifications | public void setSendPastNotifications(boolean flag)(Code) | | |
start | public void start()(Code) | | |
stop | public synchronized void stop()(Code) | | |
|
|