public static void exitJdbcMethod(Method method, long elapsedTime) { exitJdbcMethod(method, elapsedTime, null); }
public static void exitJdbcMethod(Method method, long elapsedTime) { exitJdbcMethod(method, elapsedTime, null); }
public static void readDatabaseRow(Method method, long elapsedTime, StatementMetaData statementMetaData) { exitJdbcMethod(method, elapsedTime); notifyListeners(statementMetaData); }
public static void readDatabaseRow(Method method, long elapsedTime, StatementMetaData statementMetaData) { exitJdbcMethod(method, elapsedTime); notifyListeners(statementMetaData); }
protected Object invokeTarget(Method method, Object[] args) throws Throwable { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return invokeTargetImpl(method, args); } finally { Sniffy.exitJdbcMethod(method, System.currentTimeMillis() - start); } }
protected Object invokeTarget(Method method, Object[] args) throws Throwable { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return invokeTargetImpl(method, args); } finally { Sniffy.exitJdbcMethod(method, System.currentTimeMillis() - start); } }
@Override public Connection getConnection(String userName, String password) throws SQLException { if (null == dataSource) throw new SQLException("Target is not a DataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return dataSource.getConnection(userName, password); Connection delegateConnection; long start = System.currentTimeMillis(); String url; try { Sniffy.enterJdbcMethod(); delegateConnection = dataSource.getConnection(userName, password); url = delegateConnection.getMetaData().getURL(); SniffyDriver.checkConnectionAllowed(url, userName); } finally { Sniffy.exitJdbcMethod(GET_CONNECTION_WITH_CREDENTIALS_METHOD, System.currentTimeMillis() - start, GET_CONNECTION_WITH_CREDENTIALS_METHOD_IMPL); } return Connection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(delegateConnection, url, userName) )); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ("getConnection".equals(method.getName())) { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Connection targetConnection = Connection.class.cast(method.invoke(delegate, args)); String url = targetConnection.getMetaData().getURL(); String userName = targetConnection.getMetaData().getUserName(); SniffyDriver.checkConnectionAllowed(targetConnection, url, userName); return Connection.class.cast(Proxy.newProxyInstance( PooledConnectionInvocationHandler.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(targetConnection, url, userName) )); } finally { Sniffy.exitJdbcMethod(GET_CONNECTION_METHOD, System.currentTimeMillis() - start); } } else { return method.invoke(delegate, args); } }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ("getConnection".equals(method.getName())) { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Connection targetConnection = Connection.class.cast(method.invoke(delegate, args)); String url = targetConnection.getMetaData().getURL(); String userName = targetConnection.getMetaData().getUserName(); SniffyDriver.checkConnectionAllowed(targetConnection, url, userName); return Connection.class.cast(Proxy.newProxyInstance( PooledConnectionInvocationHandler.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(targetConnection, url, userName) )); } finally { Sniffy.exitJdbcMethod(GET_CONNECTION_METHOD, System.currentTimeMillis() - start); } } else { return method.invoke(delegate, args); } }
@Override public Connection getConnection(String userName, String password) throws SQLException { if (null == dataSource) throw new SQLException("Target is not a DataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return dataSource.getConnection(userName, password); Connection delegateConnection; long start = System.currentTimeMillis(); String url; try { Sniffy.enterJdbcMethod(); delegateConnection = dataSource.getConnection(userName, password); url = delegateConnection.getMetaData().getURL(); SniffyDriver.checkConnectionAllowed(url, userName); } finally { Sniffy.exitJdbcMethod(GET_CONNECTION_WITH_CREDENTIALS_METHOD, System.currentTimeMillis() - start, GET_CONNECTION_WITH_CREDENTIALS_METHOD_IMPL); } return Connection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(delegateConnection, url, userName) )); }
@Override public XAConnection getXAConnection() throws SQLException { if (null == dataSource) throw new SQLException("Target is not a XADataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return xaDataSource.getXAConnection(); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return XAConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{XAConnection.class}, new PooledConnectionInvocationHandler(xaDataSource.getXAConnection()) )); } finally { Sniffy.exitJdbcMethod(GET_XA_CONNECTION_METHOD, System.currentTimeMillis() - start, GET_XA_CONNECTION_METHOD_IMPL); } }
@Override public XAConnection getXAConnection() throws SQLException { if (null == dataSource) throw new SQLException("Target is not a XADataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return xaDataSource.getXAConnection(); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return XAConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{XAConnection.class}, new PooledConnectionInvocationHandler(xaDataSource.getXAConnection()) )); } finally { Sniffy.exitJdbcMethod(GET_XA_CONNECTION_METHOD, System.currentTimeMillis() - start, GET_XA_CONNECTION_METHOD_IMPL); } }
@Override public XAConnection getXAConnection(String user, String password) throws SQLException { if (null == dataSource) throw new SQLException("Target is not a XADataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return xaDataSource.getXAConnection(user, password); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return XAConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{XAConnection.class}, new PooledConnectionInvocationHandler(xaDataSource.getXAConnection(user, password)) )); } finally { Sniffy.exitJdbcMethod(GET_XA_CONNECTION_WITH_CREDENTIALS_METHOD, System.currentTimeMillis() - start, GET_XA_CONNECTION_WITH_CREDENTIALS_METHOD_IMPL); } }
@Override public PooledConnection getPooledConnection() throws SQLException { if (null == connectionPoolDataSource) throw new SQLException("Target is not a ConnectionPoolDataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return connectionPoolDataSource.getPooledConnection(); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return PooledConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{PooledConnection.class}, new PooledConnectionInvocationHandler(connectionPoolDataSource.getPooledConnection()) )); } finally { Sniffy.exitJdbcMethod(GET_POOLED_CONNECTION_METHOD, System.currentTimeMillis() - start, GET_POOLED_CONNECTION_METHOD_IMPL); } }
@Override public PooledConnection getPooledConnection(String user, String password) throws SQLException { if (null == connectionPoolDataSource) throw new SQLException("Target is not a ConnectionPoolDataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return connectionPoolDataSource.getPooledConnection(user, password); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return PooledConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{PooledConnection.class}, new PooledConnectionInvocationHandler(connectionPoolDataSource.getPooledConnection(user, password)) )); } finally { Sniffy.exitJdbcMethod(GET_POOLED_CONNECTION_WITH_CREDENTIALS_METHOD, System.currentTimeMillis() - start, GET_POOLED_CONNECTION_WITH_CREDENTIALS_METHOD_IMPL); } }
@Override public XAConnection getXAConnection(String user, String password) throws SQLException { if (null == dataSource) throw new SQLException("Target is not a XADataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return xaDataSource.getXAConnection(user, password); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return XAConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{XAConnection.class}, new PooledConnectionInvocationHandler(xaDataSource.getXAConnection(user, password)) )); } finally { Sniffy.exitJdbcMethod(GET_XA_CONNECTION_WITH_CREDENTIALS_METHOD, System.currentTimeMillis() - start, GET_XA_CONNECTION_WITH_CREDENTIALS_METHOD_IMPL); } }
@Override public PooledConnection getPooledConnection() throws SQLException { if (null == connectionPoolDataSource) throw new SQLException("Target is not a ConnectionPoolDataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return connectionPoolDataSource.getPooledConnection(); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return PooledConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{PooledConnection.class}, new PooledConnectionInvocationHandler(connectionPoolDataSource.getPooledConnection()) )); } finally { Sniffy.exitJdbcMethod(GET_POOLED_CONNECTION_METHOD, System.currentTimeMillis() - start, GET_POOLED_CONNECTION_METHOD_IMPL); } }
@Override public PooledConnection getPooledConnection(String user, String password) throws SQLException { if (null == connectionPoolDataSource) throw new SQLException("Target is not a ConnectionPoolDataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return connectionPoolDataSource.getPooledConnection(user, password); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); return PooledConnection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{PooledConnection.class}, new PooledConnectionInvocationHandler(connectionPoolDataSource.getPooledConnection(user, password)) )); } finally { Sniffy.exitJdbcMethod(GET_POOLED_CONNECTION_WITH_CREDENTIALS_METHOD, System.currentTimeMillis() - start, GET_POOLED_CONNECTION_WITH_CREDENTIALS_METHOD_IMPL); } }
protected Object invokeTargetAndRecord(Method method, Object[] args) throws Throwable { if (Sniffy.hasSpies()) { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Object result = invokeTargetImpl(method, args); if (Boolean.TRUE.equals(result)) { Sniffy.readDatabaseRow(method, System.currentTimeMillis() - start, statementMetaData); } return result; } finally { Sniffy.exitJdbcMethod(method, System.currentTimeMillis() - start); } } else { return invokeTargetImpl(method, args); } } }
protected Object invokeTargetAndRecord(Method method, Object[] args) throws Throwable { if (Sniffy.hasSpies()) { long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Object result = invokeTargetImpl(method, args); if (Boolean.TRUE.equals(result)) { Sniffy.readDatabaseRow(method, System.currentTimeMillis() - start, statementMetaData); } return result; } finally { Sniffy.exitJdbcMethod(method, System.currentTimeMillis() - start); } } else { return invokeTargetImpl(method, args); } } }