AXIS uses a handler-based infrastructure. Each time a request is
submitted, the request travels through a series of handlers (defined in
your WSDD) before it actually reaches your service. The response goes
through a similiar set of handlers before it is sent out over the wire to
the client. There are a number of pre-defined handlers, such as the AXIS
engine, the transport, the provider and global handlers, such as
JWSHandler. You can also define your own handlers within the <service>
element of your web service. Any defined handlers are initialized when the
AXIS engine starts up.
I don't know what the "best practice" is for this sort of situation, but
what *I* would do is define a simple handler that performs the necessary
initialization in its init() method and add it to your <requestFlow> for
the offending <service> element. Keep in mind that if any of the handlers'
init() methods throws an exception it will trigger a
ConfigurationException, preventing any of the services from starting.
HTH,
Ian
"Tolsch, Ed"
<Edward.Tolsch To: [EMAIL PROTECTED]
@fmr.Com> cc: "Scott, David G." <[EMAIL
PROTECTED]>, "Tolsch, Ed"
<[EMAIL PROTECTED]>
01/27/2004 Subject: question on 'best' practice for
initialization?
09:29 PM
Please respond
to axis-user
HI,
Sorry for this long winded question. I have a doc/literal web
service with a default scope of 'Request' so that the implementation class
is created with each service request. I want to perform initialization
ideally when the service is deployed, before it is ever hit( meaning before
I ever see the 'open for e-business' message in the standard out file ) ,
but for now have settled on the first time the service is hit. I'm using
the
ServiceLifeCycle class for initialization.
So my implementation class looks like this.
public class SomeImplClass extends WSAxisBase implements myPortType
{
...
}
//
// My base class looks like this.
//
public abstract class WSAxisBase implements ServiceLifecycle
{
static String sMode = null;
public void init(java.lang.Object context )
{
if (sMode == null)
{
// do logic to get sMode value from web.xml and set sMode
// i.e , one time initialization here, like JNDI lookup of
datasources.
}
}
}
This seems to work fine but is far from an elegant solution as the init()
method in the ServiceLifeCycle interface gets called each time the service
is invoked and I'm just controlling the one time initialization through a
static variable.
Since I'm fairly new to AXIS, what would be the preferred way to perform a
one-time intialization in a more correct manner, as I'm incurring the call
to the init() method each time, which is not an ideal solution?
In the SOAP 2.2 world, I actually had control over the init() method in the
servlet itself, but seems like I don't really have a hook into the
AxisServlet class(org.apache.axis.transport.http.AxisServlet) ?
Any thoughts/education would be greatly appreciated.
Thanks.
Ed Tolsch
Fidelity Investments
[EMAIL PROTECTED]
This transmission may contain information that is privileged, confidential and/or
exempt from disclosure under applicable law. If you are not the intended recipient,
you are hereby notified that any disclosure, copying, distribution, or use of the
information contained herein (including any reliance thereon) is STRICTLY PROHIBITED.
If you received this transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard copy format. Thank
you.