O'Reilly logo

Java EE 6 Development with NetBeans 7 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 (another type of EJB discussed in the next chapter) can have a method that is executed automatically at regular intervals. This functionality is useful in case we want to execute some logic periodically (once a week, every day, every hour, and so on) without having to explicitly call any methods. This functionality is achieved by the EJB Timer Service.

In order to use the EJB timer service, we need to use the @Schedule annotation to specify when our method will be called. The following example illustrates how to use the EJB timer service:

package com.ensode.ejbtimer.ejb; import java.util.Date; import javax.ejb.Stateless; import javax.ejb.LocalBean; import javax.ejb.Schedule; @Stateless ...

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