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