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.
-Adrian