08 July, 2011

Spring: annotation driven and configured scheduler

Properties file (file.properties):

...
manager.cron=0 */1 * * * ?
...


Application context (context.xml)

...
<context:property-placeholder location="file.properties"/>
<task:annotation-driven/>
...


Bean:

@Component
public class Manager {
...
@Scheduled(cron = "${manager.cron}")
public void doSomething() {
log.info("doSomething");
}
...
}

No comments: