You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Dies Koper <di...@jp.fujitsu.com> on 2006/07/04 08:15:23 UTC

Re: AW: ServiceLifecycle

Hello Ralph,

Sorry for the very very late reply. I suppose you have solved your 
problem already, but if you haven't:

ebaykunde@arcor.de wrote:
>> Follow the example in the URL:
>> 1. your impl class implements javax.xml.rpc.server.ServiceLifecycle
>> 2. implement init(Object ctx) and destroy()
> My problem is hat the init and destroy method is only called, if I implement
> the ServiceLifecycle interface in the Skeleton class. But this is not what I
> want to do, because this class is not very nice and would be overwritten if
> I do another Java2WSDL task.

I tried rebuilding your service with the skeletonDeploy option to false 
(no skeletons). The init method in the impl class was called correctly.
I never used skeletons, so I am not sure what to expect if you do 
generate them.

> I am a little bit confused about the ServiceLifecycle. The ServiceLifecycle
> seems to be called every time if I call
> http://localhost:7070/myapp/services/SyncService?method=getPerson
> in the browser etc.. That's OK and what I want to have. But in some
> documentations and also in books they write the init method of a service
> will be called only ONCE before he can accept requests. I think that's not
> correct?!?

It depends on what you specify for the deployScope option. If you choose 
"application", the init method will be called only once.

> PS:
> Another ugly thing why overwrites Axis with every java2wsdl task the
> ServiceImpl class?

I think you mean the wsdl2java task.
The ant task designer must have thought that the reason you are 
rerunning the wsdl2java task is to update your Java classes after you 
changed the interface. If the interface is changed, the old impl class 
would not work anymore anyway. Why don't you keep the generated source 
and your own implementation class separate (with the 'output' attribute) 
and update your impl by hand if necessary.

Regards,
Dies


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AW: ServiceLifecycle

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Dr Janusz Martyniak wrote:

> Deepal Jayasinghe wrote:
>
>> Hi  Janusz;
>>
>>>  but,
>>>
>>> The init() is called every time I invoke the method. 
>>
>>
>> That will only happen if you deploy your service in request scope , if
>> you deploy your service in application scope then that will never
>> happen.
>>
>
>  Well, if I deploy my service as an application then init() is called
> once and all the clients will share the implementation instance and
> the latter is not what I want.
>
> What I'm trying to achieve is to keep the request mode, so every
> client gets his own instance of a service, but have a possibility to
> initialise the service once, possibly at servlet loading time, or at a
> very first call. The init() method does not deliver this.

Well , then you need to have a look at ServiceLifeCycle interface. I
hope using that you will be able to achieve what you want.

Thanks
Deepal


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: AW: ServiceLifecycle

Posted by Tony Dean <To...@sas.com>.
sorry, axis2. 

-----Original Message-----
From: Dr Janusz Martyniak [mailto:janusz.martyniak@imperial.ac.uk] 
Sent: Thursday, January 11, 2007 10:34 AM
To: axis-user@ws.apache.org
Subject: Re: AW: ServiceLifecycle

Tony Dean wrote:
> Here's what you need:
> 
> services.xml
> 
> <service name="yourService"
>          class="yourService.serviceLifeCyle" scope="request">
>     <parameter name="ServiceClass">yourService.Impl</parameter> 
>     ...
> <service/>
> 

  Hi,

Are you talking about axis2 ? I'm using axis 1.4 . There is no services.xml  apparently... server-config.wsdd seems to have a similar role in axis 1.4 but tags are somewhat different there. Have you tried the above solution on 1.x ?

                 Janusz

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AW: ServiceLifecycle

Posted by Dr Janusz Martyniak <ja...@imperial.ac.uk>.
Tony Dean wrote:
> Here's what you need:
> 
> services.xml
> 
> <service name="yourService"
>          class="yourService.serviceLifeCyle" scope="request">
>     <parameter name="ServiceClass">yourService.Impl</parameter> 
>     ...
> <service/>
> 

  Hi,

Are you talking about axis2 ? I'm using axis 1.4 . There is no 
services.xml  apparently... server-config.wsdd seems to have a similar 
role in axis 1.4 but tags are somewhat different there. Have you tried 
the above solution on 1.x ?

                 Janusz

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: AW: ServiceLifecycle

Posted by Tony Dean <To...@sas.com>.
Here's what you need:

services.xml

<service name="yourService"
         class="yourService.serviceLifeCyle" scope="request">
    <parameter name="ServiceClass">yourService.Impl</parameter> 
    ...
<service/>

yourService.serviceLifeCycle class is your service lifecycle class and it will be loaded one and only one time.  This class must implement startUp(ConfigurationContext ctx, AxisService service) and shutDown(ConfigurationContext ctx, AxisService service) and these methods are called once at the obvious time.

