Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
You can set up a timer that invokes a timeout callback method at a specified time, after a specified elapsed time, or at specified intervals.
Note:
Timers apply to all EJB types except stateful session beans and EJB 3.0 entities.For EJB 3.0 applications, using the @Timeout
annotation, you can annotate any EJB method as the timeout callback method.
For EJB 2.1 applications, your EJB must implement the TimedObject
interface and provide a timeout callback method named ejbTimeout
.
Timers are for use in modeling of application-level processes, not for real-time events.
OC4J provides standard Java EE timers as well as a convenient Java EE timer extension that allows configuration similar to the Unix cron utility.
For more information, see:
Timer and timeout callback methods should be called within a transaction. OC4J supports transaction attribute REQUIRES_NEW
for timeout callbacks. For more information on transaction attributes, see "How are Transactions Handled When a Client Invokes a Business Method?").
An enterprise bean accesses EJB timer services by means of dependency injection, through the EJBContext
interface, or through lookup in the JNDI namespace.
For more information, see "Configuring Timer Services".
The EJB timer service is a container-managed service you use to define callback methods on your EJB that are scheduled for time-based events. The EJB timer service provides a reliable and transactional notification service for timed events. Timer notifications may be scheduled to occur at a specific time, after a specific elapsed duration, or at specific recurring intervals. You can define callback methods on your EJB to receive these time-based events. The Java EE timer service is implemented by OC4J.
For more information, see "Configuring an Enterprise Bean With a Java EE Timer".
In UNIX, you can schedule a cron timer to execute regularly at specified intervals. Oracle has extended OC4J to support cron timers with EJB. You can use cron expressions for scheduling timer events with EJB deployed to OC4J. Using an OC4J cron timer, you can create timers that invoke a timeout callback method or any arbitrary Java class's main
method.
For more information, see "Configuring an Enterprise Bean With an OC4J Cron Timer".