Class PooledClientProxy<T>

  • All Implemented Interfaces:
    ServiceProxy, java.io.Closeable, java.lang.AutoCloseable, java.lang.reflect.InvocationHandler

    public class PooledClientProxy<T>
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler, java.io.Closeable, ServiceProxy
    A client proxy that uses a pool of clients to satisfy API requests. Clients in the pool are created on demand and cleaned up if idle for more than DEFAULT_MAX_IDLE_TIME. If the class provided in the constructor implements Closeable then the client will be closed() before removal from the pool.
    • Field Detail

      • DEFAULT_MAX_IDLE_TIME_PROP

        public static final java.lang.String DEFAULT_MAX_IDLE_TIME_PROP
        See Also:
        Constant Field Values
      • DEFAULT_IDLE_CHECK_INTERVAL_PROP

        public static final java.lang.String DEFAULT_IDLE_CHECK_INTERVAL_PROP
        See Also:
        Constant Field Values
      • DEFAULT_IDLE_CHECK_INTERVAL

        public static final long DEFAULT_IDLE_CHECK_INTERVAL
        See Also:
        Constant Field Values
    • Constructor Detail

      • PooledClientProxy

        public PooledClientProxy​(ClientApiFactory<T> clientFactory,
                                 java.lang.Class<T> apiClass,
                                 java.util.List<java.lang.Class<? extends java.util.function.Predicate<java.lang.Throwable>>> transientPredicates)
      • PooledClientProxy

        public PooledClientProxy​(java.lang.Class<T> actualClass,
                                 java.util.List<java.lang.Class<? extends java.util.function.Predicate<java.lang.Throwable>>> transientPredicates)
    • Method Detail

      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)
                                throws java.lang.Throwable
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
        Throws:
        java.lang.Throwable
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • getImplementationClass

        public java.lang.Class<?> getImplementationClass()
        Specified by:
        getImplementationClass in interface ServiceProxy
        Returns:
        the Class that is actually proxied