TimerService (Java EE 5)

Java EE API


javax.ejb Interface TimerService


public interface TimerService


TimerService 接口为企业 Bean 组件提供对容器提供的 Timer Service 的访问。EJB Timer Service 允许实体 Bean、无状态会话 Bean 和消息驱动 Bean 注册在指定时间、在指定时间经过后,或在指定间隔后的计时器回调事件。
英文文档:

The TimerService interface provides enterprise bean components with access to the container-provided Timer Service. The EJB Timer Service allows entity beans, stateless session beans, and message-driven beans to be registered for timer callback events at a specified time, after a specified elapsed time, or after a specified interval.


Method Summary
 Timer
 Timer
 Timer
 Timer
 Collection
 

Method Detail

public Timer createTimer(long duration, java.io.Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
创建在指定时间段后过期的单个操作计时器。
duration 计时器过期之前必须经历的毫秒数。
info 要随计时器过期通知一起传送的应用程序信息。此参数可以为 null。
return 新建的 Timer。
ThrowsIllegalArgumentException: 如果 duration 为负。
ThrowsIllegalStateException: 如果在实例不允许访问此方法的情况下调用了此方法。
ThrowsEJBException: 如果此方法由于系统级失败而失败。
英文文档:

createTimer

Timer createTimer(long duration,
                  Serializable info)
                  throws IllegalArgumentException,
                         IllegalStateException,
                         EJBException
Create a single-action timer that expires after a specified duration.

Parameters:
duration - The number of milliseconds that must elapse before the timer expires.
info - Application information to be delivered along with the timer expiration notification. This can be null.
Returns:
The newly created Timer.
Throws:
IllegalArgumentException - If duration is negative
IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method fails due to a system-level failure.

public Timer createTimer(long initialDuration, long intervalDuration, java.io.Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
创建间隔计时器,其第一次过期发生在指定时间段后,其后续过期发生在指定间隔后。
initialDuration 第一次计时器过期通知之前必须经历的毫秒数。
intervalDuration 计时器过期通知之间必须经历的毫秒数。过期通知相对于第一次过期的时间进行安排。如果过期延迟(例如,由于与 Bean 上的其他方法调用交错),则可能会有两个或两个以上的过期通知接连出现以“赶上”延迟的时间。
info 要随计时器过期一起传送的应用程序信息。此参数可以为 null。
return 新建的 Timer。
ThrowsIllegalArgumentException: 如果 initialDuration 为负,或者 intervalDuration 为负。
ThrowsIllegalStateException: 如果在实例不允许访问此方法的情况下调用了此方法。
ThrowsEJBException: 如果此方法由于系统级失败而无法完成。
英文文档:

createTimer

Timer createTimer(long initialDuration,
                  long intervalDuration,
                  Serializable info)
                  throws IllegalArgumentException,
                         IllegalStateException,
                         EJBException
Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.

Parameters:
initialDuration - The number of milliseconds that must elapse before the first timer expiration notification.
intervalDuration - The number of milliseconds that must elapse between timer expiration notifications. Expiration notifications are scheduled relative to the time of the first expiration. If expiration is delayed(e.g. due to the interleaving of other method calls on the bean) two or more expiration notifications may occur in close succession to "catch up".
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
The newly created Timer.
Throws:
IllegalArgumentException - If initialDuration is negative, or intervalDuration is negative.
IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

public Timer createTimer(java.util.Date expiration, java.io.Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
创建在给定时间点过期的单个动作计时器。
expiration 计时器必须过期的时间点。
info 要随计时器过期通知一起传送的应用程序信息。此参数可以为 null。
return 新建的 Timer。
ThrowsIllegalArgumentException: 如果 expiration 为 null,或者 expiration.getTime() 为负。
ThrowsIllegalStateException: 如果在实例不允许访问此方法的情况下调用了此方法。
ThrowsEJBException: 如果此方法由于系统级失败而无法完成。
英文文档:

createTimer

Timer createTimer(Date expiration,
                  Serializable info)
                  throws IllegalArgumentException,
                         IllegalStateException,
                         EJBException
Create a single-action timer that expires at a given point in time.

Parameters:
expiration - The point in time at which the timer must expire.
info - Application information to be delivered along with the timer expiration notification. This can be null.
Returns:
The newly created Timer.
Throws:
IllegalArgumentException - If expiration is null, or expiration.getTime() is negative.
IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

public Timer createTimer(java.util.Date initialExpiration, long intervalDuration, java.io.Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
创建间隔计时器,其第一次过期发生在给定时间点,其后续过期发生在指定间隔后。
initialExpiration 第一次计时器过期必须发生的时间点。
intervalDuration 计时器过期通知之间必须经历的毫秒数。过期通知相对于第一次过期的时间进行安排。如果过期延迟(例如,由于与 Bean 上的其他方法调用交错),则可能会有两个或两个以上的过期通知接连出现以“赶上”延迟的时间。
info 要随计时器过期一起传送的应用程序信息。此参数可以为 null。
return 新建的 Timer。
ThrowsIllegalArgumentException: 如果 initialExpiration 为 null,或者 initialExpiration.getTime() 为负,或者 intervalDuration 为负。
ThrowsIllegalStateException: 如果在实例不允许访问此方法的情况下调用了此方法。
ThrowsEJBException: 如果此方法由于系统级失败而无法完成。
英文文档:

createTimer

Timer createTimer(Date initialExpiration,
                  long intervalDuration,
                  Serializable info)
                  throws IllegalArgumentException,
                         IllegalStateException,
                         EJBException
Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.

Parameters:
initialExpiration - The point in time at which the first timer expiration must occur.
intervalDuration - The number of milliseconds that must elapse between timer expiration notifications. Expiration notifications are scheduled relative to the time of the first expiration. If expiration is delayed(e.g. due to the interleaving of other method calls on the bean) two or more expiration notifications may occur in close succession to "catch up".
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
The newly created Timer.
Throws:
IllegalArgumentException - If initialExpiration is null, or initialExpiration.getTime() is negative, or intervalDuration is negative.
IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

public java.util.Collection<E> getTimers() throws IllegalStateException, EJBException
获得与此 Bean 相关的所有活动计时器。
return javax.ejb.Timer 对象的集合。
ThrowsIllegalStateException: 如果在实例不允许访问此方法的情况下调用了此方法。
ThrowsEJBException: 如果此方法由于系统级失败而无法完成。
英文文档:

getTimers

Collection getTimers()
                     throws IllegalStateException,
                            EJBException
Get all the active timers associated with this bean.

Returns:
A collection of javax.ejb.Timer objects.
Throws:
IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!