It should be enough to put the init code in a block that is synchronized on
the class, e.g.

class Foo {

   static boolean isInitialized = false;

   public Foo(...) {
     synchronized (Foo.class) {
       if (!Foo.isInitialized) {
         .. do init stuff as below ..
       }
     }
     ....
   }

}

- Rob


-----Original Message-----
From: Marco Spinetti [mailto:[EMAIL PROTECTED]
Sent: Monday, September 01, 2003 7:52 PM
To: [EMAIL PROTECTED]
Subject: Re: Init Parameter


I'm missing something......

In a multi-thread environment, you need a kind of critical region
mechanism.

If two clients call, in the same instant, your web service (two
instances of your object ----> 2 constructor, your code is executed
twice because the statement (in this example "Foo.isInitialized") is
true.

The target of static block is to execute some code once.

But it seems that in axis enviroment, initializing star-up parameters is
not obvious.

Can someone give me some hints?


--Marco



Il lun, 2003-09-01 alle 12:59, Tom Oinn ha scritto:
> class Foo {
>
>    static boolean isInitialized = false;
>
>    public Foo(...) {
>      if (Foo.isInitialized) {
>        .. do init stuff as below ..
>      }
>      ....
>    }
>
> }
>
> ...or am I missing something?
>
> Tom
>
> Marco Spinetti wrote:
> > Hi I need to read some configuration parameter, so reading some mails in
> > mail list I have written:
> >
> > MessageContext msgContext = MessageContext.getContext();
> >     SOAPService    service    = msgContext.getService();
> >     paramValue         = service.getOption("paramName");
> >
> > and I have inserted <parameter ..../> to my service.
> >
> > I have discovered that you can't insert this code in a static block,
(http://marc.theaimsgroup.com/?t=104765761500001&r=1&w=2)
> >
> > so I try to insert it in the constructor of my class with my SOAP
method.
> >
> > But I see that the constructor is called every invocation of my web
service, so could
> > someone explain me how to initialize a variable one time and only one
time?
> >
> > Cheers
> >
> > --Marco
> >
> >
> >
> >
> >
>
>



Reply via email to