[英]java web application - how to create scheduled task or event listener
I'm creating a web application, based on struts.. The thing is, that i need to do some scheduled task, or better than that an event listener... 我正在基于Struts创建一个Web应用程序。问题是,我需要执行一些计划任务,或者比事件侦听器更好。
The idea is that my web app saves some date fields in a database, and i want to make something that checks the content of every rows, and execute a method for the fields which date is the current date. 这个想法是我的Web应用程序在数据库中保存了一些日期字段,我想做一些检查每行内容的事情,并对日期为当前日期的字段执行一种方法。
My problem is that i have never performed a listener or a scheduled task before, and I'm very confused i don't know how to do it.. I've been reading other articles, but i don't get how to integrate it with my webapp.. 我的问题是我以前从未执行过侦听器或预定任务,而且我非常困惑,我不知道该怎么做。.我一直在阅读其他文章,但我不知道如何整合它与我的webapp ..
Thanks in advance ! 提前致谢 !
Quartz Scheduler is the best one in scheduling a job. Quartz Scheduler是安排工作的最佳选择。 Please refer the following links
请参考以下链接
http://www.javabeat.net/quartz-scheduler-tutorial/ http://www.javabeat.net/quartz-scheduler-tutorial/
http://www.mkyong.com/struts2/struts-2-quartz-scheduler-integration-example/ http://www.mkyong.com/struts2/struts-2-quartz-scheduler-integration-example/
(a) Needing a scheduled task is entirely different than needing an event listener. (a)需要计划任务与需要事件侦听器完全不同。 Focus your question.
集中您的问题。
(b) For a scheduled task… (b)对于预定任务…
The older class bundled with Java is a Timer . 与Java捆绑在一起的较早的类是Timer 。
The newer way is a ScheduledExecutorService . 更新的方法是ScheduledExecutorService 。
Each has pros and cons. 每个都有优点和缺点。 Search StackOverflow for examples.
搜索StackOverflow以获取示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.