Is there a recommended pattern for shutting down / closing objects created with Guice?
The lifecycle I'm aiming for is:
- Prepare a Guice Module
- Create an injector
- Use the injector through your code to obtain objects (
injector.getInstance(Foo.class)
) - ...
- Close any resources held by said objects (file handles, TCP connections, etc...). I want this to be a deterministic step (not "some day when the GC runs").