A common way to do this is to use a multibinder to bind services, and have a service manager which starts up services post-injection. You can't easily follow the dependency graph without digging into the SPI, but you could use a MapBinder to declare services and what services they need to be started before they can start, and manually walk that graph.
Or provide an ordinal - a little like the way inetd does it, with level zero services starting before level one services, etc. Having said that, I'm looking at how lifecycle has been implemented in other containers, or in a guice fork and whether this can/should be brought into the main guice tree. Zero promises that this will be part of Guice, but it's on my list of improvements to examine. Christian. On Mar 3, 2012, at 11:08 AM, Adrian Cole wrote: > Considering normally, init methods perform some sort of heavy stuff, > I'd recommend against using providers for this. In jclouds, we > internally wire up @PostConstruct, and add a runnable to call said > methods to an executionlist, which is invoked after the injector is > created. This seems to be very similar to Mycilia, which looks quite > handy. > > -A > > On Tue, Feb 28, 2012 at 12:53 AM, David Nouls <[email protected]> wrote: >> Hi, >> >> That will not work with GIN/GWT. >> >> David >> >> On Monday, February 27, 2012 2:52:00 PM UTC+1, Marko Lavikainen wrote: >>> >>> This is probably your answer: >>> >>> http://code.google.com/p/mycila/wiki/MycilaGuice >>> >>> On 27 helmi, 11:53, David Nouls <[email protected]> wrote: >>>> Hi, >>>> >>>> I'm looking for a feature in Guice (and GIN) that allows me to call a >>>> method after injection has been done on an object. >>>> I found a blogpost that gives me a solution, but is really a cludge for >>>> something that should be somehow part of Guice. >>>> >>>> http://cristianvrabie.blogspot.com/2009/11/simulate-bean-initializati... >>>> >>>> <http://cristianvrabie.blogspot.com/2009/11/simulate-bean-initializati...> >>>> >>>> What I need is some kind of way to mark a method that needs to be >>>> invoked >>>> when construction, member and setter injections have been performed. >>>> >>>> I don't want to add some maybeInitialize method and call that from >>>> everywhere in the object since that will bring in multithreading issues. >>>> >>>> I can not/do not want to use constructor injection because in my case I >>>> have a baseclass that need injections but I don't want to polute the >>>> derived classes to also have to call super( ... ). This would basically >>>> expose the internals of the root class. >>>> >>>> David >> >> -- >> You received this message because you are subscribed to the Google Groups >> "google-guice" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/google-guice/-/Qzqir1dQgvUJ. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/google-guice?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
