-
- 所有已知实现类:
-
Timer
public interface TimerMBean公开计时器MBean的管理界面。- 从以下版本开始:
- 1.5
-
-
方法摘要
所有方法 实例方法 抽象方法 变量和类型 方法 描述 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并将其插入到与事件的定日期,时段和数量的通知列表中。如果要插入的计时器通知的日期在当前日期之前,则该方法的行为就像指定的日期是当前日期一样。
对于一次性通知,通知会立即发送。
对于定期通知,第一个通知立即传递,后续的通知按周期参数指定。请注意,一旦将计时器通知添加到通知列表中,就无法更新其关联日期,期间和发生次数。
在定期通知的情况下,参数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并将其插入到与事件的定日期,时段和数量的通知列表中。如果要插入的计时器通知的日期在当前日期之前,则该方法的行为就像指定的日期是当前日期一样。
对于一次性通知,通知会立即发送。
对于定期通知,第一个通知立即传递,后续的通知按周期参数指定。请注意,一旦将计时器通知添加到通知列表中,就无法更新其关联日期,期间和发生次数。
在定期通知的情况下,使用固定延迟执行方案,如
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)。如果要插入的计时器通知的日期在当前日期之前,则该方法的行为就像指定的日期是当前日期一样。 第一个通知立即传递,后续的通知按周期参数指定。
- 参数
-
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的计时器通知的所有标识符。
如果没有为具有指定的type此计时器MBean注册计时器通知,则向量为空。
-
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.
-
-