TimerService (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.ejb Interface TimerService


public interface TimerService

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.


方法摘要
 Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info)
          Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.
 Timer createTimer(Date expiration, Serializable info)
          Create a single-action timer that expires at a given point in time.
 Timer createTimer(long initialDuration, long intervalDuration, Serializable info)
          Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.
 Timer createTimer(long duration, Serializable info)
          Create a single-action timer that expires after a specified duration.
 Collection getTimers()
          Get all the active timers associated with this bean.
 

方法详细信息

createTimer

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

参数:
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.
返回:
The newly created Timer.
抛出异常:
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.

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.

参数:
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.
返回:
The newly created Timer.
抛出异常:
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.

createTimer

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

参数:
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.
返回:
The newly created Timer.
抛出异常:
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.

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.

参数:
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.
返回:
The newly created Timer.
抛出异常:
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.

getTimers

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

返回:
A collection of javax.ejb.Timer objects.
抛出异常:
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.

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.