You can certainly do what's recommended here, but I find it's usually more readable and flexible to write some sort of "registry" of things, and invoke that - certainly if there's any chance you'll need to consume the collection in more than one place, or perform the same operation on all elements of it.
If you do that, you can then either keep using multi-binding for registration, or you can have a register() method on your "registry", and bind the things that must register themselves as eager singletons and have them register themselves in their constructor. If my guess about what "LifecycleAware" could be is right, this may be similar to what you are writing: https://github.com/timboudreau/giulius/blob/master/giulius/src/main/java/com/mastfrog/giulius/ShutdownHookRegistry.java and it has the additional advantage that you can call it programmatically from a test harness to do cleanup on test completion rather than VM shutdown. -Tim -- 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/groups/opt_out.
