2 Replies Latest reply on Sep 20, 2011 3:21 AM by pi4630

    TimerBean: Only one @Timeout on SLSB?

    pi4630

      I've two private methdos on my SLSB, say A and B.

      Both methods are annotated with @Timeout, return void, and take Timer as an argument.

       

      Two public methods implemented by the interface are basically doing the same thing: according to which one has been called, the create a TimerInfo instance (a container class [POJO] that implements java.io.Serializable, carrying a "label" and an "element", both String), set this instance as Info when creating the timer. Of course, before I create one, I lookup if a timer with that label and that element already exists.

       

      My client invokes the exposed method that should finish in having method A invoked.

       

      I then set two breakpoints, one at the beginning of A, the other at the beginning of B.

       

      When I debug my SLSB with a timer created with timerInfo set so that method A should be invoked, the breakpoint in A never gets active, but it the one in B! Of course, at the beginning of these private methods I check which timer is calling me and therefore do not execute the logic.

       

      A workaround could be using @Timeout only on one method, and then call the A or B according to the TimerInfo set, sort of "deviator" method.

       

      I enclose the sourcecode of my SLSB... I wonder what I've missed or completely got wrong about Timers.

       

       

      Thanks

      ~pasquale

        • 1. Re: TimerBean: Only one @Timeout on SLSB?
          jaikiran

          Pasquale Imbemba wrote:

           

          I've two private methdos on my SLSB, say A and B.

          Both methods are annotated with @Timeout, return void, and take Timer as an argument.

           

          You can't have more than one @Timeout method on a bean. The spec mandates that:

           

          A bean can have at most one timeout method for handling programmatic timers

          • 2. Re: TimerBean: Only one @Timeout on SLSB?
            pi4630

            Thanks for the quick reply, Jaikiran!

             

            My book didn't note the limitation explicitly. The "workaround" then is the correct way to address different timers. Wouldn't be bad if the compiler and/or the AS would state an error when compiling/deploying.