Book Image

Java EE 7 Development with NetBeans 8

By : David R Heffelfinger
5 (1)
Book Image

Java EE 7 Development with NetBeans 8

5 (1)
By: David R Heffelfinger

Overview of this book

Table of Contents (18 chapters)
Java EE 7 Development with NetBeans 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The EJB Timer service


Stateless session beans and message-driven beans (another type of EJB discussed later in the book) can have a method that is executed automatically at regular intervals. This functionality is useful if we want to execute some logic periodically (once a week, every day, every other 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. NetBeans provides a handy wizard that we can use to help us in the process.

The next step in the wizard allows us to select several options.

We can implement our bean either as a stateless or as a singleton session bean. We can also choose to create either a local or a remote interface. Local interfaces are optional, and remote interfaces are required only if we need to access our session bean from a different JVM. So, in our example, we choose not to create...