From: Marc P. <ma...@an...> - 2003-07-16 16:59:03
|
On Wed, 16 Jul 2003 09:51:57 -0700, Brian Goetz <br...@qu...> wrote: >> How about a totally trivial solution. Add a new method to ContextTool: >> >> >> boolean isDestroyRequired(); >> >> CTs implement this and return true if they want their destroy() called. >> This way we have a complete contract for it - implement destroy() >> accordingly if you return true from isDestroyRequired, and if you never >> need it just return false and don't do anything in destroy(). > > You are missing the hard part -- how does the Context know when its > done? The question is whether we have to make the user explicitly > destroy the context, which I don't want to force all users to do just > because some tools I've never seen want this. Hmmm, well why not have explicity Context "close()" paradigm? It's standard resource allocation stuff. Worst case scenario, we end up with the GC collecting the Context and close() getting called implicitly from the finalizer. That's a worst case the same as what we have now (no recycle() method any more), and a best case where the programmer reads the docs and calls context.close() in a finally block just like they close streams. I don't see a problem here. Either way it will go away eventually, and for those of us with brain cells, it will go away quickly. -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |