Timer Service

J2EE 1.4 introduced a new Timer Service that can be used by both stateful and stateless Session beans (also Entity beans; this is covered on Day 6). The Timer Service enables a bean to be notified when a specific time period has elapsed or a specific date has arrived. The Timer Service allows a bean to trigger activity at some point in the future; for example, a stateless Session bean could reload cached data from a database every day at midnight.

An EJB schedules a timed notification using a reference to a javax.ejb.TimerService object obtained from its EJBContext (SessionContext for a Session bean). A TimerService object supports notification on a specific date, after some period of time, or at recurring intervals. The following ...

Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.