Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.management.timer
Class Timer

    java.lang.Object
      javax.management.NotificationBroadcasterSupport
          javax.management.timer.Timer

All Implemented Interfaces:
  MBeanRegistration, NotificationBroadcaster, NotificationEmitter, TimerMBean

public class Timer
extends NotificationBroadcasterSupport
implements TimerMBean, MBeanRegistration

The timer service.

Version:
  $Revision: 1.14 $
Author:
  Adrian Brock

Field Summary
`static long` | `ONE_DAY` The number of milliseconds in one day.
`static long` | `ONE_HOUR` The number of milliseconds in one hour.
`static long` | `ONE_MINUTE` The number of milliseconds in one minute.
`static long` | `ONE_SECOND` The number of milliseconds in one second.
`static long` | `ONE_WEEK` The number of milliseconds in one week.

Constructor Summary
`Timer()`

Method Summary
`Integer` | `addNotification(String type, String message, Object userData, Date date)` Creates a new timer notification for a specific date/time.
`Integer` | `addNotification(String type, String message, Object userData, Date date, long period)` Creates a new timer notification for a specific date/time, with an optional repeat period.
`Integer` | `addNotification(String type, String message, Object userData, Date date, long period, long occurences)` Creates a new timer notification for a specific date/time, with an optional repeat period and a maximum number of occurences.
`Integer` | `addNotification(String type, String message, Object userData, Date date, long period, long nbOccurences, boolean fixedRate)` Creates a new timer notification with the specified type, message and userData and inserts it into the list of notifications with a given date, period and number of occurences.
`Vector` | `getAllNotificationIDs()` Retrieves all timer notifications ids.
`Date` | `getDate(Integer id)` Retrieves a copy of the notification date for a passed notification id.
`Boolean` | `getFixedRate(Integer id)` Gets a copy of the flag indicating whether a peridic notification is executed at fixed-delay or at fixed-rate.
`int` | `getNbNotifications()` Retrieves the number of registered timer notifications.
`Long` | `getNbOccurences(Integer id)` Retrieves a copy of the maximum notification occurences for a passed notification id.
`Vector` | `getNotificationIDs(String type)` Retrieves all timer notifications ids of the passed notification type.
`String` | `getNotificationMessage(Integer id)` Retrieves the notification message for a passed notification id.
`String` | `getNotificationType(Integer id)` Retrieves the notification type for a passed notification id.
`Object` | `getNotificationUserData(Integer id)` Retrieves the notification user data for a passed notification id.
`Long` | `getPeriod(Integer id)` Retrieves a copy of the notification period for a passed notification id.
`boolean` | `getSendPastNotifications()` Retrieves the flag indicating whether past notifications are sent.
`boolean` | `isActive()` Test whether the timer MBean is active.
`boolean` | `isEmpty()` Test whether the timer MBean has any registered notifications.
`void` | `postDeregister()` This method is called by the MBeanServer after deregistration takes place.
`void` | `postRegister(Boolean registrationDone)` This method is called by the MBeanServer after registration takes place or when registration fails.
`void` | `preDeregister()` This method is called by the MBeanServer before deregistration takes place.
`ObjectName` | `preRegister(MBeanServer server, ObjectName objectName)` This method is called by the MBeanServer before registration takes place.
`void` | `removeAllNotifications()` Removes all notifications from the timer MBean.
`void` | `removeNotification(Integer id)` Removes a notification from the timer MBean with the specified notification id.
`void` | `removeNotifications(String type)` Removes all notifications from the timer MBean of the specified notification type.
`void` | `setSendPastNotifications(boolean value)` Sets the flag indicating whether past notifications are sent.
`void` | `start()` Starts the timer.
`void` | `stop()` Stops the timer.

