@Override protected Object handleInvocation(Object proxy, final Method method, final Object[] args) throws Throwable { // Special case for close() allows closing the entire pool by calling close() on the proxy. if (_shutdownPoolOnClose && args.length == 0 && method.getName().equals("close")) { _servicePool.close(); return null; } PartitionContext partitionContext = _partitionContextSupplier.forCall(method, args); // Delegate the method through to a service provider in the pool. return _servicePool.execute(partitionContext, _retryPolicy, new ServiceCallback<S, Object>() { @Override public Object call(S service) throws ServiceException { try { return method.invoke(service, args); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { throw Throwables.propagate(e.getTargetException()); } } }); }
@Override protected Object handleInvocation(Object proxy, final Method method, final Object[] args) throws Throwable { // Special case for close() allows closing the entire pool by calling close() on the proxy. if (_shutdownPoolOnClose && args.length == 0 && method.getName().equals("close")) { _servicePool.close(); return null; } PartitionContext partitionContext = _partitionContextSupplier.forCall(method, args); // Delegate the method through to a service provider in the pool. return _servicePool.execute(partitionContext, _retryPolicy, new ServiceCallback<S, Object>() { @Override public Object call(S service) throws ServiceException { try { return method.invoke(service, args); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { throw Throwables.propagate(e.getTargetException()); } } }); }