December 2017
Intermediate to advanced
372 pages
8h 46m
English
The example in the previous section has one disadvantage: the startTimer() method in the session bean must be invoked from a client in order to start the timer. This restriction makes it difficult to have the timer start as soon as the bean is deployed.
Java EE 6 introduced calendar-based EJB timer expressions. Calendar-based expressions allow one or more methods in our session beans to be executed at a certain date and time. For example, we could configure one of our methods to be executed every night at 8:10 pm, which is exactly what our next example does:
package com.ensode.javaeebook.calendarbasedtimer; import java.util.logging.Logger; import javax.ejb.Stateless; import javax.ejb.LocalBean; import ...