You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by ian tabangay <it...@gmail.com> on 2008/09/10 07:59:42 UTC

runSync or call directly

Hi. If I have a service written in java, why or why should I not call
another service (also written in java) directly?

-- start code --
public static Map serviceA(DispatchContext dctx, Map context) {
  ...
}

public static Map serviceB(DispatchContext dctx, Map context) {
  ...
}
-- end code --

For example, to call serviceB from serviceA, is it more advisable to access
it via
  dispatcher.runSync("serviceA", context)
or can I just call it directly like so:
  serviceB(dctx, context)


Thanks

~ ian

Re: runSync or call directly

Posted by Jacques Le Roux <ja...@les7arts.com>.
From: "Jacopo Cappellato" <ja...@gmail.com>
> Always use runSync: there is a small overhead but several advantages,  
> one the most important ones is that you just refer to the service  
> definition and not on the actual implementation details (Java method,  
> Minilang method etc...).

Also direct Java calls are not ECA aware and this is a very important part of OFBiz : its business workflow.

Jacques

> Jacopo
> 
> 
> On Sep 10, 2008, at 7:59 AM, ian tabangay wrote:
> 
>> Hi. If I have a service written in java, why or why should I not call
>> another service (also written in java) directly?
>>
>> -- start code --
>> public static Map serviceA(DispatchContext dctx, Map context) {
>>  ...
>> }
>>
>> public static Map serviceB(DispatchContext dctx, Map context) {
>>  ...
>> }
>> -- end code --
>>
>> For example, to call serviceB from serviceA, is it more advisable to  
>> access
>> it via
>>  dispatcher.runSync("serviceA", context)
>> or can I just call it directly like so:
>>  serviceB(dctx, context)
>>
>>
>> Thanks
>>
>> ~ ian
> 
>

Re: runSync or call directly

Posted by ian tabangay <it...@gmail.com>.
Ok thanks for the info.

~ ian

On Wed, Sep 10, 2008 at 3:23 PM, Jacopo Cappellato <
jacopo.cappellato@gmail.com> wrote:

> Always use runSync: there is a small overhead but several advantages, one
> the most important ones is that you just refer to the service definition and
> not on the actual implementation details (Java method, Minilang method
> etc...).
>
> Jacopo

Re: runSync or call directly

Posted by Jacopo Cappellato <ja...@gmail.com>.
Always use runSync: there is a small overhead but several advantages,  
one the most important ones is that you just refer to the service  
definition and not on the actual implementation details (Java method,  
Minilang method etc...).

Jacopo


On Sep 10, 2008, at 7:59 AM, ian tabangay wrote:

> Hi. If I have a service written in java, why or why should I not call
> another service (also written in java) directly?
>
> -- start code --
> public static Map serviceA(DispatchContext dctx, Map context) {
>  ...
> }
>
> public static Map serviceB(DispatchContext dctx, Map context) {
>  ...
> }
> -- end code --
>
> For example, to call serviceB from serviceA, is it more advisable to  
> access
> it via
>  dispatcher.runSync("serviceA", context)
> or can I just call it directly like so:
>  serviceB(dctx, context)
>
>
> Thanks
>
> ~ ian