On Mon, 6 Aug 2001, Erik Weber wrote:

> Hello all.
> 
> I have minimal experience with Tomcat, and didn't see any mention of this in
> looking over the docs.
> 
> I am used to developing in WebLogic. WebLogic supports what are called startup
> classes. You register the name of the class in the server's properties file,
> and when the server starts, it instantiates that class with arguments included
> in the properties file.
> 
> I have found this is a nice way to start up asynchronous subscribers to a
> messaging queue. Upon instantiation, which again is automatic, the various
> subscribers, in their constructors, simply register themselves as listeners
> with the queue.
> 
> I was wondering if Tomcat supports a similar construct as this (startup
> classes). If not, perhaps I could implement my queue subscribers as Servlets,
> but this seems strange, considering mulitple threads should not be running
> through a single subscriber.
> 
> Any thoughts or advice on this?
> 

The servlet 2.3 spec (and, therefore, Tomcat 4) supports a portable
mechanism for this kind of thing called "application event
listeners".  Using this, you can register (in web.xml) listeners that are
notified when the application is started and shut down -- quite helpful
for this sort of thing.

In a servlet 2.2 world, what most people do is declare a servlet to be
<load-on-startup> and initialize things in the init() method of that
servlet.  This is relying on the container to never unload that servlet
for the lifetime of the app (Tomcat doesn't unload anything until shutdown
time), but it basically works.

> -Erik
> 
> 

Craig McClanahan


Reply via email to