O'Reilly logo

Java EE 6 with GlassFish 3 Application Server by David R. Heffelfinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

EJB timer service

Stateless session beans and message-driven beans can have a method that is executed periodically at regular intervals of time. This can be accomplished by using the EJB timer service. The following example illustrates how to take advantage of this service:

package net.ensode.glassfishbook; import java.io.Serializable; import java.util.Collection; import java.util.Date; import java.util.logging.Logger; import javax.annotation.Resource; import javax.ejb.EJBContext; import javax.ejb.Stateless; import javax.ejb.Timeout; import javax.ejb.Timer; import javax.ejb.TimerService; @Stateless public class EjbTimerExampleBean implements EjbTimerExample { private static Logger logger = Logger.getLogger(EjbTimerExampleBean.class.getName()); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required