Package com.attivio.service
Class PooledClientProxy<T>
- java.lang.Object
-
- com.attivio.service.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 thanDEFAULT_MAX_IDLE_TIME
. If the class provided in the constructor implementsCloseable
then the client will beclosed()
before removal from the pool.
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_IDLE_CHECK_INTERVAL
static java.lang.String
DEFAULT_IDLE_CHECK_INTERVAL_PROP
static long
DEFAULT_MAX_IDLE_TIME
static java.lang.String
DEFAULT_MAX_IDLE_TIME_PROP
-
Constructor Summary
Constructors Constructor Description 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(java.lang.Class<T> actualClass, java.util.List<java.lang.Class<? extends java.util.function.Predicate<java.lang.Throwable>>> transientPredicates)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.Class<?>
getImplementationClass()
java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
-
-
-
Field Detail
-
DEFAULT_MAX_IDLE_TIME_PROP
public static final java.lang.String DEFAULT_MAX_IDLE_TIME_PROP
- See Also:
- Constant Field Values
-
DEFAULT_MAX_IDLE_TIME
public static final long DEFAULT_MAX_IDLE_TIME
- 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 interfacejava.lang.reflect.InvocationHandler
- Throws:
java.lang.Throwable
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
getImplementationClass
public java.lang.Class<?> getImplementationClass()
- Specified by:
getImplementationClass
in interfaceServiceProxy
- Returns:
- the Class> that is actually proxied
-
-