| |
|
| java.lang.Object biz.hammurapi.dispatch.Dispatcher
All known Subclasses: biz.hammurapi.dispatch.QueuingDispatcher,
Dispatcher | public class Dispatcher (Code) | | This class dispatches objects to invocation handlers which can accept them.
Target invocation handlers are organized in "buckets" keyed by the argument class. This makes dispatching
very efficient at runtime because only compatible handlers are interated over for invocation.
author: Pavel Vlasov |
Inner Class :protected interface Invocation | |
Constructor Summary | |
public | Dispatcher(Collection targets) Creates dispatcher.
Parameters: targets - Collection which contains instances of InvocationTarget or InvocationHandler. |
Method Summary | |
protected void | consumeResult(Object result) Consumes invocation results. | public void | dispatch(Object arg) Dispatches object to invocation handlers.
Exceptions thrown by handlers are wrapped into DispatchException and that exception is dispatched as
though it is a return value. | public int | size() |
Dispatcher | public Dispatcher(Collection targets)(Code) | | Creates dispatcher.
Parameters: targets - Collection which contains instances of InvocationTarget or InvocationHandler. |
consumeResult | protected void consumeResult(Object result)(Code) | | Consumes invocation results. This implementation
simply dispatches results.
Override this method to provide more advanced results handling.
Parameters: result - |
dispatch | public void dispatch(Object arg)(Code) | | Dispatches object to invocation handlers.
Exceptions thrown by handlers are wrapped into DispatchException and that exception is dispatched as
though it is a return value. It is recommended to have an invocation handler which would handle thrown
exceptions, e.g. log them. Errors are propagated up.
Parameters: arg - Instance to be dispatched. |
size | public int size()(Code) | | Number of handlers |
|
|
|