-
1. Re: @Service and the TimerService
mwx.dennis Nov 13, 2009 6:32 AM (in response to mwx.dennis)Sorry, I got it wrong.
The timer service gets injected but I cannot set it up in the bean's constructor because the injection only happens after the constructor was run.
What I'm missing is the lifecycle callbacks such as @PostConstruct.
So my actual question is:
Why are there no lifecycle callbacks in @Service beans? -
2. Re: @Service and the TimerService
jaikiran Nov 13, 2009 6:55 AM (in response to mwx.dennis)It does support @PostConstruct. Did you try adding it to a method (with the correct signature) in that @Service?
-
3. Re: @Service and the TimerService
mwx.dennis Nov 13, 2009 7:21 AM (in response to mwx.dennis)When I put this in my @Service bean:
@PostConstruct public void init() { System.out.println("####################### init()"); }
I don't see the output in the log and I can definitely tell the bean is working.
Just to be sure, that's a @javax.annotation.PostConstruct inside a @org.jboss.ejb3.annotation.Service.
I'm on JBoss [The Oracle] 5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634) -
4. Re: @Service and the TimerService
mwx.dennis Nov 16, 2009 6:53 AM (in response to mwx.dennis)The same problem exists with @PreDestroy.
The bean is stopped by the container (at least the log message [EJBContainer] STOPPED EJB: .... is present) but the @PreDestroy method is not invoked. The signature is @PreDestroy public void shutdown(). -
5. Re: @Service and the TimerService
jaikiran Nov 16, 2009 9:13 AM (in response to mwx.dennis)Looking at the EJB3 code, i do believe that this should be working. Can you please apply the EJB3 plugin http://www.jboss.org/ejb3/ejb3plugin.html against AS-5.1.0 and see if it works? If that too doesn't work, then please post the entire service bean code and the relevant console logs.
The latest plugin can be downloaded from here http://www.jboss.org/ejb3/downloads.html. -
6. Re: @Service and the TimerService
mwx.dennis Nov 16, 2009 10:15 AM (in response to mwx.dennis)After applying the patch it works perfectly. Both the @PostConstruct and the @PreDestroy methods are executed.
Thanks a million, Jaikiran - you made my day!