Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (

Part Number E13981-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

Understanding EJB Timer Services

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.


Timers apply to all EJB types except stateful session beans and EJB 3.0 entities.

EJB timers are supported only in an OC4J instance that runs on a single JVM (where numprocs=1 in the <process-set> element of the opmn.xml configuration file).

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

Understanding Java EE 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".

Understanding OC4J Cron Timer Services

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