com.thoughtworks.proxy.toys.multicast
Class MulticastingInvoker<T>

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

public class MulticastingInvoker<T>
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 behavior 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.
 T 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 T 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 method.
Returns:
the result of the invoked method.
Throws:
Throwable - if the invoked method has thrown.


Copyright © 2005-2010 Codehaus. All Rights Reserved.