Class JdkProxySource<T>

  • Type Parameters:
    T - type of the pooled object to be proxied
    All Implemented Interfaces:
    ProxySource<T>

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

      Fields 
      Modifier and Type Field Description
      private java.lang.ClassLoader classLoader  
      private java.lang.Class<?>[] interfaces  
    • Constructor Summary

      Constructors 
      Constructor Description
      JdkProxySource​(java.lang.ClassLoader classLoader, java.lang.Class<?>[] interfaces)
      Create a new proxy source for the given interfaces.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T createProxy​(T pooledObject, UsageTracking<T> usageTracking)
      Create a new proxy object, wrapping the given pooled object.
      T resolveProxy​(T proxy)
      Obtain the wrapped object from the given proxy.
      • Methods inherited from class java.lang.Object

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

      • classLoader

        private final java.lang.ClassLoader classLoader
      • interfaces

        private final java.lang.Class<?>[] interfaces
    • Constructor Detail

      • JdkProxySource

        public JdkProxySource​(java.lang.ClassLoader classLoader,
                              java.lang.Class<?>[] interfaces)
        Create 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 Detail

      • createProxy

        public T createProxy​(T pooledObject,
                             UsageTracking<T> usageTracking)
        Description copied from interface: ProxySource
        Create 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
        Obtain the wrapped object from the given proxy.
        Specified by:
        resolveProxy in interface ProxySource<T>
        Parameters:
        proxy - The proxy object
        Returns:
        The pooled objetc wrapped by the given proxy