This is interesting.  I can't speak to the Axis internals.  But what this shows
me is that Axis is creating more than one service implementation class.  Thus
there is more than one instance of your Test class instanciated even though
they will live to service many requests.  This is what I would expect for Axis
to support multiple user-request-threads coming in from the Servlet container.

If you move the 'temp=""' line out of the constructor and into a static
initializer (static String  temp="";) you will get the effect you are looking
for.  But to scale the example, you might want to implement a class following
the Singleton pattern to maintain the application state.

hope it helps,
james

Quoting "J.W.F. Thirion" <[EMAIL PROTECTED]>:

> Hi everyone,
>
> I appologise if this has been asked already, but I would like to know the
> following: Is it possible to have a Java class, e.g. Test in my Test.java,
> to keep the value of its static variables between calls to the service. E.g.
> I have a static variable temp, to which I just add string data and on each
> call to getValue the value returned should be the value I passed to the
> function concatenated to previous String values. So on the first call, if I
> pass "Hello", I would get back "Initial, Hello" and on the second call, if I
> pass "there", I would get back "Initial, Hello there", and so on. The object
> must thus never go out of scope. I assumed that I needed to set the scope to
> application, but that didn't work (I just got back the string "Initial, XXX"
> where XXX is what I passed to getValue - thus the constructor was called on
> each call). Here is my deploy.wsdd file:
>
> <deployment xmlns="http://xml.apache.org/axis/wsdd/";
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
>     <service name="Test" provider="java:RPC">
>         <parameter name="scope"          value="application" />
>         <parameter name="className"      value="Test" />
>         <parameter name="allowedMethods" value="*" />
>     </service>
> </deployment>
>
> and here is my class:
>
> public class Test {
>     static boolean bInitialised;
>     static String  temp;
>
>     public Test() {
>       bInitialised = false;
>       temp = "";
>     }
>
>     public static synchronized boolean isInitialised() {
>         return bInitialised;
>     }
>
>     public static synchronized void initialise() {
>               temp = "Initial, ";
>               bInitialised = true;
>     }
>
>     public String getValue(String input) {
>         if (!Test.isInitialised()) {
>               Test.initialise();
>         }
>
>         temp = temp + input;
>         return temp;
>     }
> }
>
> and I have deployed the service with the following:
>
> java org.apache.axis.client.AdminClient deploy.wsdd
>
> Any help would be greatly appreciated.
>
> Kind regards,
> J.W.F. Thirion (Dérik)
> E-mail: [EMAIL PROTECTED]
>
>
>

Reply via email to