1 Reply Latest reply on Dec 19, 2007 7:42 PM by Jake C

    using raiseTimedEvent / TimerSchedule

    Brian Cole Newbie

      I couldn't find a working example on the forums, so now I've got one, I thought I'd do the right thing and post.
      1. I'm using a POJO here, and didn't change my components.xml at all. If I was in a EJB component, I guess I could have used the EJB (or quartz?) timer service, but what I have here is all I needed.
      2. Seam 2.0 and JBoss 4.2.2.
      3. The event stuff in Seam is great. Thanks Seam people!

      import java.util.Date;
      import javax.ejb.Remove;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Create;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Observer;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Startup;
      import org.jboss.seam.annotations.async.Asynchronous;
      import org.jboss.seam.async.TimerSchedule;
      import org.jboss.seam.core.Events;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.log.Logging;
      public class ScheduleProcessor {
       private final Log log = Logging.getLog(ScheduleProcessor.class);
       public void init() {
       log.info("init at " + new Date());
       Events.instance().raiseTimedEvent("test3", TimerSchedule.ONCE_IMMEDIATELY);
       Events.instance().raiseTimedEvent("test4", new TimerSchedule(3000L, 8000L)); // delay of 3 secs, then run every 8 secs
       public void remove() {
       public void test1() {
       log.info("test 1");
       public void test2() {
       log.info("test 2");
       public void test3() {
       log.info("test 3");
       public void test4() {
       log.info("test 4");

        • 1. Re: using raiseTimedEvent / TimerSchedule
          Jake C Newbie

          I've been using a variation of this in Seam 1.1.5.GA where my Asynchronous method returns javax.ejb.Timer, and I declare "@In Timer timer;" in my class, so I can cancel the Timer if I need to.

          However, in Seam 2.0.1.CR1, as soon as I declare "@In Timer timer;" in my class, Events.instance().raiseAsynchronousEvent() and Events.instance().raiseTimedEvent() don't generate events any more. I don't get any errors or anything, I just don't receive events.

          How do I use Events.instance().raiseTimedEvent() where I have access to the Timer object in Seam 2.0.1.CR1?