Class JdkProxySource<T>

java.lang.Object
org.apache.commons.pool2.proxy.JdkProxySource<T>
Type Parameters:
T - type of the pooled object to be proxied
All Implemented Interfaces:
ProxySource<T>

public class JdkProxySource<T> extends Object implements ProxySource<T>
Provides proxy objects using Java reflection.
Since:
2.0
  • Field Details

    • classLoader

      private final ClassLoader classLoader
    • interfaces

      private final Class<?>[] interfaces
  • Constructor Details

    • JdkProxySource

      public JdkProxySource(ClassLoader classLoader, Class<?>[] interfaces)
      Constructs a new proxy source for the given interfaces.
      Parameters:
      classLoader - The class loader with which to create the proxy
      interfaces - The interfaces to proxy
  • Method Details

    • createProxy

      public T createProxy(T pooledObject, UsageTracking<T> usageTracking)
      Description copied from interface: ProxySource
      Creates a new proxy object, wrapping the given pooled object.
      Specified by:
      createProxy in interface ProxySource<T>
      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
      Returns:
      the new proxy object
    • resolveProxy

      public T resolveProxy(T proxy)
      Description copied from interface: ProxySource
      Resolves the wrapped object from the given proxy.
      Specified by:
      resolveProxy in interface ProxySource<T>
      Parameters:
      proxy - The proxy object
      Returns:
      The pooled object wrapped by the given proxy
    • toString

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