enthuware.oce-ejbd.v6.2.429

Moderator: admin

Post Reply
jayrmotta
Posts: 3
Joined: Tue Jul 19, 2011 11:32 am
Contact:

enthuware.oce-ejbd.v6.2.429

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.oce-ejbd.v6.2.429

Post by admin »

You are right but @Startup is applicable only for singleton beans.
If you like our products and services, please help us by posting your review here.

PedroKowalski
Posts: 25
Joined: Thu Aug 04, 2011 10:36 am
Location: Poland
Contact:

Re: enthuware.oce-ejbd.v6.2.429

Post 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!

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.oce-ejbd.v6.2.429

Post 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!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests