com.thoughtworks.proxy.toys.pool
Class Pool.PoolingInvoker

java.lang.Object
  extended by com.thoughtworks.proxy.toys.delegate.DelegatingInvoker
      extended by com.thoughtworks.proxy.toys.pool.Pool.PoolingInvoker
All Implemented Interfaces:
Invoker, Serializable
Enclosing class:
Pool

protected static class Pool.PoolingInvoker
extends DelegatingInvoker

The Invoker of the proxy.

Since:
0.2
See Also:
Serialized Form

Constructor Summary
protected Pool.PoolingInvoker(Pool pool, ProxyFactory proxyFactory, ObjectReference delegateReference, int delegationMode)
          Construct a PoolingInvoker.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Invocation of a method of the proxied object.
protected  Object proxy()
          Create a proxy for the types of the pool.
 Object returnInstanceToPool()
          Return the current instance to the pool.
 
Methods inherited from class com.thoughtworks.proxy.toys.delegate.DelegatingInvoker
delegate, equals, getDelegateReference, getMethodToInvoke, getProxyFactory, hashCode, invokeOnDelegate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pool.PoolingInvoker

protected Pool.PoolingInvoker(Pool pool,
                              ProxyFactory proxyFactory,
                              ObjectReference delegateReference,
                              int delegationMode)
Construct a PoolingInvoker.

Parameters:
pool - the corresponding Pool
proxyFactory - the ProxyFactory to use
delegateReference - the ObjectReference with the delegate
delegationMode - onde of the delgation modes
Since:
0.2
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
Overrides:
invoke in class DelegatingInvoker
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.

returnInstanceToPool

public Object returnInstanceToPool()
Return the current instance to the pool. The pool's monitor will be notified, if the Resetter returns the object.

Returns:
Void.TYPE
Since:
0.2

proxy

protected Object proxy()
Create a proxy for the types of the pool.

Returns:
the new proxy instance
Since:
0.2