Top Description Methods
javax.ejb

public Interface TimerService

Imports
java.io.Serializable, java.util.Date, .Collection

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

Method Summary

Modifier and TypeMethod and Description
public Timer

Returns:

the newly created Timer.
createCalendarTimer
(ScheduleExpression
a schedule expression describing the timeouts for this timer.
schedule
)

Create a calendar-based timer based on the input schedule expression.

public Timer

Returns:

the newly created Timer.
createCalendarTimer
(ScheduleExpression
a schedule expression describing the timeouts for this timer.
schedule
,
TimerConfig
timer configuration.
timerConfig
)

Create a calendar-based timer based on the input schedule expression.

public Timer

Returns:

the newly created Timer.
createIntervalTimer
(long
The number of milliseconds that must elapse before the first timer expiration notification.
initialDuration
,
long
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".
intervalDuration
,
TimerConfig
timer configuration
timerConfig
)

Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.

public Timer

Returns:

the newly created Timer.
createIntervalTimer
(Date
the point in time at which the first timer expiration must occur.
initialExpiration
,
long
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".
intervalDuration
,
TimerConfig
timer configuration.
timerConfig
)

Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.

public Timer

Returns:

the newly created Timer.
createSingleActionTimer
(long
the number of milliseconds that must elapse before the timer expires.
duration
,
TimerConfig
timer configuration.
timerConfig
)

Create a single-action timer that expires after a specified duration.

public Timer

Returns:

the newly created Timer.
createSingleActionTimer
(Date
the point in time at which the timer must expire.
expiration
,
TimerConfig
timer configuration.
timerConfig
)

Create a single-action timer that expires at a given point in time.

public Timer

Returns:

the newly created Timer.
createTimer
(long
the number of milliseconds that must elapse before the timer expires.
duration
,
Serializable
application information to be delivered along with the timer expiration notification. This can be null.
info
)

Create a single-action timer that expires after a specified duration.

public Timer

Returns:

the newly created Timer.
createTimer
(long
The number of milliseconds that must elapse before the first timer expiration notification.
initialDuration
,
long
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".
intervalDuration
,
Serializable
application information to be delivered along with the timer expiration. This can be null.
info
)

Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.

public Timer

Returns:

the newly created Timer.
createTimer
(Date
The point in time at which the timer must expire.
expiration
,
Serializable
application information to be delivered along with the timer expiration notification. This can be null.
info
)

Create a single-action timer that expires at a given point in time.

public Timer

Returns:

the newly created Timer.
createTimer
(Date
the point in time at which the first timer expiration must occur.
initialExpiration
,
long
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".
intervalDuration
,
Serializable
application information to be delivered along with the timer expiration. This can be null.
info
)

Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.

public Collection<Timer>

Returns:

a collection of javax.ejb.Timer objects.
getAllTimers
()

Returns all active timers associated with the beans in the same module in which the caller bean is packaged.

public Collection<Timer>

Returns:

a collection of javax.ejb.Timer objects.
getTimers
()

Returns all active timers associated with this bean.

Method Detail

createCalendarTimerback to summary
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException

Create a calendar-based timer based on the input schedule expression.

Parameters
schedule:ScheduleExpression

a schedule expression describing the timeouts for this timer.

Returns:Timer

the newly created Timer.

Exceptions
IllegalArgumentException:
If Schedule represents an invalid schedule expression.
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.
Since
EJB 3.1
createCalendarTimerback to summary
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException

Create a calendar-based timer based on the input schedule expression.

Parameters
schedule:ScheduleExpression

a schedule expression describing the timeouts for this timer.

timerConfig:TimerConfig

timer configuration.

Returns:Timer

the newly created Timer.

Exceptions
IllegalArgumentException:
If Schedule represents an invalid schedule expression.
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.
Since
EJB 3.1
createIntervalTimerback to summary
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) 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:long

The number of milliseconds that must elapse before the first timer expiration notification.

intervalDuration:long

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".

timerConfig:TimerConfig

timer configuration

Returns:Timer

the newly created Timer.

Exceptions
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.
Since
EJB 3.1
createIntervalTimerback to summary
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) 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:Date

the point in time at which the first timer expiration must occur.

intervalDuration:long

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".

timerConfig:TimerConfig

timer configuration.

Returns:Timer

the newly created Timer.

Exceptions
IllegalArgumentException:
If initialExpiration is null, if initialExpiration.getTime() is negative, or if 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.
Since
EJB 3.1
createSingleActionTimerback to summary
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException

Create a single-action timer that expires after a specified duration.

Parameters
duration:long

the number of milliseconds that must elapse before the timer expires.

timerConfig:TimerConfig

timer configuration.

Returns:Timer

the newly created Timer.

Exceptions
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.
Since
EJB 3.1
createSingleActionTimerback to summary
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException

Create a single-action timer that expires at a given point in time.

Parameters
expiration:Date

the point in time at which the timer must expire.

timerConfig:TimerConfig

timer configuration.

Returns:Timer

the newly created Timer.

Exceptions
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.
Since
EJB 3.1
createTimerback to summary
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException

Create a single-action timer that expires after a specified duration.

Parameters
duration:long

the number of milliseconds that must elapse before the timer expires.

info:Serializable

application information to be delivered along with the timer expiration notification. This can be null.

Returns:Timer

the newly created Timer.

Exceptions
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.
createTimerback to summary
public 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:long

The number of milliseconds that must elapse before the first timer expiration notification.

intervalDuration:long

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:Serializable

application information to be delivered along with the timer expiration. This can be null.

Returns:Timer

the newly created Timer.

Exceptions
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.
createTimerback to summary
public 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:Date

The point in time at which the timer must expire.

info:Serializable

application information to be delivered along with the timer expiration notification. This can be null.

Returns:Timer

the newly created Timer.

Exceptions
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.
createTimerback to summary
public 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:Date

the point in time at which the first timer expiration must occur.

intervalDuration:long

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:Serializable

application information to be delivered along with the timer expiration. This can be null.

Returns:Timer

the newly created Timer.

Exceptions
IllegalArgumentException:
If initialExpiration is null, if initialExpiration.getTime() is negative, or if 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.
getAllTimersback to summary
public Collection<Timer> getAllTimers() throws IllegalStateException, EJBException

Returns all active timers associated with the beans in the same module in which the caller bean is packaged. These include both the programmatically-created timers and the automatically-created timers.

Returns:Collection<Timer>

a collection of javax.ejb.Timer objects.

Exceptions
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.
Since
EJB 3.2
getTimersback to summary
public Collection<Timer> getTimers() throws IllegalStateException, EJBException

Returns all active timers associated with this bean. These include both the programmatically-created timers and the automatically-created timers.

Returns:Collection<Timer>

a collection of javax.ejb.Timer objects.

Exceptions
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.