Calendar Styled Timer
EJB 3.1 supports a new calendar based timer. This timer is modeled after the
UNIX Cron facility and can be used in stateless, singleton, and message driven beans.
Description of Example
In this example, we define a method of a singleton bean using a calendar
based timeout expression annotated with the @Schedule tag. This method adds
parameters to the bean in a specialized interval. These added parameters
mainly contain information about the time the method was called (for example,
"Wed Nov 17 11:06:47 CST 2010") and the number of times it has been called.
This timed method will terminate itself after it has been executed for a set
number of times (for example, after it has been executed five times). We
define a servlet to get the added parameters from the singleton bean and
display them to the customer to verify that the timed method worked.
Use This Example
Click "Run" to run this example and see the records of the executed timed method.
|