Resin Documentationapp server |
scheduled task
Resin's ScheduledTask capability lets you schedule
events using a flexible cron-style trigger. The task can be
any
When specified as an Java Injection bean, the bean task
has full IoC capabilities,
including injection,
Java Injection bean job configurationThe most common and flexible job configuration uses standard IoC
bean-style configuration. The bean must implement <web-app xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:com.caucho.resin"> <resin:ScheduledTask> <resin:cron>*/5</resin:cron> <qa:MyTask xmlns:qa="urn:java:com.caucho.resin"/> </ScheduledTask> </web-app> task reference job configurationThe task bean can also be passed to the ScheduledTask using
a Resin-IoC EL reference. The name of the task bean would be defined
previously, either in a <bean> or picked up by classpath
scanning. Like the bean-style job configuration, the reference bean must
implement <web-app xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:com.caucho.resin"> <resin:ScheduledTask task="#{taskBean}"> <resin:cron>0 0 *</resin:cron> </resin:ScheduledTask> </web-app> method reference job configurationScheduledTask can execute a method on a defined bean as the scheduler's task. The method is specified using EL reference syntax. At each trigger time, ScheduledTask will invoke the EL method expression. In the following example, the task invokes <web-app xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:com.caucho.resin" xmlns:qa="urn:java:qa"> <qa:MyBean> <Named>myBean</Named> </qa:MyBean> <resin:ScheduledTask method="#{myBean.myMethod}"> <resin:delay>10m</resin:delay> <resin:period>1h</resin:period> </resin:ScheduledTask> </web-app> url job configurationIn a <web-app>, the ScheduledTask can invoke a servlet URL
at the trigger times. The task uses the servlet <web-app xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:com.caucho.resin"> <resin:ScheduledTask url="/cron.php"> <resin:cron>0 15 * * 0</resin:cron> </resin:ScheduledTask> </web-app> cron trigger syntaxSome ascii art from the wikipedia cron entry # +---------------- minute (0 - 59) # | +------------- hour (0 - 23) # | | +---------- day of month (1 - 31) # | | | +------- month (1 - 12) # | | | | +---- day of week (0 - 6) (Sunday=0 or 7) # | | | | | * * * * *
Each field specifies a range of times to be executed. The patterns allowed are:
The minutes field is always required, and the hours, days, and months fields are optional.
|