4 Replies Latest reply on Aug 14, 2007 8:59 AM by vadger

    Qestion about timers in jboss seam

    vadger

      Hello,

      In documentation I've found that jboss seam has timer possibility. The question is, how I can initialize timer task on application deploy time. The possible way is via context listener in web.xml where I'll invoke EJB method that is represented as timer. Is there another way to initialize timer task on application start up?

      Thanks.

        • 1. Re: Qestion about timers in jboss seam
          pmuir

          Use

          @Observer("org.jboss.seam.postInitialization")


          • 2. Re: Qestion about timers in jboss seam
            vadger

            Am I right, if I have for instance:

            @Stateful
            @Name("paymentAction")
            public class CreatePaymentAction
            {
             @In(create=true) PaymentHandler paymentHandler;
             @In Bill bill;
            
             public String schedulePayment()
             {
             paymentHandler.processScheduledPayment( new Payment(bill), bill.getDueDate() );
             return "success";
             }
            
             public String scheduleRecurringPayment()
             {
             paymentHandler.processRecurringPayment( new Payment(bill), bill.getDueDate(),
             ONE_MONTH );
             return "success";
             }
            }


            The example is taken from seam documentation.
            So, if I want to invoke method at deploy time, I have to do next:

            @Stateful
            @Name("paymentAction")
            public class CreatePaymentAction
            {
             @In(create=true) PaymentHandler paymentHandler;
             @In Bill bill;
            
             public String schedulePayment()
             {
             paymentHandler.processScheduledPayment( new Payment(bill), bill.getDueDate() );
             return "success";
             }
            
             @Observer("org.jboss.seam.postInitialization")
             public String scheduleRecurringPayment()
             {
             paymentHandler.processRecurringPayment( new Payment(bill), bill.getDueDate(),
             ONE_MONTH );
             return "success";
             }
            }


            ?



            • 3. Re: Qestion about timers in jboss seam
              pmuir

              Yup, though you probably don't need it to be stateful.

              • 4. Re: Qestion about timers in jboss seam
                vadger

                tnx a lot :) JBoss Seam is really smart and elegant application framework, I like it :)