com.thoughtworks.proxy.toys.multicast
Class MulticastingInvoker

java.lang.Object
  extended by com.thoughtworks.proxy.toys.multicast.MulticastingInvoker
All Implemented Interfaces:
Invoker, Serializable

public class MulticastingInvoker
extends Object
implements Invoker

A Invoker implementation that multicasts calls to multiple targets. Proxies generated by this class will forward all method invocations to an array of underlying objects. The behaviour is recursive, so return values will also be multicasting objects.

Since:
0.1
Author:
Aslak Hellesøy, Chris Stevenson, Jörg Schaible
See Also:
Serialized Form

Constructor Summary
MulticastingInvoker(Class[] type, ProxyFactory proxyFactory, Object[] targets)
          Construct a MulticastingInvoker.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Invocation of a method of the proxied object.
 Object proxy()
          Create a proxy for this Invoker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MulticastingInvoker

public MulticastingInvoker(Class[] type,
                           ProxyFactory proxyFactory,
                           Object[] targets)
Construct a MulticastingInvoker.

Parameters:
type - the implemented types
proxyFactory - the ProxyFactory to use
targets - the target instances where the proxy delegates a call
Since:
0.1
Method Detail

proxy

public Object proxy()
Create a proxy for this Invoker.

Returns:
the new proxy
Since:
0.1

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Description copied from interface: Invoker
Invocation of a method of the proxied object.

Specified by:
invoke in interface Invoker
Parameters:
proxy - the proxy instance.
method - the method to invoke.
args - the arguments of the mothod.
Returns:
the result of the onvoked method.
Throws:
Throwable - if the invoked method has thrown.