You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Dave Cowing <dc...@enpresence.com> on 2006/07/22 21:04:20 UTC

[Axis2] How to perform startup initialization?

I'm getting started with Axis 2 and am looking to perform some
initialization when axis2 starts up.  Specifically, I'm looking to configure
a database pool and a couple of other resource pools that will be shared by
web services.
 
In a servlet, I do this by creating a servlet listener, configuring the pool
objects and dropping them into the servlet context.
 
I assume that I should be looking at the Service Group or Configuration
Context to store the pools.  I also tried creating an AxisObserver, but I
don't seem to be able to access the contexts.
 
How can I create a method that's called when axis2 starts up and has access
to these contexts?
 
Thanks,
Dave

RE: [Axis2] How to perform startup initialization?

Posted by Dave Cowing <dc...@enpresence.com>.
Martin,
 
what'd I'd like to do is set up a pool of database connections, that I can
access within each call to my service.  This way I avoid the latency of
creating new db connections for each call to my service, plus limit the
number of connections to the db.  I can certainly use a more restricted
scope, but the key is that the pool needs to be setup when axis is started
and last across calls to services.
 
thanks,
Dave

  _____  

From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Saturday, July 22, 2006 4:46 PM
To: axis-user@ws.apache.org
Subject: Re: [Axis2] How to perform startup initialization?


Resources identified within that service are known only to that service
As with Any servlet you can extends AxisServlet and possibly read in
customised parameters (such as DB connect strings) in the init() but I guess
I dont understand why you would want access the resource for all services
inside AxisServlet..

Perhaps to understand your intended outcome could you explain 
why you need to identify your resources at the ServletContext (instead of
the considerably more restricted scope of your deployed service)???

Martin --
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.
 

 

----- Original Message ----- 
From: Dave  <ma...@enpresence.com> Cowing 
To: axis-user@ws.apache.org 
Sent: Saturday, July 22, 2006 3:04 PM
Subject: [Axis2] How to perform startup initialization?

I'm getting started with Axis 2 and am looking to perform some
initialization when axis2 starts up.  Specifically, I'm looking to configure
a database pool and a couple of other resource pools that will be shared by
web services.
 
In a servlet, I do this by creating a servlet listener, configuring the pool
objects and dropping them into the servlet context.
 
I assume that I should be looking at the Service Group or Configuration
Context to store the pools.  I also tried creating an AxisObserver, but I
don't seem to be able to access the contexts.
 
How can I create a method that's called when axis2 starts up and has access
to these contexts?
 
Thanks,
Dave


Re: [Axis2] How to perform startup initialization?

Posted by Martin Gainty <mg...@hotmail.com>.
Resources identified within that service are known only to that service
As with Any servlet you can extends AxisServlet and possibly read in customised parameters (such as DB connect strings) in the init() but I guess I dont understand why you would want access the resource for all services inside AxisServlet..

Perhaps to understand your intended outcome could you explain 
why you need to identify your resources at the ServletContext (instead of the considerably more restricted scope of your deployed service)???

Martin --
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



  ----- Original Message ----- 
  From: Dave Cowing 
  To: axis-user@ws.apache.org 
  Sent: Saturday, July 22, 2006 3:04 PM
  Subject: [Axis2] How to perform startup initialization?


  I'm getting started with Axis 2 and am looking to perform some initialization when axis2 starts up.  Specifically, I'm looking to configure a database pool and a couple of other resource pools that will be shared by web services.

  In a servlet, I do this by creating a servlet listener, configuring the pool objects and dropping them into the servlet context.

  I assume that I should be looking at the Service Group or Configuration Context to store the pools.  I also tried creating an AxisObserver, but I don't seem to be able to access the contexts.

  How can I create a method that's called when axis2 starts up and has access to these contexts?

  Thanks,
  Dave

RE: [Axis2] How to perform startup initialization?

Posted by Dave Cowing <dc...@enpresence.com>.
Sanjiva/Tony,
Thanks for the suggestions,
Dave

-----Original Message-----
From: Sanjiva Weerawarana [mailto:sanjiva@opensource.lk] 
Sent: Sunday, July 23, 2006 7:41 AM
To: axis-user@ws.apache.org
Subject: Re: [Axis2] How to perform startup initialization?

On Sat, 2006-07-22 at 15:04 -0400, Dave Cowing wrote:
> I'm getting started with Axis 2 and am looking to perform some 
> initialization when axis2 starts up.  Specifically, I'm looking to 
> configure a database pool and a couple of other resource pools that 
> will be shared by web services.
>  
> In a servlet, I do this by creating a servlet listener, configuring 
> the pool objects and dropping them into the servlet context.
>  
> I assume that I should be looking at the Service Group or 
> Configuration Context to store the pools.  I also tried creating an 
> AxisObserver, but I don't seem to be able to access the contexts.
>  
> How can I create a method that's called when axis2 starts up and has 
> access to these contexts?

The contexts are available only at runtime. I don't think we currently have
a defined programming model for system init time, system-wide user code
execution. 

[You're not really a "user" though as you want to do this for a group of
unconnected services. (If that were not the case you could use the service
lifecycle stuff in a service group.) This is really a system extension
point.]

There are several work arounds but none are very elegant:
- do what Tony suggested: use the services' init() method to create the
stuff and push the data into the ConfigurationContext so its visible to all
services. You'll need to have the same code in all the services as you
(presumably) don't know which one will be used first.
- write a module and deploy it globally- this module will then get called
and you can do the same as the above but at least you don't have to tell
service authors to do any work (except go look up the db pool).

If you want a proper first class solution please post a note on the axis-dev
list (with [axis2] prefix) and also open a JIRA. Its a useful feature but
must be done carefully to avoid risking the system to a malicious or
careless service author doing this.

Thanks,

Sanjiva.



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [Axis2] How to perform startup initialization?

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Sat, 2006-07-22 at 15:04 -0400, Dave Cowing wrote:
> I'm getting started with Axis 2 and am looking to perform some
> initialization when axis2 starts up.  Specifically, I'm looking to
> configure a database pool and a couple of other resource pools that
> will be shared by web services.
>  
> In a servlet, I do this by creating a servlet listener, configuring
> the pool objects and dropping them into the servlet context.
>  
> I assume that I should be looking at the Service Group or
> Configuration Context to store the pools.  I also tried creating an
> AxisObserver, but I don't seem to be able to access the contexts.
>  
> How can I create a method that's called when axis2 starts up and has
> access to these contexts?

The contexts are available only at runtime. I don't think we currently
have a defined programming model for system init time, system-wide user
code execution. 

[You're not really a "user" though as you want to do this for a group of
unconnected services. (If that were not the case you could use the
service lifecycle stuff in a service group.) This is really a system
extension point.]

There are several work arounds but none are very elegant:
- do what Tony suggested: use the services' init() method to create the
stuff and push the data into the ConfigurationContext so its visible to
all services. You'll need to have the same code in all the services as
you (presumably) don't know which one will be used first.
- write a module and deploy it globally- this module will then get
called and you can do the same as the above but at least you don't have
to tell service authors to do any work (except go look up the db pool).

If you want a proper first class solution please post a note on the
axis-dev list (with [axis2] prefix) and also open a JIRA. Its a useful
feature but must be done carefully to avoid risking the system to a
malicious or careless service author doing this.

Thanks,

Sanjiva.



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org