com.thoughtworks.proxy.toys.future
Class FutureInvoker

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

public class FutureInvoker
extends Object
implements Invoker

Invoker that implements transparent asynchronous method calls. The invoked method will return immediately with a result that can be hot swapped. This result proxy contains first a null object and will automatically replaced later on when the asynchronous method call returns the correct result.

Since:
1.0
Author:
Aslak Hellesøy
See Also:
Serialized Form

Constructor Summary
FutureInvoker(Object target, ProxyFactory proxyFactory, ExecutorService executor)
          Construct the invoker.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Invocation of a method of the proxied object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FutureInvoker

public FutureInvoker(Object target,
                     ProxyFactory proxyFactory,
                     ExecutorService executor)
Construct the invoker.

Parameters:
target - the instance that will have its methods called asynchronously
proxyFactory - the proxy factory used to create the proxy for the target instance and all return types of the called methods
executor - the executor used to call the method asynchronously
Since:
1.0
Method Detail

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.