On Jul 20, 2012, at 10:51 AM, Adrian Crum wrote:

> 
> On 7/20/2012 9:43 AM, Jacopo Cappellato wrote:
>> Thank you Adrian, it is of great help.
>> 
>> On Jul 20, 2012, at 10:07 AM, Adrian Crum wrote:
>> 
>>> 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.
>> Well, actually the getDelegator and getSecurity methods of DispatchContext 
>> simply returns the objects from the LocalDispatcher.
>> It seems that the only real purpose of DispatchContext is as an helper to 
>> read (and cache) service definitions; there is also a useful 
>> makeValidContext method but that can be made static (I will probably commit 
>> this change later) and may in theory be moved in some other class.
>> If my understanding is correct, then the name of this class is misleading.
>> Do you agree?
> 
> No, I don't agree. If you look at a typical Java service method signature, 
> you have something like:
> 
> public static Map<String, Object> myService(DispatchContext.dctx, Map<String, 
> Object> context)...
> 
> The DispatchContext contains the objects common to all invocations of 
> myService, and the context Map contains the objects specific to each 
> invocation. In order to write a service, you will need the objects the 
> DispatchContext contains. From my perspective, the class name accurately 
> describes its purpose.

What I meant to say is that DispatchContext actually delegates the retrieval of 
the delegator and security to the LocalDispatcher; it is not the glue that 
keeps together a Delegator, a Security and a LocalDispatcher but it is instead 
an helper class to retrieve the Delegator and Security from the LocalDispatcher.
I agree that it is used as a "context" in all service implementations.
The real added value of the DispatchContext object is that it compose a 
LocalDispatcher with a ClassLoader and a collection of localReaders (i.e. paths 
to service definitions).

Jacopo

> 
> -Adrian
> 
> 

Reply via email to