On 7/20/2012 8:53 AM, Jacopo Cappellato wrote:
Thank you Adrian, please see inline:

On Jul 20, 2012, at 9:33 AM, Adrian Crum wrote:

This will be very helpful - thanks for starting it Jacopo!

I will start off with the obvious answers...

LocalDispatcher: The service dispatcher interface.
GenericAbstractDispatcher/GenericDispatcher: LocalDispatcher implementations.
ServiceDispatcher: A service dispatcher "engine". Basically, the 
LocalDispatcher implementations delegate to it.
I guess that with "engine" you mean an "helper" class (or similar) and not a 
service engine (i.e. implementation of GenericEngine).

Correct.

Apart from this, I see that the ServiceDispatcher is used in a lot of code 
directly... shouldn't we use instead the LocalDispatcher? According to your 
notes, if I understand them, the only class that should reference the 
ServiceDispatcher should be GenericDispatcher that is the only class that 
implement LocalDispatcher; but GenericDispatcher doesn't use at all the 
ServiceDispatcher.

Correct. Ideally, client code should look something like this:

LocalDispatcher dispatcher = DispatcherFactory.getInstance(...);

GenericDispatcher uses ServiceDispatcher: GenericAbstractDispatcher.java, line 45.


My next doubt/question is about the GenericEngine interface: how it relates 
with LocalDispatcher and ServiceDispatcher?

GenericEngine is the abstraction that allows us to write services in Java, scripts, etc... So, a service dispatcher uses the GenericEngine to invoke the service in a language-independent way.


DispatchContext: A bag of objects needed for service execution, plus some 
utility methods.
So, is the DispatchContext associated to the LocalDispatcher or instead it is 
an implementation detail that makes sense only for the ServiceDispatcher?

It is associated with LocalDispatcher. If you have a LocalDispatcher in your hand, then you can use it to get a DispatchContext. If you have a DispatchContext in your hand, you can use it to get a LocalDispatcher. Keep in mind the DispatchContext contains the objects related to a service invocation: The service dispatcher, delegator, and security. You need all three to write a service.


Thanks,

Jacopo

I agree there is a lot of feature envy between classes. The API could be 
cleaned up a lot.

 From my perspective, the GenericDispatcher.getLocalDispatcher method should 
not exist - since it forces you to reference an implementation. Instead, there 
should be a separate service dispatcher factory.

-Adrian

On 7/20/2012 7:33 AM, Jacopo Cappellato wrote:
Hi all,

I am a bit confused about the meaning/purpose/responsibilities of the following 
classes:

ServiceDispatcher/GenericDispatcher/LocalDispatcher/DispatchContext

Would any of you help me understand the role of each of these classes? They all 
see rather intermingled in terms of responsibilities.
For example, what is the purpose of creating two instances with different names 
of a dispatcher associated to the same delegator:

LocalDispatcher dispatcher = GenericDispatcher.getLocalDispatcher("entity-" + 
delegator.getDelegatorName(), delegator);

and

LocalDispatcher thisDispatcher = 
GenericDispatcher.getLocalDispatcher(delegator.getDelegatorName(), delegator);

?

Thanks,

Jacopo





Reply via email to