com.thoughtworks.proxy.toys.pool
Class Pool.PoolingInvoker<T>

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

protected static class Pool.PoolingInvoker<T>
extends DelegatingInvoker<T>

The Invoker of the proxy.

Since:
0.2
See Also:
Serialized Form

Constructor Summary
protected Pool.PoolingInvoker(Pool<T> pool, ProxyFactory proxyFactory, ObjectReference<T> delegateReference, DelegationMode delegationMode)
          Construct a PoolingInvoker.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Invocation of a method of the proxied object.
protected  T proxy()
          Create a proxy for the types of the pool.
 void 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<T> pool,
                              ProxyFactory proxyFactory,
                              ObjectReference<T> delegateReference,
                              DelegationMode delegationMode)
Construct a PoolingInvoker.

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

returnInstanceToPool

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

Since:
0.2

proxy

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

Returns:
the new proxy instance
Since:
0.2


Copyright © 2005-2010 Codehaus. All Rights Reserved.