We use scope="soapsession" to get one instance per user-session-thread; that 
allows for long-lasting.-user-sessions and/or state-full service objects. We 
use it since years, and we use it with axis2-1.2; we did not test it with 
axis2-1.5.1; doing so, beware to adjust in /.conf/axis2.xml 
ConfigContextTimeoutInterval from 30000 ms (default) to what you think is an 
appropriate timeout. Because if the timeout triggers, destroy() is called on 
your service object. 

    <!--This will give out the timeout of the configuration contexts, in 
milliseconds-->
    <parameter name="ConfigContextTimeoutInterval">28800000</parameter>

We use it as shown above because we start sometimes user sessions which are not 
terminating within hours due to heavy calculations. Also you need to add 2 
methods of 3 to your service class; init() and destroy(), as shown in relevant 
documentation.

Josef


-----Ursprüngliche Nachricht-----
Von: Meeusen, Christopher W. [mailto:[email protected]] 
Gesendet: Freitag, 20. August 2010 18:21
An: [email protected]; [email protected]
Cc: [email protected]
Betreff: RE: Field level variables

I think I found the answer to my question.  Thank you for pointing me in the 
correct direction.  According to the article here: 
http://wso2.org/library/articles/axis2-session-management-part-2, if no scope 
is explicitly declared for a service then, it defaults to session scope, which 
means that an instance of the service implementation will be instantiated for 
each request.  10 requests to MyService.class means 10 instances of 
MyService.class.

Thanks!
Chris



-----Original Message-----
From: java-user-return-83370-meeusen.christopher=mayo....@axis.apache.org 
[mailto:java-user-return-83370-meeusen.christopher=mayo....@axis.apache.org] On 
Behalf Of Meeusen, Christopher W.
Sent: Friday, August 20, 2010 11:06 AM
To: [email protected]
Cc: [email protected]; [email protected]
Subject: RE: Field level variables

Thank you for the response!  I just want to make sure I understand.  You're 
saying this is configurable in the services.xml file?  If this is so what is 
the default scope if nothing is specified?

Thanks,
Chris

-----Original Message-----
From: Jeff Greif [mailto:[email protected]]
Sent: Friday, August 20, 2010 11:03 AM
To: Meeusen, Christopher W.
Cc: [email protected]; [email protected]
Subject: Re: Field level variables

This is configurable in the deployment descriptor.  The <service> element has 
an attribute "scope".  One allowed value of this attribute creates an instance 
of the implementing class for each invocation.

Jeff

On 8/20/2010 7:18 AM, Meeusen, Christopher W. wrote:
> Let me try to ask this another way.  Say I have a class MyService.java and 
> this class has a web service method in it.  What does the lifecycle of this 
> class look like?  Is there a new instance of MyService instantiated for each 
> request to one of the methods within it, or is one instance of this class 
> instantiated and multiple threads use the same instance of the class?
> 
> -----Original Message-----
> From: Meeusen, Christopher W. 
> Sent: Wednesday, August 18, 2010 5:45 PM
> To: [email protected]
> Cc: [email protected]
> Subject: Re: Field level variables
> 
> My main concern is if this is thread safe.  Are pojos re entrant in axis2-1.3?
> 
> On Aug 18, 2010, at 17:21, "Meeusen, Christopher W." 
> <[email protected]  > wrote:
> 
>> I’m looking through some of my colleagues code and I’m noticing some 
>> field level variables declared inside one of our pojos.  Someth ing 
>> similar to this:
>>
>>
>>
>> Public class classA
>>
>> {
>>
>>                 private classB aClassb;
>>
>>
>>
>>                 Public classC[] aMethod()
>>
>> {
>>
>>                                 aClassb= new classB();
>>
>> }
>>
>> }
>>
>>
>>
>> aMethod() is exposed as a web service and is called several thousand 
>> times per minute.  Is this thread safe?  I know it is bad to have 
>> field level variables unless they are really needed but I don’t know 
>> if this behavior is ok inside of the axis2 environment.
>>
>>
>>
>> Thanks,
>>
>> Chris

Reply via email to