-
- 所有已知实现类:
-
Timer
public interface TimerMBean暴露计时器MBean的管理界面。- 从以下版本开始:
- 1.5
-
-
方法摘要
所有方法 接口方法 抽象方法 Modifier and Type 方法 描述 IntegeraddNotification(String type, String message, Object userData, Date date)创建具有指定的新计时器通知type,message和userData并将其插入到与事件给定日期以及null时段和数量的通知列表中。IntegeraddNotification(String type, String message, Object userData, Date date, long period)创建具有指定的新计时器通知type,message和userData并将其插入到带有给定日期和时段,以及null出现数量的通知列表中。IntegeraddNotification(String type, String message, Object userData, Date date, long period, long nbOccurences)创建具有指定的新计时器通知type,message和userData并将其插入到与事件的定日期,时段和数量的通知列表中。IntegeraddNotification(String type, String message, Object userData, Date date, long period, long nbOccurences, boolean fixedRate)创建具有指定的新计时器通知type,message和userData并将其插入到与事件的定日期,时段和数量的通知列表中。Vector<Integer>getAllNotificationIDs()获取注册到通知列表中的所有定时器通知标识符。DategetDate(Integer id)获取与定时器通知相关联的日期的副本。BooleangetFixedRate(Integer id)获取标志的副本,指示是定期通知是以 固定延迟还是 固定速率执行 。intgetNbNotifications()获取注册到通知列表中的定时器通知的数量。LonggetNbOccurences(Integer id)获取与定时器通知相关联的剩余发生次数的副本。Vector<Integer>getNotificationIDs(String type)获取与指定类型相对应的定时器通知的所有标识符。StringgetNotificationMessage(Integer id)获取与指定标识符相对应的定时器通知详细消息。StringgetNotificationType(Integer id)获取与指定标识符对应的定时器通知类型。ObjectgetNotificationUserData(Integer id)获取与指定标识符相对应的定时器通知用户数据对象。LonggetPeriod(Integer id)获取与定时器通知相关联的周期(以毫秒为单位)的副本。booleangetSendPastNotifications()获取指示定时器是否发送过去通知的标志。booleanisActive()测试定时器MBean是否处于活动状态。booleanisEmpty()测试定时器通知的列表是否为空。voidremoveAllNotifications()从通知列表中删除所有定时器通知,并重置用于更新计时器通知标识符的计数器。voidremoveNotification(Integer id)从通知列表中删除与指定标识符相对应的定时器通知。voidremoveNotifications(String type)从通知列表中删除与指定类型对应的所有定时器通知。voidsetSendPastNotifications(boolean value)设置指示定时器是否发送过去通知的标志。voidstart()启动计时器。voidstop()停止定时器
-
-
-
方法详细信息
-
start
void start()
启动计时器。如果在通知列表中的时间之前有一个或多个定时器通知,则根据
sendPastNotifications标志发送通知,然后根据其周期和剩余的发生次数进行更新。 如果计时器通知日期早于当前日期,则此通知将从通知列表中移除。
-
stop
void stop()
停止定时器
-
addNotification
Integer addNotification(String type, String message, Object userData, Date date, long period, long nbOccurences, boolean fixedRate) throws IllegalArgumentException
创建具有指定的新计时器通知type,message和userData并将其插入到与事件的定日期,时段和数量的通知列表中。如果要插入的计时器通知的日期在当前日期之前,该方法的行为就像指定的日期是当前日期一样。
对于一次性通知,通知将立即发送。
对于定期通知,第一个通知立即发送,后续的通知按照period参数指定。请注意,一旦定时器通知已添加到通知列表中,则无法更新其关联的日期,周期和出现次数。
在定期通知的情况下,参数fixedRate的值用于指定执行方案,如
Timer中所述 。- 参数
-
type- 定时器通知类型。 -
message- 定时器通知详细信息。 -
userData- 定时器通知用户数据对象。 -
date- 发生通知的日期。 -
period- 定时器通知的周期(以毫秒为单位)。 -
nbOccurences- 将发出定时器通知的总数。 -
fixedRate- 如果是true并且如果通知是周期性的,则以固定速率执行方案调度通知。 如果是false,如果通知是周期性的,那么通过固定延迟执行方案调度通知。 如果通知不是周期性的,则忽略。 - 结果
- 新创建的定时器通知的标识符。
- 异常
-
IllegalArgumentException- 日期为null或出现的期间或次数为负。 - 另请参见:
-
addNotification(String, String, Object, Date, long, long)
-
addNotification
Integer addNotification(String type, String message, Object userData, Date date, long period, long nbOccurences) throws IllegalArgumentException
创建具有指定的新计时器通知type,message和userData并将其插入到与事件的定日期,时段和数量的通知列表中。如果要插入的计时器通知的日期在当前日期之前,该方法的行为就像指定的日期是当前日期一样。
对于一次性通知,通知将立即发送。
对于定期通知,第一个通知立即发送,后续的通知按照period参数指定。请注意,一旦定时器通知已添加到通知列表中,则无法更新其关联的日期,周期和出现次数。
在定期通知的情况下,使用固定延迟执行方案,如
Timer所规定。 为了使用固定速率执行方案,请改用addNotification(String, String, Object, Date, long, long, boolean)。- 参数
-
type- 定时器通知类型。 -
message- 定时器通知详细信息。 -
userData- 定时器通知用户数据对象。 -
date- 发生通知的日期。 -
period- 定时器通知的周期(以毫秒为单位)。 -
nbOccurences- 定时器通知将被发出的总数。 - 结果
- 新创建的定时器通知的标识符。
- 异常
-
IllegalArgumentException- 日期为null或期间或出现次数为负数。 - 另请参见:
-
addNotification(String, String, Object, Date, long, long, boolean)
-
addNotification
Integer addNotification(String type, String message, Object userData, Date date, long period) throws IllegalArgumentException
创建具有指定的新计时器通知type,message和userData并将其插入到带有给定日期和时段,以及null出现数量的通知列表中。定时器通知将使用固定延迟执行方案使用定时器周期连续重复,如
Timer中所述 。 为了使用固定速率执行方案,请改用addNotification(String, String, Object, Date, long, long, boolean)。如果要插入的计时器通知的日期在当前日期之前,该方法的行为就像指定的日期是当前日期一样。 第一个通知立即发送,随后的通知按照period参数指定。
- 参数
-
type- 定时器通知类型。 -
message- 定时器通知详细信息。 -
userData- 定时器通知用户数据对象。 -
date- 发生通知的日期。 -
period- 定时器通知的周期(以毫秒为单位)。 - 结果
- 新创建的定时器通知的标识符。
- 异常
-
IllegalArgumentException- 日期为null或期间为负。
-
addNotification
Integer addNotification(String type, String message, Object userData, Date date) throws IllegalArgumentException
创建具有指定的新计时器通知type,message和userData并将其插入到与事件给定日期以及null时段和数量的通知列表中。计时器通知将在指定的日期处理一次。
如果要插入的计时器通知的日期在当前日期之前,则该方法的行为就好像指定的日期是当前日期,并且立即发送通知。
- 参数
-
type- 定时器通知类型。 -
message- 定时器通知详细信息。 -
userData- 定时器通知用户数据对象。 -
date- 发生通知的日期。 - 结果
- 新创建的定时器通知的标识符。
- 异常
-
IllegalArgumentException- 日期是null。
-
removeNotification
void removeNotification(Integer id) throws InstanceNotFoundException
从通知列表中删除与指定标识符相对应的定时器通知。- 参数
-
id- 定时器通知标识符。 - 异常
-
InstanceNotFoundException- 指定的标识符与此定时器MBean的通知列表中的任何定时器通知不对应。
-
removeNotifications
void removeNotifications(String type) throws InstanceNotFoundException
从通知列表中删除与指定类型对应的所有定时器通知。- 参数
-
type- 定时器通知类型。 - 异常
-
InstanceNotFoundException- 指定类型与此定时器MBean的通知列表中的任何定时器通知不对应。
-
removeAllNotifications
void removeAllNotifications()
从通知列表中删除所有定时器通知,并重置用于更新计时器通知标识符的计数器。
-
getNbNotifications
int getNbNotifications()
获取注册到通知列表中的定时器通知的数量。- 结果
- 定时器通知的次数。
-
getAllNotificationIDs
Vector<Integer> getAllNotificationIDs()
获取注册到通知列表中的所有定时器通知标识符。- 结果
-
包含所有定时器通知标识符的
Integer对象的向量。
如果没有为此定时器MBean注册定时器通知,则向量为空。
-
getNotificationIDs
Vector<Integer> getNotificationIDs(String type)
获取与指定类型相对应的定时器通知的所有标识符。- 参数
-
type- 定时器通知类型。 - 结果
-
包含
Integer对象的向量,包含具有指定的type的定时器通知的所有标识符。
如果没有为此定时器MBean注册的定时器通知指定了type,向量为空。
-
getNotificationType
String getNotificationType(Integer id)
获取与指定标识符对应的定时器通知类型。- 参数
-
id- 定时器通知标识符。 - 结果
- 定时器通知类型,如果标识符未映射到为此定时器MBean注册的任何定时器通知,则为null。
-
getNotificationMessage
String getNotificationMessage(Integer id)
获取与指定标识符相对应的定时器通知详细消息。- 参数
-
id- 定时器通知标识符。 - 结果
- 定时器通知详细消息,如果标识符未映射到为此定时器MBean注册的任何定时器通知,则为null。
-
getNotificationUserData
Object getNotificationUserData(Integer id)
获取与指定标识符相对应的定时器通知用户数据对象。- 参数
-
id- 定时器通知标识符。 - 结果
- 定时器通知用户数据对象,如果标识符未映射到为此定时器MBean注册的任何定时器通知,则为null。
-
getDate
Date getDate(Integer id)
获取与定时器通知相关联的日期的副本。- 参数
-
id- 定时器通知标识符。 - 结果
- 如果标识符未映射到为此定时器MBean注册的任何定时器通知,则该日期的副本为null。
-
getPeriod
Long getPeriod(Integer id)
获取与定时器通知相关联的周期(以毫秒为单位)的副本。- 参数
-
id- 定时器通知标识符。 - 结果
- 如果标识符未映射到为此定时器MBean注册的任何定时器通知,则该周期的副本为null。
-
getNbOccurences
Long getNbOccurences(Integer id)
获取与定时器通知相关联的剩余发生次数的副本。- 参数
-
id- 定时器通知标识符。 - 结果
- 剩余出现次数的副本,如果标识符未映射到为此定时器MBean注册的任何定时器通知,则为null。
-
getFixedRate
Boolean getFixedRate(Integer id)
获取标志的副本,指示是定期通知是以 固定延迟还是 固定速率执行 。- 参数
-
id- 定时器通知标识符。 - 结果
- 指示是否以 固定延迟或 固定速率执行定期通知的标志的副本。
-
getSendPastNotifications
boolean getSendPastNotifications()
获取指示定时器是否发送过去通知的标志。- 结果
- 过去的通知发送开/关标志值。
- 另请参见:
-
setSendPastNotifications(boolean)
-
setSendPastNotifications
void setSendPastNotifications(boolean value)
设置指示定时器是否发送过去通知的标志。- 参数
-
value- 过去的通知发送开/关标志值。 - 另请参见:
-
getSendPastNotifications()
-
isActive
boolean isActive()
- 结果
-
true如果计时器MBean是活动的,false否则。
-
isEmpty
boolean isEmpty()
测试定时器通知的列表是否为空。- 结果
-
trueif the list of timer notifications is empty,falseotherwise.
-
-