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 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 Connection getConnection() throws SQLException { if (null == dataSource) throw new SQLException("Target is not a DataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return dataSource.getConnection(); Connection delegateConnection; long start = System.currentTimeMillis(); String url; String userName; try { Sniffy.enterJdbcMethod(); delegateConnection = dataSource.getConnection(); // TODO: cache these parameters url = delegateConnection.getMetaData().getURL(); userName = delegateConnection.getMetaData().getUserName(); SniffyDriver.checkConnectionAllowed(url, userName); } finally { Sniffy.exitJdbcMethod(GET_CONNECTION_METHOD, System.currentTimeMillis() - start, GET_CONNECTION_METHOD_IMPL); } return Connection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(delegateConnection, url, userName) )); }
@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 Connection getConnection() throws SQLException { if (null == dataSource) throw new SQLException("Target is not a DataSource instance"); if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return dataSource.getConnection(); Connection delegateConnection; long start = System.currentTimeMillis(); String url; String userName; try { Sniffy.enterJdbcMethod(); delegateConnection = dataSource.getConnection(); // TODO: cache these parameters url = delegateConnection.getMetaData().getURL(); userName = delegateConnection.getMetaData().getUserName(); SniffyDriver.checkConnectionAllowed(url, userName); } finally { Sniffy.exitJdbcMethod(GET_CONNECTION_METHOD, System.currentTimeMillis() - start, GET_CONNECTION_METHOD_IMPL); } return Connection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(delegateConnection, url, userName) )); }
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); } } }
public Connection connect(String url, Properties info) throws SQLException { if (null == url || !acceptsURL(url)) return null; String originUrl = extractOriginUrl(url); String userName = info.getProperty("user"); checkConnectionAllowed(originUrl, userName, true); Driver originDriver; try { originDriver = DriverManager.getDriver(originUrl); } catch (SQLException e) { try { reloadServiceProviders(); originDriver = DriverManager.getDriver(originUrl); } catch (Exception e2) { throw e; } } if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return originDriver.connect(originUrl, info); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Connection delegateConnection = originDriver.connect(originUrl, info); return Connection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(delegateConnection, originUrl, userName) )); } finally { Sniffy.exitJdbcMethod(CONNECT_METHOD, System.currentTimeMillis() - start, CONNECT_METHOD_IMPL); } }
public Connection connect(String url, Properties info) throws SQLException { if (null == url || !acceptsURL(url)) return null; String originUrl = extractOriginUrl(url); String userName = info.getProperty("user"); checkConnectionAllowed(originUrl, userName, true); Driver originDriver; try { originDriver = DriverManager.getDriver(originUrl); } catch (SQLException e) { try { reloadServiceProviders(); originDriver = DriverManager.getDriver(originUrl); } catch (Exception e2) { throw e; } } if (!SniffyConfiguration.INSTANCE.isMonitorJdbc()) return originDriver.connect(originUrl, info); long start = System.currentTimeMillis(); try { Sniffy.enterJdbcMethod(); Connection delegateConnection = originDriver.connect(originUrl, info); return Connection.class.cast(Proxy.newProxyInstance( SniffyDriver.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionInvocationHandler(delegateConnection, originUrl, userName) )); } finally { Sniffy.exitJdbcMethod(CONNECT_METHOD, System.currentTimeMillis() - start, CONNECT_METHOD_IMPL); } }