Thanks, Glen,

I hunted for something like that at the time, in docs and in the source code. I obviously didn't hunt hard enough, though.

ADK

Glen Daniels wrote:

Hi Aaron, Niket:

We did think of this too. :) Allow me to refer you to:

http://ws.apache.org/axis/faq.html#faq8

If you simply set scope="application" on your service, Axis will only create a single instance of the service class.

--Glen



-----Original Message-----
From: Aaron Knauf [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 27, 2003 12:36 AM
To: [EMAIL PROTECTED]
Subject: Re: Service Class as Singleton Class


The problem is that Axis instantiates and new service class instance each time the service is invoked, using reflection to find the public constructor. It would be difficult to get Axis to cater for singletons, as the getInstance method could be called anything.


I found the instantiation of a new service class for each invocation to be a problem, so I worked around it by implementing my service class as a proxy to a singleton implementation class. The wrapper gets instantiated every time, but the class that implements all the logic is only instantiated once. This was to avoid expensive initialization code (such as starting up a pool of connections to a CORBA server) from being executed repeatedly, but it had the handy side effect of allowing me to read in my config from the WSDD file in this wrapper, too, therby hiding the fact that the thing was running as a web service from the impl class.

Hope this helps.

Cheers

ADK

Niket Anand wrote:






Hello All,
I am newbie to Axis. I am facing problem as
java.lang.InstantiationException


<file:///C:/jdk1.3.1/docs/api/java/lang/InstantiationException.html>


exception when my service class is Singleton class and having
private constructor and getInstance() to get instance of this
class. When axis client ask for a method from the service class
then it throw this exception. If I remove the Singleton ability
and provide public constructor then it works fine. But I want it
to be remain Singleton . Please help me How to work with Service
class as Singleton and what modification needs to be


done in wsdd.


waiting for reply...
thanks,
Niket













Reply via email to