public static Connection wrapInterceptor(Connection delegate) { InterceptorConnection instance = new InterceptorConnection(delegate); return (Connection) Proxy.newProxyInstance( InterceptorConnection.class.getClassLoader(), new Class[]{Connection.class}, instance); } }
@Override public Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { Object ret; try { ret = method.invoke(delegate, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } Class<? extends Statement> wrapperClazz = INTERCEPT_METHODS.get(method.getName()); if (wrapperClazz != null) { ret = wrap(wrapperClazz, ret); } return ret; }
@Override protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { Object ret; try { ret = method.invoke(delegate, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } if (method.getName().equals("getConnection")) { Connection conn = (Connection) ret; conn = InterceptorConnection.wrapInterceptor(conn); onAcquire(conn); ret = conn; } return ret; }
public static Connection wrapInterceptor(Connection delegate) { InterceptorConnection instance = new InterceptorConnection(delegate); return (Connection) Proxy.newProxyInstance( InterceptorConnection.class.getClassLoader(), new Class[]{Connection.class}, instance); } }
@Override public Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { Object ret; try { ret = method.invoke(delegate, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } Class<? extends Statement> wrapperClazz = INTERCEPT_METHODS.get(method.getName()); if (wrapperClazz != null) { ret = wrap(wrapperClazz, ret); } return ret; }
@Override protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { Object ret; try { ret = method.invoke(delegate, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } if (method.getName().equals("getConnection")) { Connection conn = (Connection) ret; conn = InterceptorConnection.wrapInterceptor(conn); onAcquire(conn); ret = conn; } return ret; }