You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by J Aaron Farr <fa...@apache.org> on 2003/12/16 00:01:15 UTC

RE: More Release()

On Tue, 2003-12-16 at 03:16, Day, Jem BGI SF wrote:
> My sense is that release() isn't anything directly to do with garbage collection.
> 
> All you're really saying IMHO is "i've finished with this 'thing'", thus allowing the  container/framework to recyle it, destroy it, or nominate it for an Oscar.
> 
> ie release() != finalize()

I've avoided this thread thus far, but I think this a good point.

My "impression" of release() is similar to close() on a database
connection.  I believe the more you think about this, the more you'll
see the similarities.

Think:

   javax.sql.DataSource ~= ServiceManager
   java.sql.Connection  ~= YourComponent

Similar to what was mentioned in the wiki, there's a simple choice in
JDBC:

either
  * explicitly handle the JDBC connections and risk tying up resources
or
  * Write tight JDBC, always closing the connection when you're done or
getting a new one from the DataSource when you need it.

For many situations, the first is fine, it works, and is very simple. 
In the second case you'll always know the code will work and you can
take advantage of a number of container managed features like connection
pooling, statement caching, and so on.  But of course, coding that way
is, as mentioned, a PITA.

If you want to take advantage of the rich semantics of Avalon
lifecycles, then you'll need to appropriately write your components. 
The nice thing is, you always have the choice (at least in your own
apps).

-- 
 jaaron  <http://jadetower.org>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org