Comment #66 on issue 62 by james.strachan: Lifecycle support
http://code.google.com/p/google-guice/issues/detail?id=62

@mcculls yes - the problem isn't the 'start' part of lifecycle, its easy to do with the existing hooks. The big problem is trying to do a 'stop/close' or @PreDestroy in a clean way without hacks like forking guice (which guiceyfruit had to do) or writing your own custom Scope objects etc. (FWIW your idea only works if the stop hooks map exactly to the start hooks, which isn't the case in JSR 250).

We should be able to create an Injector, look up some objects then close down all the singletons for example without jumping through too many hoops. (Ditto Request / Session scope in guice-servlet).

Guice knows which objects have been created in a particular scope - they are stored in that scope (thats what a scope is afterall), so its kinda trivial to be able to iterate through a scope so you can close the objects - it just requires a fairly trivial change to guice to be able to do such a thing...
http://code.google.com/p/google-guice/issues/detail?id=354

Right now there are only a small subset of real 'stop' lifecycles you can do without hacking your own replacement Scopes, forking guice or solving a small subset through hacks (basically creating your own mirror scope keeping track of all the objects you post process in a start interceptor).

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" 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-dev?hl=en.

Reply via email to