You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Deepak Agarwal <da...@gmail.com> on 2013/03/21 08:07:16 UTC
How to extend a service with a base method defined in parent service
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
Re: How to extend a service with a base method defined in parent
service
Posted by Adrian Crum <ad...@sandglass-software.com>.
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.
>