How do I wire up my web.xml to have a task happen every n many seconds. Moreover, I need to have a server method refresh every 5 seconds via a method call.
Much thanks in advance
SOLVED:
http://javaprogrammingtips4u.blogspot.com/2010/05/how-to-implement-task-scheduler-job.html
You can annotate the desired routine using
public class Foo {
@Scheduled(fixedDelay=5000)
public void Bar() {
// ...
}
}
But in order to for Spring for find and recognize the annotation you must declare which base package the class Foo
lies in as well as configure Spring to look for scheduling tasks. Put the following in your spring XML configuration (and don't forget to import the XML namespaces context
and task
).
<context:component-scan base-package="com.company.scheduling"/>
<task:annotation-driven />
Alternatively you can put @EnableScheduling before the class declaration and it does the XML config for you out of the box.
See also the context namespace and the task namespace.
You can use the Quartz scheduler integration as documented here: http://static.springsource.org/spring/docs/2.0.8/reference/scheduling.html
I do not understand the 2nd part of your question about refreshing a server method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With