yourService.Impl is your implementation class.  It should contain an init(ServiceContext ctx) and destroy(ServiceContext ctx).  These methods are session-based and will be called everytime a new session is created and destroyed.  And since you specify scope=request, a new session will be created on every request.

Hope this explains what you need.

I use scope=application so I have not verified this myself, but I investigated all possible lifecycle scenarios when I was deciding how I wanted to implement my service.

-Tony

-----Original Message-----
From: Dr Janusz Martyniak [mailto:janusz.martyniak@imperial.ac.uk] 
Sent: Thursday, January 11, 2007 5:43 AM
To: axis-user@ws.apache.org
Subject: Re: AW: ServiceLifecycle

Deepal Jayasinghe wrote:
> Hi  Janusz;
> 
>>  but,
>>
>> The init() is called every time I invoke the method. 
> 
> That will only happen if you deploy your service in request scope , if 
> you deploy your service in application scope then that will never happen.
> 

  Well, if I deploy my service as an application then init() is called once and all the clients will share the implementation instance and the latter is not what I want.

What I'm trying to achieve is to keep the request mode, so every client gets his own instance of a service, but have a possibility to initialise the service once, possibly at servlet loading time, or at a very first call. The init() method does not deliver this.

> 
>>  Thre are lots of applications one would like to initialise the whole
>> system before actually performing any requests. Otherwise every call
>> to an operation has to perform often complex initialisation steps.
> 
> Totally agreed.
> 
  Appreciated ;-), but is there a way out ???

                         cheers, Janusz

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AW: ServiceLifecycle

Posted by Dr Janusz Martyniak <ja...@imperial.ac.uk>.
Deepal Jayasinghe wrote:
> Hi  Janusz;
> 
>>  but,
>>
>> The init() is called every time I invoke the method. 
> 
> That will only happen if you deploy your service in request scope , if
> you deploy your service in application scope then that will never happen.
> 

  Well, if I deploy my service as an application then init() is called 
once and all the clients will share the implementation instance and the 
latter is not what I want.

What I'm trying to achieve is to keep the request mode, so every client 
gets his own instance of a service, but have a possibility to initialise 
the service once, possibly at servlet loading time, or at a very first 
call. The init() method does not deliver this.

> 
>>  Thre are lots of applications one would like to initialise the whole
>> system before actually performing any requests. Otherwise every call
>> to an operation has to perform often complex initialisation steps.
> 
> Totally agreed.
> 
  Appreciated ;-), but is there a way out ???

                         cheers, Janusz

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AW: ServiceLifecycle

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi  Janusz;

>
>  but,
>
> The init() is called every time I invoke the method. 

That will only happen if you deploy your service in request scope , if
you deploy your service in application scope then that will never happen.

> I saw a post on axis2 and it seems to be different there (lifecycle !=
> session). 

Yes , session and life cycle are two different things , the idea of life
cycle interface is to provide a way to handle life cycle of the
AixsService and those life cycle method only call at the system start
time and when system goes down.
But , the idea of session is bit different . Sessions scope define the
life time of service impl class and the contexts.

> There is no much use of init() called every time for session-less
> services (I could put init() in a operation) and it just makes
> lifecycle=session (an application is an endless session ;-) ).


>
>  Is it possible to initialise the whole service _ONCE_ and still get a
> session-less services in Axis 1.4 ? The Web Services mit Axis, a
> German book the ebaykunde was probably referring to does suggest that
> init() is called only once "before a service can accept calls".

hmm, I am not sure abt Axis 1.4 :)

>
>  Thre are lots of applications one would like to initialise the whole
> system before actually performing any requests. Otherwise every call
> to an operation has to perform often complex initialisation steps.

Totally agreed.

>
>  Any ideas ?
>
>                   happy New Year to everyone !
>                             cheers Janusz
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AW: ServiceLifecycle

Posted by Dr Janusz Martyniak <ja...@imperial.ac.uk>.
Dies Koper wrote:

> 
> It depends on what you specify for the deployScope option. If you choose 
> "application", the init method will be called only once.
> 

  Well,

I tried the lifecycle business  as well (via skeletons which call imp 
classes explicitly in their init() method, i.e both skeletons and imp 
implement the interface)

  but,

The init() is called every time I invoke the method. I saw a post on 
axis2 and it seems to be different there (lifecycle != session). There 
is no much use of init() called every time for session-less services (I 
could put init() in a operation) and it just makes lifecycle=session (an 
application is an endless session ;-) ).

  Is it possible to initialise the whole service _ONCE_ and still get a 
session-less services in Axis 1.4 ? The Web Services mit Axis, a German 
book the ebaykunde was probably referring to does suggest that init() is 
called only once "before a service can accept calls".

  Thre are lots of applications one would like to initialise the whole 
system before actually performing any requests. Otherwise every call to 
an operation has to perform often complex initialisation steps.

  Any ideas ?

                   happy New Year to everyone !
                             cheers Janusz


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org