tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allistair Crossley" <>
Subject RE: [OFF-TOPIC]RE: Some pretty basic Tomcat ConnectionPoolingQuestions????
Date Tue, 14 Sep 2004 07:56:51 GMT
> 1. We should rename the DBConnection class to DBConnectionFactory. I
> have often wondered what a factory is in this sense, could you
> elaborate?

charles answered this very well :)

> 2. Adding a finalize() method in the external class 
> --> wouldn't that nullify the DataSource before we are 
> finished with it?
> --> isn't that doubling up with the destroy() method?
> --> how much better would it be to nullify the DataSource in a
> finalize() method, a destroy() method or both?

overriding the Object.finalize method ensures that the JRE will perform the statements contained
within it. You don't actually "need" to do this if you think the JRE will spot when your objects
are ready for GC, but sometimes it's good to explicitly do it. I normally write an interface
called DisposableObject that defines 1 method

public void destroy()

I override finalize to just call this method. That way, either an external call OR a JRE call
will get to destroy() to clean up any internal resources for sure.

finalize will only be called when all references to the factory are lost and therefore the
JRE starts to GC it. Yes it would double up if you have a destroy method but see my last commment
on linking the two.

> 3. I'd like to find out more about 'adding a static reference 
> to itself
> and adding a static method called getInstance()' 
> --> how much more efficient would that be?
> --> how do I implement that?
> </question>

here's a good tutorial on Singletons

hope this helps, Allistair

QAS Ltd.
Developers of QuickAddress Software
<a href=""></a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message