You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Johannes Fiala <so...@fwd.at> on 2003/01/06 18:13:55 UTC

Caching database connections across requests

Hi there!

Does anybody know how I can easily intercept the servlet initialization 
routine of the servlet rpcrouter?
I'd like to extend it that way, that if the servlet is loaded, 10 database 
connections will be opened, available for subsequent requests. 

So I'd need to include a kind of entry point class easily in the 
rpcrouter's initialization routine. Does anybody know how I can achieve 
this without having to fumble in the soap.war - Sourcefiles?

Wouldn't it be a good idea to have such entrypoints at least in the 
rpcrouter serlvet's initializiation routine?

thx alot
Johannes

Re: Caching database connections across requests

Posted by Scott Nichol <sn...@scottnichol.com>.
I like the ServletContextListener because it is so unintrusive.  I wish
I'd thought of it.

Scott Nichol

----- Original Message -----
From: "Johannes Fiala" <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Monday, January 06, 2003 1:27 PM
Subject: Re: Caching database connections across requests


> Hi Scott,
>
> Thx for your input!
> Do you think it is better to use Robert's idea with a
> ServletContextListener or subclassing rpcrouter?
> Basically all I do is adding some code to extend the init() method of
> rpcrouter, which inits my DbConnectionBroker for reuse in subsequent
> SOAP-calls using servletContext.setAttribute/getAttribute.
>
> Johannes
>
>
>
>
> Scott Nichol <sn...@scottnichol.com>
> 06.01.2003 19:13
> Please respond to
> soap-user@xml.apache.org
>
>
> To
> soap-user@xml.apache.org
> cc
>
> Subject
> Re: Caching database connections across requests
>
>
>
>
>
>
> There is no built in hook.  My recommendation is to write your own
class
> that subclasses RPCRouterServlet.  The init() should call
super.init(),
> then do your custom initialization.  That way, you don't have to poke
> around the source, although you will want to change web.xml to either
> add your new servlet or change the rpcrouter mapping to point to your
> servlet.
>
> Scott Nichol
>
> ----- Original Message -----
> From: "Johannes Fiala" <so...@fwd.at>
> To: <so...@xml.apache.org>
> Sent: Monday, January 06, 2003 12:13 PM
> Subject: Caching database connections across requests
>
>
> > Hi there!
> >
> > Does anybody know how I can easily intercept the servlet
> initialization
> > routine of the servlet rpcrouter?
> > I'd like to extend it that way, that if the servlet is loaded, 10
> database
> > connections will be opened, available for subsequent requests.
> >
> > So I'd need to include a kind of entry point class easily in the
> > rpcrouter's initialization routine. Does anybody know how I can
> achieve
> > this without having to fumble in the soap.war - Sourcefiles?
> >
> > Wouldn't it be a good idea to have such entrypoints at least in the
> > rpcrouter serlvet's initializiation routine?
> >
> > thx alot
> > Johannes
>
>
> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>
>
>
>
>


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>


Re: Caching database connections across requests

Posted by Scott Nichol <sn...@scottnichol.com>.
I like the ServletContextListener because it is so unintrusive.  I wish
I'd thought of it.

Scott Nichol

----- Original Message -----
From: "Johannes Fiala" <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Monday, January 06, 2003 1:27 PM
Subject: Re: Caching database connections across requests


> Hi Scott,
>
> Thx for your input!
> Do you think it is better to use Robert's idea with a
> ServletContextListener or subclassing rpcrouter?
> Basically all I do is adding some code to extend the init() method of
> rpcrouter, which inits my DbConnectionBroker for reuse in subsequent
> SOAP-calls using servletContext.setAttribute/getAttribute.
>
> Johannes
>
>
>
>
> Scott Nichol <sn...@scottnichol.com>
> 06.01.2003 19:13
> Please respond to
> soap-user@xml.apache.org
>
>
> To
> soap-user@xml.apache.org
> cc
>
> Subject
> Re: Caching database connections across requests
>
>
>
>
>
>
> There is no built in hook.  My recommendation is to write your own
class
> that subclasses RPCRouterServlet.  The init() should call
super.init(),
> then do your custom initialization.  That way, you don't have to poke
> around the source, although you will want to change web.xml to either
> add your new servlet or change the rpcrouter mapping to point to your
> servlet.
>
> Scott Nichol
>
> ----- Original Message -----
> From: "Johannes Fiala" <so...@fwd.at>
> To: <so...@xml.apache.org>
> Sent: Monday, January 06, 2003 12:13 PM
> Subject: Caching database connections across requests
>
>
> > Hi there!
> >
> > Does anybody know how I can easily intercept the servlet
> initialization
> > routine of the servlet rpcrouter?
> > I'd like to extend it that way, that if the servlet is loaded, 10
> database
> > connections will be opened, available for subsequent requests.
> >
> > So I'd need to include a kind of entry point class easily in the
> > rpcrouter's initialization routine. Does anybody know how I can
> achieve
> > this without having to fumble in the soap.war - Sourcefiles?
> >
> > Wouldn't it be a good idea to have such entrypoints at least in the
> > rpcrouter serlvet's initializiation routine?
> >
> > thx alot
> > Johannes
>
>
> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>
>
>
>
>


