Page 1 of 1

enthuware.oce-ejbd.v6.2.429

Posted: Thu Jul 21, 2011 12:08 am
by jayrmotta
In case of programmatic timer creation (i.e. the one that uses TimerService dependency injection), the timer is created by the bean code at runtime. Therefore, if the code that creates the timer doesn't execute, the timer will not be created. Note that even the @PostConstruct method is guaranteed to be called only before the execution of a business method. So, if a business method is not called, there is no guarantee that the @PostConstruct method will be called. So programmatic timer creation cannot be relied upon in this case.
It's not true, we can rely on the @Startup annotation to ensure that @PostConstruct will be executed as a application lifecycle callback, and then creating the timer.

Re: enthuware.oce-ejbd.v6.2.429

Posted: Thu Jul 21, 2011 7:27 am
by admin
You are right but @Startup is applicable only for singleton beans.

Re: enthuware.oce-ejbd.v6.2.429

Posted: Thu Aug 04, 2011 10:41 am
by PedroKowalski
Ok, so what do you think about this.

I have an EJB which makes a programmatic upon particular business method is invocation, BUT I invoke this method from another Singleton EJB (@Startup) - just a type of TimerInitializerBean.

I understand what was the purpose of this question and that my case is a tremendously impractical, but... maybe the question could be rephrased?

What do you think?

Cheers!

Re: enthuware.oce-ejbd.v6.2.429

Posted: Sun Aug 07, 2011 9:26 am
by admin
Yes, it is not entirely impossible to do so. You may even achieve it without timers using some thread and calendar logic. After all, that is what people were doing before Timer functionality was available.

But then again, as you said, that defeats the purpose of the question. Even so, I guess it might be better to update the option to say, "This can be achieved best using automatic timer creation."

thanks for your feedback!