Class BaseProxyHandler<T>

java.lang.Object
org.apache.commons.pool2.proxy.BaseProxyHandler<T>
Type Parameters:
T - type of the wrapped pooled object
Direct Known Subclasses:
CglibProxyHandler, JdkProxyHandler

class BaseProxyHandler<T> extends Object
Base implementation for object wrappers when using a ProxiedObjectPool.
Since:
2.0
  • Field Details

    • pooledObject

      private volatile T pooledObject
    • usageTracking

      private final UsageTracking<T> usageTracking
  • Constructor Details

    • BaseProxyHandler

      BaseProxyHandler(T pooledObject, UsageTracking<T> usageTracking)
      Constructs a new wrapper for the given pooled object.
      Parameters:
      pooledObject - The object to wrap
      usageTracking - The instance, if any (usually the object pool) to be provided with usage tracking information for this wrapped object
  • Method Details

    • disableProxy

      T disableProxy()
      Disable the proxy wrapper. Called when the object has been returned to the pool. Further use of the wrapper should result in an IllegalStateException.
      Returns:
      the object that this proxy was wrapping
    • doInvoke

      Object doInvoke(Method method, Object[] args) throws Throwable
      Invoke the given method on the wrapped object.
      Parameters:
      method - The method to invoke
      args - The arguments to the method
      Returns:
      The result of the method call
      Throws:
      Throwable - If the method invocation fails
    • getPooledObject

      T getPooledObject()
      Gets the wrapped, pooled object.
      Returns:
      the underlying pooled object
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      2.4.3
    • validateProxiedObject

      void validateProxiedObject()
      Check that the proxy is still valid (i.e. that disableProxy() has not been called).
      Throws:
      IllegalStateException - if disableProxy() has been called