Re: Caching database connections across requests

Posted by Johannes Fiala <so...@fwd.at>.
Hi Scott, 

Thx for your input! 
Do you think it is better to use Robert's idea with a 
ServletContextListener or subclassing rpcrouter?
Basically all I do is adding some code to extend the init() method of 
rpcrouter, which inits my DbConnectionBroker for reuse in subsequent 
SOAP-calls using servletContext.setAttribute/getAttribute.

Johannes




Scott Nichol <sn...@scottnichol.com> 
06.01.2003 19:13
Please respond to
soap-user@xml.apache.org


To
soap-user@xml.apache.org
cc

Subject
Re: Caching database connections across requests






There is no built in hook.  My recommendation is to write your own class
that subclasses RPCRouterServlet.  The init() should call super.init(),
then do your custom initialization.  That way, you don't have to poke
around the source, although you will want to change web.xml to either
add your new servlet or change the rpcrouter mapping to point to your
servlet.

Scott Nichol

----- Original Message -----
From: "Johannes Fiala" <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Monday, January 06, 2003 12:13 PM
Subject: Caching database connections across requests


> Hi there!
>
> Does anybody know how I can easily intercept the servlet
initialization
> routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10
database
> connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the
> rpcrouter's initialization routine. Does anybody know how I can
achieve
> this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>




Re: Caching database connections across requests

Posted by Johannes Fiala <so...@fwd.at>.
Hi Scott, 

Thx for your input! 
Do you think it is better to use Robert's idea with a 
ServletContextListener or subclassing rpcrouter?
Basically all I do is adding some code to extend the init() method of 
rpcrouter, which inits my DbConnectionBroker for reuse in subsequent 
SOAP-calls using servletContext.setAttribute/getAttribute.

Johannes




Scott Nichol <sn...@scottnichol.com> 
06.01.2003 19:13
Please respond to
soap-user@xml.apache.org


To
soap-user@xml.apache.org
cc

Subject
Re: Caching database connections across requests






There is no built in hook.  My recommendation is to write your own class
that subclasses RPCRouterServlet.  The init() should call super.init(),
then do your custom initialization.  That way, you don't have to poke
around the source, although you will want to change web.xml to either
add your new servlet or change the rpcrouter mapping to point to your
servlet.

Scott Nichol

----- Original Message -----
From: "Johannes Fiala" <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Monday, January 06, 2003 12:13 PM
Subject: Caching database connections across requests


> Hi there!
>
> Does anybody know how I can easily intercept the servlet
initialization
> routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10
database
> connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the
> rpcrouter's initialization routine. Does anybody know how I can
achieve
> this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>




Re: Caching database connections across requests

Posted by Scott Nichol <sn...@scottnichol.com>.
There is no built in hook.  My recommendation is to write your own class
that subclasses RPCRouterServlet.  The init() should call super.init(),
then do your custom initialization.  That way, you don't have to poke
around the source, although you will want to change web.xml to either
add your new servlet or change the rpcrouter mapping to point to your
servlet.

Scott Nichol

----- Original Message -----
From: "Johannes Fiala" <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Monday, January 06, 2003 12:13 PM
Subject: Caching database connections across requests


> Hi there!
>
> Does anybody know how I can easily intercept the servlet
initialization
> routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10
database
> connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the
> rpcrouter's initialization routine. Does anybody know how I can
achieve
> this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>


Re: Caching database connections across requests

Posted by Johannes Fiala <so...@fwd.at>.
Hi Robert,

I did it first using setAttribute in the rpcrouter Servlet's init-routine, 
however this approach seems to be quite dirty to me.
Thx for the idea of using a ServletContextListener instead, it should be 
much more cleaner.

thx
Johannes




Robert Dietrick <rd...@sega.com> 
06.01.2003 18:50
Please respond to
soap-user@xml.apache.org


To
soap-user@xml.apache.org
cc

Subject
Re: Caching database connections across requests






