tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Stevens <...@latchkey.com>
Subject Re: Webapp initialization (tomcat 4)
Date Tue, 15 May 2001 21:59:59 GMT
on 5/15/01 11:18 AM, "Peter Mutsaers" <peter@mutsaers.com> wrote:

> Hello,
> 
> I have some questions on webapp initialization.
> 
> sorry to send this to both tomcat-user and tomcat-dev; since I use
> tomcat 4 I wasn't sure where to send this to. I hope that my questions
> are answered by some brand new, not yet documented features of
> tomcat-4 :)

Tomcat-user is the right place.

> Browsing through documents, it seems like the only way to create some
> initial objects (such as a JDBC connection pool) in the ServetContext
> is to create a Servlet with load-on-startup, which then in its init()
> method can do some initialization.

You could implement a Singleton based Service. This is what Turbine did. It
has an entire Service framework for dealing with exactly this problem. It
takes care of startup and destroy. There is also a very good JDBC connection
pool included with Turbine, however, it isn't strictly J2FooEE so you may
have to fight those pointy haired bosses who only regurgitate what they read
in magazines.

<http://jakarta.apache.org/turbine/>

> Another topic: Am I correct in believing that
> ServletContext.getContext(uri) is the only way to obtain stuff from
> another webapps' ServletContext?
> 
> In fact what I would like is to create a JDBC Connection Pool to be
> shared amongst various webapps. I could create this pool Object in one
> webapp (via the clumsy Servlet load-on-startup), then copy a reference
> to the ServletContexts of the other webapps. This creates some
> ordering problems (the other webapps may not run until the webapp
> setting up the connection pool is ready).

IMHO, A better approach is to have those webapps living under the same
context. Turbine's system isn't quite there yet, but it is very close. We
will have full transparent support for this in the near future.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


Mime
View raw message