How to extend a service with a base method defined in parent service

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to extend a service with a base method defined in parent service

Deepak Agarwal-2
Hello,

I have a requirement where I want to keep common 'operations' (not
attributes) in one service and then want to extend it with several
services. Here, I want that while running child services base service
method gets run first (just in a normal polymorphism concept).

Is it possible to define these services in services.xml OOTB ?

In my knowledge so far services defined in the services.xml can
inherit/override the attributes but the following doesn't work

<service name="ParentService" engine="groovy"
location="component://mycomp/webapp/mycomp/WEB-INF/action/folder/Parent.groovy"></service>

<service name="ChildService" engine="groovy"
location="component://mycomp/webapp/mycomp/WEB-INF/action/folder/Child.groovy">
   <implements service="ParentService"/>
</service>

Or, probably only 'implements' is supported and hence only interfaces can
be implemented and no support for extending services.

--
Thanks,
Deepak Agarwal,

Mobile: +91 9501190044
Reply | Threaded
Open this post in threaded view
|

Re: How to extend a service with a base method defined in parent service

Adrian Crum-3
The <inherits> element only affects service attributes. So, your child
service will need to invoke the parent service.

-Adrian

On 3/21/2013 7:07 AM, Deepak Agarwal wrote:

> Hello,
>
> I have a requirement where I want to keep common 'operations' (not
> attributes) in one service and then want to extend it with several
> services. Here, I want that while running child services base service
> method gets run first (just in a normal polymorphism concept).
>
> Is it possible to define these services in services.xml OOTB ?
>
> In my knowledge so far services defined in the services.xml can
> inherit/override the attributes but the following doesn't work
>
> <service name="ParentService" engine="groovy"
> location="component://mycomp/webapp/mycomp/WEB-INF/action/folder/Parent.groovy"></service>
>
> <service name="ChildService" engine="groovy"
> location="component://mycomp/webapp/mycomp/WEB-INF/action/folder/Child.groovy">
>     <implements service="ParentService"/>
> </service>
>
> Or, probably only 'implements' is supported and hence only interfaces can
> be implemented and no support for extending services.
>