@Test public void testProxyImplementsCloseable() throws IOException { Service service = ServicePoolProxy.create(Service.class, NEVER_RETRY, _pool, SUPPLIER, true); assertTrue(service instanceof Closeable); }
static <S> S create(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> pool, PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?>[] interfaces = shutdownPoolOnClose ? new Class<?>[] {serviceType, Closeable.class} : new Class<?>[] {serviceType}; ServicePoolProxy<S> proxy = new ServicePoolProxy<S>( serviceType, retryPolicy, pool, partitionContextSupplier, shutdownPoolOnClose); return serviceType.cast(Proxy.newProxyInstance(loader, interfaces, proxy)); }
ServicePoolProxy extends AbstractInvocationHandler { static <S> S create(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> pool, PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?>[] interfaces = shutdownPoolOnClose ? new Class<?>[] {serviceType, Closeable.class} : new Class<?>[] {serviceType}; ServicePoolProxy<S> proxy = new ServicePoolProxy<S>( serviceType, retryPolicy, pool, partitionContextSupplier, shutdownPoolOnClose); return serviceType.cast(Proxy.newProxyInstance(loader, interfaces, proxy)); } }
ServicePoolProxy extends AbstractInvocationHandler { static <S> S create(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> pool, PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?>[] interfaces = shutdownPoolOnClose ? new Class<?>[] {serviceType, Closeable.class} : new Class<?>[] {serviceType}; ServicePoolProxy<S> proxy = new ServicePoolProxy<S>( serviceType, retryPolicy, pool, partitionContextSupplier, shutdownPoolOnClose); return serviceType.cast(Proxy.newProxyInstance(loader, interfaces, proxy)); } ServicePoolProxy(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> servicePool,
                     PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose); }
ServicePoolProxy extends AbstractInvocationHandler { static <S> S create(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> pool, PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?>[] interfaces = shutdownPoolOnClose ? new Class<?>[] {serviceType, Closeable.class} : new Class<?>[] {serviceType}; ServicePoolProxy<S> proxy = new ServicePoolProxy<S>( serviceType, retryPolicy, pool, partitionContextSupplier, shutdownPoolOnClose); return serviceType.cast(Proxy.newProxyInstance(loader, interfaces, proxy)); } ServicePoolProxy(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> servicePool,
                     PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose); @Override String toString(); }
ServicePoolProxy extends AbstractInvocationHandler { static <S> S create(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> pool, PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?>[] interfaces = shutdownPoolOnClose ? new Class<?>[] {serviceType, Closeable.class} : new Class<?>[] {serviceType}; ServicePoolProxy<S> proxy = new ServicePoolProxy<S>( serviceType, retryPolicy, pool, partitionContextSupplier, shutdownPoolOnClose); return serviceType.cast(Proxy.newProxyInstance(loader, interfaces, proxy)); } ServicePoolProxy(Class<S> serviceType, RetryPolicy retryPolicy, ServicePool<S> servicePool,
                     PartitionContextSupplier partitionContextSupplier, boolean shutdownPoolOnClose); @Override String toString();  }