Methods inherited from class javax.management.NotificationBroadcasterSupport
`addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ONE_SECOND

    public static final long ONE_SECOND

  The number of milliseconds in one second.

  See Also:
    Constant Field Values

### ONE_MINUTE

    public static final long ONE_MINUTE

  The number of milliseconds in one minute.

  See Also:
    Constant Field Values

### ONE_HOUR

    public static final long ONE_HOUR

  The number of milliseconds in one hour.

  See Also:
    Constant Field Values

### ONE_DAY

    public static final long ONE_DAY

  The number of milliseconds in one day.

  See Also:
    Constant Field Values

### ONE_WEEK

    public static final long ONE_WEEK

  The number of milliseconds in one week.

  See Also:
    Constant Field Values

Constructor Detail

### Timer

    public Timer()

Method Detail

### addNotification

    public Integer addNotification(String type,
                                   String message,
                                   Object userData,
                                   Date date)
                            throws IllegalArgumentException

  Description copied from interface: `TimerMBean`
  Creates a new timer notification for a specific date/time. The notification is performed once.

  Specified by:
    `addNotification` in interface `TimerMBean`
  Parameters:
    `type` - the notification type.
    `message` - the notification's message string.
    `userData` - the notification's user data.
    `date` - the date/time the notification will occur.
  Returns:
    the notification id for this notification.
  Throws:
    `IllegalArgumentException` - when the date is before the current date.

### addNotification

    public Integer addNotification(String type,
                                   String message,
                                   Object userData,
                                   Date date,
                                   long period)
                            throws IllegalArgumentException

  Description copied from interface: `TimerMBean`
  Creates a new timer notification for a specific date/time, with an optional repeat period. When the repeat period is not zero, the notification repeats forever.

  If the date and time is before the the current date and time the period is repeatedly added until a date after the current date and time is found.

  Specified by:
    `addNotification` in interface `TimerMBean`
  Parameters:
    `type` - the notification type.
    `message` - the notification's message string.
    `userData` - the notification's user data.
    `date` - the date/time the notification will occur.
    `period` - the repeat period in milli-seconds. Passing zero means no repeat.
  Returns:
    the notification id for this notification.
  Throws:
    `IllegalArgumentException` - when the date is before the current date or the period is negative.

### addNotification

    public Integer addNotification(String type,
                                   String message,
                                   Object userData,
                                   Date date,
                                   long period,
                                   long occurences)
                            throws IllegalArgumentException

  Description copied from interface: `TimerMBean`
  Creates a new timer notification for a specific date/time, with an optional repeat period and a maximum number of occurences.

  If the date and time is before the the current date and time the period is repeatedly added until a date after the current date and time is found. If the number of occurences is exceeded before the current date and time is reached, an IllegalArgumentException is raised.

  Specified by:
    `addNotification` in interface `TimerMBean`
  Parameters:
    `type` - the notification type.
    `message` - the notification's message string.
    `userData` - the notification's user data.
    `date` - the date/time the notification will occur.
    `period` - the repeat period in milli-seconds. Passing zero means no repeat.
    `occurences` - the maximum number of repeats. When the period is not zero and this parameter is zero, it will repeat indefinitely.
  Returns:
    the notification id for this notification.
  Throws:
    `IllegalArgumentException` - when the date is before the current date, the period is negative or the number of repeats is negative.

### getAllNotificationIDs

    public Vector getAllNotificationIDs()

  Description copied from interface: `TimerMBean`
  Retrieves all timer notifications ids.

  Specified by:
    `getAllNotificationIDs` in interface `TimerMBean`
  Returns:
    a vector of Integers containing the ids. The list is empty when there are no timer notifications.

### getDate

    public Date getDate(Integer id)

  Description copied from interface: `TimerMBean`
  Retrieves a copy of the notification date for a passed notification id.

  Specified by:
    `getDate` in interface `TimerMBean`
  Parameters:
    `id` - the notification id.
  Returns:
    a copy of the notification date or null when the notification id is not registered.

### getNbNotifications

    public int getNbNotifications()

  Description copied from interface: `TimerMBean`
  Retrieves the number of registered timer notifications.

  Specified by:
    `getNbNotifications` in interface `TimerMBean`
  Returns:
    the number of notifications.

### getNbOccurences

    public Long getNbOccurences(Integer id)

  Description copied from interface: `TimerMBean`
  Retrieves a copy of the maximum notification occurences for a passed notification id.

  Specified by:
    `getNbOccurences` in interface `TimerMBean`
  Parameters:
    `id` - the notification id.
  Returns:
    a copy of the maximum notification occurences or null when the notification id is not registered.

### getFixedRate

    public Boolean getFixedRate(Integer id)

  Gets a copy of the flag indicating whether a peridic notification is executed at fixed-delay or at fixed-rate.

  Specified by:
    `getFixedRate` in interface `TimerMBean`
  Parameters:
    `id` - The timer notification identifier.
  Returns:
    A copy of the flag indicating whether a peridic notification is executed at fixed-delay or at fixed-rate.

### getNotificationIDs

    public Vector getNotificationIDs(String type)

  Description copied from interface: `TimerMBean`
  Retrieves all timer notifications ids of the passed notification type.

  Specified by:
    `getNotificationIDs` in interface `TimerMBean`
  Parameters:
    `type` - the notification type.
  Returns:
    a vector of Integers containing the ids. The list is empty when there are no timer notifications of the passed type.

### getNotificationMessage

    public String getNotificationMessage(Integer id)

  Description copied from interface: `TimerMBean`
  Retrieves the notification message for a passed notification id.

  Specified by:
    `getNotificationMessage` in interface `TimerMBean`
  Parameters:
    `id` - the notification id.
  Returns:
    the notification message or null when the notification id is not registered.

### getNotificationType

    public String getNotificationType(Integer id)

  Description copied from interface: `TimerMBean`
  Retrieves the notification type for a passed notification id.

  Specified by:
    `getNotificationType` in interface `TimerMBean`
  Parameters:
    `id` - the notification id.
  Returns:
    the notification type or null when the notification id is not registered.

### getNotificationUserData

    public Object getNotificationUserData(Integer id)

  Description copied from interface: `TimerMBean`
  Retrieves the notification user data for a passed notification id.

  Specified by:
    `getNotificationUserData` in interface `TimerMBean`
  Parameters:
    `id` - the notification id.
  Returns:
    the notification user data or null when the notification id is not registered.

### getPeriod

    public Long getPeriod(Integer id)

  Description copied from interface: `TimerMBean`
  Retrieves a copy of the notification period for a passed notification id.

  Specified by:
    `getPeriod` in interface `TimerMBean`
  Parameters:
    `id` - the notification id.
  Returns:
    a copy of the notification period or null when the notification id is not registered.

### getSendPastNotifications

    public boolean getSendPastNotifications()

  Description copied from interface: `TimerMBean`
  Retrieves the flag indicating whether past notifications are sent.

  Specified by:
    `getSendPastNotifications` in interface `TimerMBean`
  Returns:
    true when past notifications are sent, false otherwise.

### isActive

    public boolean isActive()

  Description copied from interface: `TimerMBean`
  Test whether the timer MBean is active.

  Specified by:
    `isActive` in interface `TimerMBean`
  Returns:
    true when timer is active, false otherwise.

### isEmpty

    public boolean isEmpty()

  Description copied from interface: `TimerMBean`
  Test whether the timer MBean has any registered notifications.

  Specified by:
    `isEmpty` in interface `TimerMBean`
  Returns:
    true when timer has no registered notifications, false otherwise.

### removeAllNotifications

    public void removeAllNotifications()

  Description copied from interface: `TimerMBean`
  Removes all notifications from the timer MBean.

  Specified by:
    `removeAllNotifications` in interface `TimerMBean`

### removeNotification

    public void removeNotification(Integer id)
                            throws InstanceNotFoundException

  Description copied from interface: `TimerMBean`
  Removes a notification from the timer MBean with the specified notification id.

  Specified by:
    `removeNotification` in interface `TimerMBean`
  Parameters:
    `id` - the notification id.
  Throws:
    `InstanceNotFoundException` - when there are no notification registered with the id passed.

### removeNotifications

    public void removeNotifications(String type)
                             throws InstanceNotFoundException

  Description copied from interface: `TimerMBean`
  Removes all notifications from the timer MBean of the specified notification type.

  Specified by:
    `removeNotifications` in interface `TimerMBean`
  Parameters:
    `type` - the notification type.
  Throws:
    `InstanceNotFoundException` - when there are no notifications of the type passed.

### setSendPastNotifications

    public void setSendPastNotifications(boolean value)

  Description copied from interface: `TimerMBean`
  Sets the flag indicating whether past notifications are sent.

  Specified by:
    `setSendPastNotifications` in interface `TimerMBean`
  Parameters:
    `value` - the new value of the flag. true when past notifications are sent, false otherwise.

### start

    public void start()

  Description copied from interface: `TimerMBean`
  Starts the timer. If there are any notifications before the current time these notifications are processed. The notification only takes place when send past notiications is true.

  Specified by:
    `start` in interface `TimerMBean`

### stop

    public void stop()

  Description copied from interface: `TimerMBean`
  Stops the timer.

  Specified by:
    `stop` in interface `TimerMBean`

### addNotification

    public Integer addNotification(String type,
                                   String message,
                                   Object userData,
                                   Date date,
                                   long period,
                                   long nbOccurences,
                                   boolean fixedRate)
                            throws IllegalArgumentException

  Creates a new timer notification with the specified type, message and userData and inserts it into the list of notifications with a given date, period and number of occurences.

  If the timer notification to be inserted has a date that is before the current date, the method behaves as if the specified date were the current date. For once-off notifications, the notification is delivered immediately. For periodic notifications, the first notification is delivered immediately and the subsequent ones are spaced as specified by the period parameter.

  Note that once the timer notification has been added into the list of notifications, its associated date, period and number of occurences cannot be updated.

  In the case of a periodic notification, the value of parameter fixedRate is used to specify the execution scheme, as specified in Timer.

  Specified by:
    `addNotification` in interface `TimerMBean`
  Parameters:
    `type` - The timer notification type.
    `message` - The timer notification detailed message.
    `userData` - The timer notification user data object.
    `date` - The date when the notification occurs.
    `period` - The period of the timer notification (in milliseconds).
    `nbOccurences` - The total number the timer notification will be emitted.
    `fixedRate` - If true and if the notification is periodic, the notification is scheduled with a fixed-rate execution scheme. If false and if the notification is periodic, the notification is scheduled with a fixed-delay execution scheme. Ignored if the notification is not periodic.
  Returns:
    The identifier of the new created timer notification.
  Throws:
    `IllegalArgumentException` - The period or the number of occurences is negative

### preRegister

    public ObjectName preRegister(MBeanServer server,
                                  ObjectName objectName)
                           throws Exception

  Description copied from interface: `MBeanRegistration`
  This method is called by the MBeanServer before registration takes place. The MBean is passed a reference of the MBeanServer it is about to be registered with. The MBean must return the ObjectName it will be registered with. The MBeanServer can pass a suggested object depending upon how the MBean is registered.

  The MBean can stop the registration by throwing an exception.The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

  Specified by:
    `preRegister` in interface `MBeanRegistration`
  Returns:
    the actual ObjectName to register this MBean with.
  Throws:
    `Exception` - for any error, the MBean is not registered.

### postRegister

    public void postRegister(Boolean registrationDone)

  Description copied from interface: `MBeanRegistration`
  This method is called by the MBeanServer after registration takes place or when registration fails.

  Specified by:
    `postRegister` in interface `MBeanRegistration`
  Parameters:
    `registrationDone` - the MBeanServer passes true when the MBean was registered, false otherwise.

### preDeregister

    public void preDeregister()
                       throws Exception

  Description copied from interface: `MBeanRegistration`
  This method is called by the MBeanServer before deregistration takes place.

  The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

  Specified by:
    `preDeregister` in interface `MBeanRegistration`
  Throws:
    `Exception`

### postDeregister

    public void postDeregister()

  Description copied from interface: `MBeanRegistration`
  This method is called by the MBeanServer after deregistration takes place.

  Specified by:
    `postDeregister` in interface `MBeanRegistration`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.