trigger method on future date in java
I am using java spring framework to develop a开发者_如何转开发 Webapp. I have a situation where I want to trigger one method at future date( value of the future date is retrieved from database)
I tried spring quartz but it starts running as its xml configuration is loaded and I want to trigger the method only once in the future time.so the date should be able to be set programmatically not from XML configuration
eg
methodOne(futureDate)
{
//on futureDate it calls
methodTwo(<some args>)
}
What would be the good way to achieve this ?
Thanks in advance!
Quartz Scheduler is configurable programatically. I have used it before for user-controlled scheduling, and it can do exactly what you need.
Read all the tutorial pages (specially the one about SimpleTrigger), and you'll have a better understanding of its capabilities.
did you take a look at the timer api from java se?
http://download.oracle.com/javase/6/docs/api/java/util/Timer.html
http://download.oracle.com/javase/6/docs/api/java/util/TimerTask.html
here's an example on roseindia: http://www.roseindia.net/java/example/java/util/CertainAndRepeatTime.shtml
hope that helped
精彩评论