[ https://issues.apache.org/jira/browse/ISIS-597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13830645#comment-13830645 ]
Oscar Bou commented on ISIS-597: -------------------------------- Thanks, Dan. Let me detail the use case. Perhaps there are other ways, but this is the only one I can think of. I have a Service that needs to instantiate a "server" at start-up. This "server" needs to be initialized with other Services, so they must be injected. On those Services, there are actions that use an Isis Session to create fixtures, obtain default values, etc. As it must be created on start-up, if I don't want to use Timers, etc. I think it should be done on @PostConstruct. If implemented on other Dependency Injection framework, such as Spring, I would define all beans and inject them as needed and also use the @PostConstruct method (just in the case that the "server" would not be defined also as a bean and injected). Are there any alternatives with Isis to ensure the "server" is created at start-up? Thanks, Oscar > Services still not injected when entering @PostConstruct methods on a Service > ----------------------------------------------------------------------------- > > Key: ISIS-597 > URL: https://issues.apache.org/jira/browse/ISIS-597 > Project: Isis > Issue Type: Improvement > Components: Core, Objectstore: JDO > Affects Versions: objectstore-jdo-1.3.0, core-1.3.0 > Reporter: Oscar Bou > Assignee: Dan Haywood > Fix For: objectstore-jdo-1.4.0, core-1.4.0 > > > Methods annotated with @PostConstruct are invoked before their objects being > injected. > Steps to reproduce: > As per [1], create a method on a service annotated with @PostConstruct, like > this one: > @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). > [1] http://isis.apache.org/core/services/initializing-services.html -- This message was sent by Atlassian JIRA (v6.1#6144)