You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andrea Sacco <at...@ngi.it> on 2007/06/01 21:32:37 UTC

How to load a static class on Tomcat startup

Hello everybody,
I want to know how I can configure Tomcat to load my Singleton class on his 
startup routine? This class implement a cache that I want to stay in memory 
until Tomcat is shutted down.

I've read about context but it seem to load the class only on a particular
URL 
request..

I want the class to be loaded with Tomcat, without any request is made.

Thanks to all

Andrea

p.s.:I've also posted this message in the dev list and I'm sorry of the
mistake..

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.472 / Virus Database: 269.8.5/826 - Release Date: 31/05/2007
16.51
 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to load a static class on Tomcat startup

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 6/1/07, Caldarale, Charles R <Ch...@unisys.com> wrote:
> > From: Andrea Sacco [mailto:atreyuas@ngi.it]
> > Subject: How to load a static class on Tomcat startup
> >
> > I want to know how I can configure Tomcat to load my
> > Singleton class on his startup routine?


Make the Singleton class implement ServletContextListener ,
and register the Singleton class as a listener in web.xml

The syntax for registering the listener in web.xml is specific to
the version of Tomcat ( Servlet Specification ) you are using.

>
> Sounds like you need a Listener:
> http://tomcat.apache.org/tomcat-6.0-doc/config/engine.html#Lifecycle%20L
> isteners
> http://tomcat.apache.org/tomcat-5.5-doc/config/engine.html#Lifecycle%20L
> isteners
>
>  - Chuck


-Rashmi

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to load a static class on Tomcat startup

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Andrea Sacco [mailto:atreyuas@ngi.it] 
> Subject: How to load a static class on Tomcat startup
> 
> I want to know how I can configure Tomcat to load my 
> Singleton class on his startup routine?

Sounds like you need a Listener:
http://tomcat.apache.org/tomcat-6.0-doc/config/engine.html#Lifecycle%20L
isteners
http://tomcat.apache.org/tomcat-5.5-doc/config/engine.html#Lifecycle%20L
isteners

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org