tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Flaumenhaft" <...@sidelight.com>
Subject Re: Life of a class?
Date Thu, 01 Mar 2001 20:09:00 GMT

Hi Neil,

Your pool class probably has a static member for the single instance
retrieved by getInstance (), right? If so, this instance is reset only when
the server is restarted or stopped, or when you explicitly release it
yourself.

(By the way, Tomcat maintains a separate classloader for each context (i.e.,
each webapp). Static variables exist within the classloader. This means if
you have multiple contexts, i.e., the same app instantiated several times in
the same Tomcat, you'll have several instances).

Regards,
Ben Flaumenhaft
Principal, Sidelight Consulting
http://www.sidelight.com

----- Original Message -----
From: "Neil Edney" <neil.edney@cmgplc.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Thursday, March 01, 2001 2:00 AM
Subject: Life of a class?


> Hi,
>
> We have implemented a database connection pool class (extract below) and
use
> the 'getInstance' method to ensuire that there is only one instance
created
> at any one time.
>
> What we need to know is when will this class be destroyed? Is it went the
> server is stopped (or crashed!) or will it timeout after a period of
> non-use?
>
> Regards,
> Neil
>
>
> public class DbPool extends Object implements java.io.Serializable {
>
>     private static DbPool instance;
>
>     public static DbPool getInstance(){
>         if (instance == null)
>             instance = new DbPool();
>         return instance;
>     }
>
>     /** Creates new dbPool */
>     private DbPool(){
>
>         /** dbPool code */
>
>     }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
>


Mime
View raw message