Class BaseProxyHandler<T>

  • Type Parameters:
    T - type of the wrapped pooled object
    Direct Known Subclasses:
    CglibProxyHandler, JdkProxyHandler

    class BaseProxyHandler<T>
    extends java.lang.Object
    Base implementation for object wrappers when using a ProxiedObjectPool.
    Since:
    2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseProxyHandler​(T pooledObject, UsageTracking<T> usageTracking)
      Create a new wrapper for the given pooled object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) T disableProxy()
      Disable the proxy wrapper.
      (package private) java.lang.Object doInvoke​(java.lang.reflect.Method method, java.lang.Object[] args)
      Invoke the given method on the wrapped object.
      (package private) T getPooledObject()
      Obtain the wrapped, pooled object.
      (package private) void validateProxiedObject()
      Check that the proxy is still valid (i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pooledObject

        private volatile T pooledObject
    • Constructor Detail

      • BaseProxyHandler

        BaseProxyHandler​(T pooledObject,
                         UsageTracking<T> usageTracking)
        Create 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 Detail

      • getPooledObject

        T getPooledObject()
        Obtain the wrapped, pooled object.
        Returns:
        the underlying pooled object
      • 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
      • validateProxiedObject

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

        java.lang.Object doInvoke​(java.lang.reflect.Method method,
                                  java.lang.Object[] args)
                           throws java.lang.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:
        java.lang.Throwable - If the method invocation fails