Comment #75 on issue 62 by [email protected]: Lifecycle support
http://code.google.com/p/google-guice/issues/detail?id=62
I wouldn't use Closeable (#1) here. It would be surprising to me if Guice
called close() on my objects just because they happen to implement
Closeable. Also, "close" doesn't fit all of the use cases.
If anything, we'd support @PreDestroy, but again, what are the use cases? A
looked through the first 20 or so pages of results on koders.com and didn't
see one interesting usage. I can try to imagine some:
1. Closing I/O resources
2. Shutting down threads and executors
3. Proactively freeing native memory
4. Removing external references (listeners, etc.)
...
@PreDestroy doesn't seem like a good solution to any of these. Use
try-finally, try-with-resources, references, explicit shut down logic,
etc., instead, and your code will be less error prone and more
maintainable. No offense intended to Hani and others than were on JSR-250,
but my sense is that @PreDestroy is an annotation in search of a problem.
--
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.