Java Reference
In-Depth Information
The asterisk character is a placeholder for all possible values for the given attribute. For example,
to set a schedule to trigger every hour, you would use the expression hour="*" for annotation‐
coni gured timers. For programmatic timers, you would invoke the method hour("*") on an instance
of the ScheduleExpression class.
You can express values for each attribute as a list or a range. For example, the expression
dayOfMonth="1, 15, last" sets the timer to trigger on the i rst, i fteenth, and last day of every
month, whereas the expression hour="8‐18" represents every hour from 08:00 until 18:00.
You can specify intervals and augment them with a starting point. The expression hour="8/1"
triggers every hour starting from 08:00, whereas the expression hour="*/12" triggers every
12 hours. However, you can only set intervals for seconds, minutes, and hour attributes.
Table 10-4 offers a few examples of the calendar‐based schedule in action.
TABLE 10-4: Examples of Expressions in Acti on
Every ten seconds
hour = "2",
Every two hours
minute = "15"
Every 15 minutes
dayOfWeek="Mon, Fri"
Every Monday and Friday at midnight
Every day at 8 a.m.
dayOfWeek="0‐7", hour="8"
Five days before the end of every month at midnight
First Monday of every month at 10 p.m.
dayOfMonth="1st Mon", hour="22"
The 15th of the following March
Month="Mar", dayOfMonth="15"
May 1, 2015 at midnight
year="2015", month="May"
New in the EJB 3.2 implementation is an enhancement to the timer service API that allows access to
all active timers in the EJB module. These include both programmatically and automatically created
LISTING 10‐3: All timers can be retrieved and manipulated
package com.devchronicles.timer;
import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.Singleton;
import javax.ejb.Startup;
Search WWH ::

Custom Search