Just to point it out, as per [1] and [2], @PostConstruct should only be called after all dependencies have been injected.
Thanks again, Oscar [1] http://docs.oracle.com/javaee/5/api/javax/annotation/PostConstruct.html [2] http://wiki.eclipse.org/Eclipse4/RCP/Dependency_Injection#.40PostConstruct.2C_.40PreDestroy_.28javax.annotation.29 El 17/11/2013, a las 17:15, GESCONSULTOR - Óscar Bou <o....@gesconsultor.com> escribió: > Hi to all. > > I have an Isis service that needs to initialize a "server" upon creation > (it's a Drools session, but it would be the same with an email server, for > instance). > > For initializing that "server", I need to pass it references to other Isis > services (in this case Drools globals). > > If, as per [1], I try like this: > > @PostConstruct > public void init(final Map<?, ?> props) { > > server.setGlobal("eventOccurrences", this.eventOccurrences); > > > } > > .... > > // {{ injected: EventOccurrences > private EventOccurrences eventOccurrences; > > public final void injectEventOccurrences(final EventOccurrences > eventOccurrences) { > this.eventOccurrences = eventOccurrences; > } > > // }} > > > The problem is that when the execution arrives to: > server.setGlobal("eventOccurrences", this.eventOccurrences); > > > this.eventOccurrences is still null... So it has not yet been injected (or > instantiated). > > I must ensure that the server starts to run from the beginning of the Isis > application execution. > > There's a note on [1] footer, but I thought this is not the case, as my only > expectation is that services are injected when calling "@PostConstruct" > methods. > > > Perhaps I'm missing something basic or the previous expectation is precisely > the one explicited by the footer note ... > > If that's the case, is there a better way to solve it? > > > Thanks, > > Oscar > > > [1] http://isis.apache.org/core/services/initializing-services.html > > > > >