public static JdbcEventListener getJdbcEventListener() { return JdbcEventListenerFactoryLoader.load().createJdbcEventListener(); }
@SuppressWarnings("resource") public static Connection wrapConnection(Connection realConnection, ConnectionInformation connectionInformation) { if (realConnection == null) { return null; } return ConnectionWrapper.wrap(realConnection, JdbcEventListenerFactoryLoader.load().createJdbcEventListener(), connectionInformation); }
@Override public XAConnection getXAConnection() throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(XADataSource.class).getXAConnection(), this.jdbcEventListenerFactory); }
@Override public PooledConnection getPooledConnection(String user, String password) throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(ConnectionPoolDataSource.class).getPooledConnection(user, password), this.jdbcEventListenerFactory); }
@Override public PooledConnection getPooledConnection() throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(ConnectionPoolDataSource.class).getPooledConnection(), this.jdbcEventListenerFactory); }
@Override public XAConnection getXAConnection(String user, String password) throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(XADataSource.class).getXAConnection(user, password), this.jdbcEventListenerFactory); }
@Test public void testLoadViaServiceLoader() { assertThat(JdbcEventListenerFactoryLoader.load(), instanceOf(TestJdbcEventListenerFactory.class)); }
this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load();
@Override public Connection getConnection(String username, String password) throws SQLException { if (realDataSource == null) { bindDataSource(); } final long start = System.nanoTime(); if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } final Connection conn; final JdbcEventListener jdbcEventListener = this.jdbcEventListenerFactory.createJdbcEventListener(); final ConnectionInformation connectionInformation = ConnectionInformation.fromDataSource(realDataSource); jdbcEventListener.onBeforeGetConnection(connectionInformation); try { conn = ((DataSource) realDataSource).getConnection(username, password); connectionInformation.setConnection(conn); connectionInformation.setTimeToGetConnectionNs(System.nanoTime() - start); jdbcEventListener.onAfterGetConnection(connectionInformation, null); } catch (SQLException e) { connectionInformation.setTimeToGetConnectionNs(System.nanoTime() - start); jdbcEventListener.onAfterGetConnection(connectionInformation, e); throw e; } return ConnectionWrapper.wrap(conn, jdbcEventListener, connectionInformation); }
P6SpyDriver.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load();
public static JdbcEventListener getJdbcEventListener() { return JdbcEventListenerFactoryLoader.load().createJdbcEventListener(); }
@SuppressWarnings("resource") public static Connection wrapConnection(Connection realConnection, ConnectionInformation connectionInformation) { if (realConnection == null) { return null; } return ConnectionWrapper.wrap(realConnection, JdbcEventListenerFactoryLoader.load().createJdbcEventListener(), connectionInformation); }
@Override public PooledConnection getPooledConnection() throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(ConnectionPoolDataSource.class).getPooledConnection(), this.jdbcEventListenerFactory); }
@Override public XAConnection getXAConnection(String user, String password) throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(XADataSource.class).getXAConnection(user, password), this.jdbcEventListenerFactory); }
@Override public PooledConnection getPooledConnection(String user, String password) throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(ConnectionPoolDataSource.class).getPooledConnection(user, password), this.jdbcEventListenerFactory); }
@Override public XAConnection getXAConnection() throws SQLException { if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } return new P6XAConnection(castRealDS(XADataSource.class).getXAConnection(), this.jdbcEventListenerFactory); }
this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load();
@Override public Connection getConnection(String username, String password) throws SQLException { if (realDataSource == null) { bindDataSource(); } final long start = System.nanoTime(); if (this.jdbcEventListenerFactory == null) { this.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load(); } final Connection conn; final JdbcEventListener jdbcEventListener = this.jdbcEventListenerFactory.createJdbcEventListener(); final ConnectionInformation connectionInformation = ConnectionInformation.fromDataSource(realDataSource); jdbcEventListener.onBeforeGetConnection(connectionInformation); try { conn = ((DataSource) realDataSource).getConnection(username, password); connectionInformation.setConnection(conn); connectionInformation.setTimeToGetConnectionNs(System.nanoTime() - start); jdbcEventListener.onAfterGetConnection(connectionInformation, null); } catch (SQLException e) { connectionInformation.setTimeToGetConnectionNs(System.nanoTime() - start); jdbcEventListener.onAfterGetConnection(connectionInformation, e); throw e; } return ConnectionWrapper.wrap(conn, jdbcEventListener, connectionInformation); }
P6SpyDriver.jdbcEventListenerFactory = JdbcEventListenerFactoryLoader.load();