users@glassfish.java.net

Re: Want to schedule task for every night at 8pm, using Java,Servlet,JSP

From: <glassfish_at_javadesktop.org>
Date: Wed, 16 Jan 2008 07:38:27 PST

Just an FYI that this is a topic we're planning on addressing in the next version of the EJB spec (EJB 3.1 -- JSR 318) by adding support for calendar-based time expressions and automatically created timers. The use-case you mentioned will be doable with something that looks like this :

@Stateless
public class TaskBean {

   @Schedule(hour="20")
   public void doTask(Timer t) {
      ...
   }

}

The timer will be created automatically as a result of deployment, so there would be no need to programmatically create it within a servlet init callback. We'll also be supporting the packaging of EJB components directly within a .war(without the need for an ejb-jar), so it won't be an issue to take advantage of this from your web application.
[Message sent by forum member 'ksak' (ksak)]

http://forums.java.net/jive/thread.jspa?messageID=254207