I'm not sure about accessing the init mehtod of rpcrouter, but there 
alternative methods of initializing resources at startup.  One way is to 
write a ServletContextListener which initializes the resources and makes 
them available to the rest of the application.

Basically, you would write a subclass of 
javax.servlet.ServletContextListener, and initializes the DB connections 
in the contextInitialized() method.  You could make them available to 
the rest of the servlets in your web app by assigning them to some 
attribute of the ServletContext.

-rob

Johannes Fiala wrote:

>
> Hi there!
>
> Does anybody know how I can easily intercept the servlet 
> initialization routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10 
> database connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the 
> rpcrouter's initialization routine. Does anybody know how I can 
> achieve this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the 
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes 




--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>




Re: Caching database connections across requests

Posted by Johannes Fiala <so...@fwd.at>.
Hi Robert,

I did it first using setAttribute in the rpcrouter Servlet's init-routine, 
however this approach seems to be quite dirty to me.
Thx for the idea of using a ServletContextListener instead, it should be 
much more cleaner.

thx
Johannes




Robert Dietrick <rd...@sega.com> 
06.01.2003 18:50
Please respond to
soap-user@xml.apache.org


To
soap-user@xml.apache.org
cc

Subject
Re: Caching database connections across requests






I'm not sure about accessing the init mehtod of rpcrouter, but there 
alternative methods of initializing resources at startup.  One way is to 
write a ServletContextListener which initializes the resources and makes 
them available to the rest of the application.

Basically, you would write a subclass of 
javax.servlet.ServletContextListener, and initializes the DB connections 
in the contextInitialized() method.  You could make them available to 
the rest of the servlets in your web app by assigning them to some 
attribute of the ServletContext.

-rob

Johannes Fiala wrote:

>
> Hi there!
>
> Does anybody know how I can easily intercept the servlet 
> initialization routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10 
> database connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the 
> rpcrouter's initialization routine. Does anybody know how I can 
> achieve this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the 
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes 




--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>




Re: Caching database connections across requests

Posted by Robert Dietrick <rd...@sega.com>.
I'm not sure about accessing the init mehtod of rpcrouter, but there 
alternative methods of initializing resources at startup.  One way is to 
write a ServletContextListener which initializes the resources and makes 
them available to the rest of the application.

Basically, you would write a subclass of 
javax.servlet.ServletContextListener, and initializes the DB connections 
in the contextInitialized() method.  You could make them available to 
the rest of the servlets in your web app by assigning them to some 
attribute of the ServletContext.

-rob

Johannes Fiala wrote:

>
> Hi there!
>
> Does anybody know how I can easily intercept the servlet 
> initialization routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10 
> database connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the 
> rpcrouter's initialization routine. Does anybody know how I can 
> achieve this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the 
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes 




--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>


Re: Caching database connections across requests

Posted by Robert Dietrick <rd...@sega.com>.
I'm not sure about accessing the init mehtod of rpcrouter, but there 
alternative methods of initializing resources at startup.  One way is to 
write a ServletContextListener which initializes the resources and makes 
them available to the rest of the application.

Basically, you would write a subclass of 
javax.servlet.ServletContextListener, and initializes the DB connections 
in the contextInitialized() method.  You could make them available to 
the rest of the servlets in your web app by assigning them to some 
attribute of the ServletContext.

-rob

Johannes Fiala wrote:

>
> Hi there!
>
> Does anybody know how I can easily intercept the servlet 
> initialization routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10 
> database connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the 
> rpcrouter's initialization routine. Does anybody know how I can 
> achieve this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the 
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes 




Re: Caching database connections across requests

Posted by Scott Nichol <sn...@scottnichol.com>.
There is no built in hook.  My recommendation is to write your own class
that subclasses RPCRouterServlet.  The init() should call super.init(),
then do your custom initialization.  That way, you don't have to poke
around the source, although you will want to change web.xml to either
add your new servlet or change the rpcrouter mapping to point to your
servlet.

Scott Nichol

----- Original Message -----
From: "Johannes Fiala" <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Monday, January 06, 2003 12:13 PM
Subject: Caching database connections across requests


> Hi there!
>
> Does anybody know how I can easily intercept the servlet
initialization
> routine of the servlet rpcrouter?
> I'd like to extend it that way, that if the servlet is loaded, 10
database
> connections will be opened, available for subsequent requests.
>
> So I'd need to include a kind of entry point class easily in the
> rpcrouter's initialization routine. Does anybody know how I can
achieve
> this without having to fumble in the soap.war - Sourcefiles?
>
> Wouldn't it be a good idea to have such entrypoints at least in the
> rpcrouter serlvet's initializiation routine?
>
> thx alot
> Johannes