Top Description Methods
javax.ejb

public Interface Timer

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

The Timer interface contains information about a timer that was created through the EJB Timer Service.
Since
EJB 2.1

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Cause the timer and all its associated expiration notifications to be cancelled.

public TimerHandle

Returns:

a serializable handle to the timer.
getHandle
()

Get a serializable handle to the timer.

public Serializable

Returns:

The Serializable object that was passed in at timer creation, or null if the info argument passed in at timer creation was null.
getInfo
()

Get the information associated with the timer at the time of creation.

public Date

Returns:

the point in time at which the next timer expiration is scheduled to occur.
getNextTimeout
()

Get the point in time at which the next timer expiration is scheduled to occur.

public ScheduleExpression

Returns:

schedule expression for the timer.
getSchedule
()

Get the schedule expression corresponding to this timer.

public long

Returns:

the number of milliseconds that will elapse before the next scheduled timer expiration.
getTimeRemaining
()

Get the number of milliseconds that will elapse before the next scheduled timer expiration.

public boolean

Returns:

boolean indicating whether the timer is calendar-based.
isCalendarTimer
()

Return whether this timer is a calendar-based timer.

public boolean

Returns:

boolean indicating whether the timer is persistent.
isPersistent
()

Return whether this timer has persistent semantics.

Method Detail

cancelback to summary
public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException

Cause the timer and all its associated expiration notifications to be cancelled.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
EJBException:
If this method could not complete due to a system-level failure.
getHandleback to summary
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException

Get a serializable handle to the timer. This handle can be used at a later time to re-obtain the timer reference.

Returns:TimerHandle

a serializable handle to the timer.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method. Also thrown if invoked on a non-persistent timer.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
EJBException:
If this method could not complete due to a system-level failure.
getInfoback to summary
public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException

Get the information associated with the timer at the time of creation. This may be the info string that was passed to the timer creation method or the info element of the Schedule annotaiton.

Returns:Serializable

The Serializable object that was passed in at timer creation, or null if the info argument passed in at timer creation was null.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
EJBException:
If this method could not complete due to a system-level failure.
getNextTimeoutback to summary
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, NoMoreTimeoutsException, EJBException

Get the point in time at which the next timer expiration is scheduled to occur.

Returns:Date

the point in time at which the next timer expiration is scheduled to occur.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
NoMoreTimeoutsException:
Indicates that the timer has no future timeouts
EJBException:
If this method could not complete due to a system-level failure.
getScheduleback to summary
public ScheduleExpression getSchedule() throws IllegalStateException, NoSuchObjectLocalException, EJBException

Get the schedule expression corresponding to this timer. The timer must be a calendar-based timer. It may have been created automatically or programmatically.

Returns:ScheduleExpression

schedule expression for the timer.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method. Also thrown if invoked on a timer that is not a calendar-based timer.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
EJBException:
If this method could not complete due to a system-level failure.
Since
EJB 3.1
getTimeRemainingback to summary
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, NoMoreTimeoutsException, EJBException

Get the number of milliseconds that will elapse before the next scheduled timer expiration.

Returns:long

the number of milliseconds that will elapse before the next scheduled timer expiration.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
NoMoreTimeoutsException:
Indicates that the timer has no future timeouts
EJBException:
If this method could not complete due to a system-level failure.
isCalendarTimerback to summary
public boolean isCalendarTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException

Return whether this timer is a calendar-based timer.

Returns:boolean

boolean indicating whether the timer is calendar-based.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
EJBException:
If this method could not complete due to a system-level failure.
Since
EJB 3.1
isPersistentback to summary
public boolean isPersistent() throws IllegalStateException, NoSuchObjectLocalException, EJBException

Return whether this timer has persistent semantics.

Returns:boolean

boolean indicating whether the timer is persistent.

Exceptions
IllegalStateException:
If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException:
If invoked on a timer that has expired or has been cancelled.
EJBException:
If this method could not complete due to a system-level failure.
Since
EJB 3.1