You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Williamson <ch...@wolfram.com> on 2001/12/07 23:19:02 UTC

Resources

Is there a way to load an object into Tomcat, have it initialize
automatically, then sit back and process requests.

For example you could do this using an MBean in JBoss.  I am looking for a
similar solution using Tomcat.

I can load a resource but it creates a new object everytime I try to look up
the object in JNDI.  I would rather it just reference an object that is
initialized when the system starts.

Anyway to do this?

Thanks for any help,

Chris


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


RE: Resources

Posted by Chris Williamson <ch...@wolfram.com>.
Thanks a lot!  This was very helpful.  Especially the 4.0.2 info.

Chris

> -----Original Message-----
> From: craigmcc@wolfram.com [mailto:craigmcc@wolfram.com]On Behalf Of
> Craig R. McClanahan
> Sent: Friday, December 07, 2001 5:12 PM
> To: Tomcat Users List
> Subject: Re: Resources
>
>
> On Fri, 7 Dec 2001, Chris Williamson wrote:
>
> > Date: Fri, 7 Dec 2001 16:19:02 -0600
> > From: Chris Williamson <ch...@wolfram.com>
> > Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> > To: Tomcat Users Group <to...@jakarta.apache.org>
> > Subject: Resources
> >
> > Is there a way to load an object into Tomcat, have it initialize
> > automatically, then sit back and process requests.
> >
> > For example you could do this using an MBean in JBoss.  I am
> looking for a
> > similar solution using Tomcat.
> >
> > I can load a resource but it creates a new object everytime I
> try to look up
> > the object in JNDI.  I would rather it just reference an object that is
> > initialized when the system starts.
> >
> > Anyway to do this?
> >
> > Thanks for any help,
> >
> > Chris
> >
>
> In a Servlet 2.3 environment (like Tomcat 4), one approach to this would
> be the new application event listeners functionality.  You can register a
> listener (implements ServletContextListener) that is notified when the web
> application is started up and shut down.  At startup time, simply create
> the resource you want, and stick it in the servlet context attributes.
>
> For Tomcat 4 specifically, you can also create your own object factory for
> JNDI-accessed resources.  The implementation of this factory is totally up
> to you, so you could have it create an object once and return it every
> time.  (Also, in an update that will show up in 4.0.2 soon, the standard
> object factories only create an object once.)
>
> Craig
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Resources

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Fri, 7 Dec 2001, Chris Williamson wrote:

> Date: Fri, 7 Dec 2001 16:19:02 -0600
> From: Chris Williamson <ch...@wolfram.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users Group <to...@jakarta.apache.org>
> Subject: Resources
>
> Is there a way to load an object into Tomcat, have it initialize
> automatically, then sit back and process requests.
>
> For example you could do this using an MBean in JBoss.  I am looking for a
> similar solution using Tomcat.
>
> I can load a resource but it creates a new object everytime I try to look up
> the object in JNDI.  I would rather it just reference an object that is
> initialized when the system starts.
>
> Anyway to do this?
>
> Thanks for any help,
>
> Chris
>

In a Servlet 2.3 environment (like Tomcat 4), one approach to this would
be the new application event listeners functionality.  You can register a
listener (implements ServletContextListener) that is notified when the web
application is started up and shut down.  At startup time, simply create
the resource you want, and stick it in the servlet context attributes.

For Tomcat 4 specifically, you can also create your own object factory for
JNDI-accessed resources.  The implementation of this factory is totally up
to you, so you could have it create an object once and return it every
time.  (Also, in an update that will show up in 4.0.2 soon, the standard
object factories only create an object once.)

Craig


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>