On 4 Apr 2014, at 16:08, Jochen Wiedmann <[email protected]> wrote: > On Friday, April 4, 2014 4:39:41 PM UTC+2, Stuart McCulloch wrote: > > So it could happen if a type is bound, but never gets injected - could you > share more details of what you expect vs. what you see? > > Thanks, Stuart, > > that's exactly the case, and this will help me now. > > For the future: Can I enforce invocation in any other way? As you may have > guessed, the context is handling the @PostConstruct annotation, and I would > want that to happen immediately, not after possibly quite some time, when the > object is actually being used.
If you use Stage. PRODUCTION when creating the injector then any singletons will be eagerly created, is that what you're looking for? BTW, if you want support for @PostConstruct and @PreDestroy you might want to take a look at http://onami.apache.org/lifecycle/org.apache.onami.lifecycle.standard/index.html I typically use TypeListener to select types requiring lifecycle support, InjectionListener to schedule instances of those types, and ProvisionListener to handle cycles (by detecting when we're already provisioning something) ( see examples under https://github.com/eclipse/sisu.inject/tree/master/org.eclipse.sisu.inject/src/org/eclipse/sisu/bean, specifically the Lifecycle* and BeanScheduler classes ) > Jochen -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/d/optout.
