Creating and using declarative timers

Declarative timers, also called automatic timers, offer a technique to declare a timer using annotations. The @Schedule annotation accepts a set of arguments defining a timer event. The annotation specifies the time the event is to occur and declares the callback method. This technique provides an easy to use and intuitive way of scheduling application tasks.

Getting ready

The process of creating a declarative timer includes:

  1. Creating a method to perform some task
  2. Adding the @Schedule or @Schedules annotation to a method

    The argument of the @Schedule consists of a set of time elements that correspond to fields of a ScheduleExpression object. These fields specify when and how often a timer callback will be made. ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.