If you just want spring-like @PostConstruct and @PreDestroy methods support then there are many libs that implements it like https://github.com/mycila/guice, https://github.com/Netflix/governator etc. I even wrote my own https://github.com/xvik/guice-ext-annotations.
But, such things are against guice philosophy: https://github.com/google/guice/wiki/ModulesShouldBeFastAndSideEffectFree In short, you should avoid implicit bootstrap logic and do some special lifecycle service with start/stop methods which should be called from outside world. For example, in web application it could be servlet context listener which will call start / stop. четверг, 14 мая 2015 г., 15:50:16 UTC+6 пользователь klc написал: > > So my questions are: > 1. Is there a way to find out if a guice has been created? > 2. Is there a way to let guice to run deconstruct when server is closing? > (ie ServletContextListener.contextDestroyed) > > klc > > On Thursday, May 14, 2015 at 5:34:02 PM UTC+8, klc wrote: >> >> Sorry >> >> What i have now is a provider of let say a queue (Singleton scope). If >> the queue has been created, i will get from the injector and close it. (or >> is there a way to do this automatically?) >> This is on guice-servlet. >> >> klc >> >> On Thursday, May 14, 2015 at 5:31:20 PM UTC+8, scl wrote: >>> >>> Yes, but you have to be more specific if you want some concrete help >>> >>> Am 14. Mai 2015 11:25:52 MESZ, schrieb klc <[email protected]>: >>>> >>>> Hi Is there a way to destruct object in guice 4? >>>> >>>> I see guice fruit but i think it support guice 2. The object i'm >>>> closing are db, queue and etc. >>>> >>>> -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/f06afcb3-4d04-4ff5-9ef8-5e74915faf34%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
