@Test public void testRewrapConnection() throws SQLException, IllegalAccessException { DriverManager.registerDriver(driver); final Connection connection = DriverManager.getConnection(H2_DATABASE_URL); jdbcWrapper.rewrapConnection(connection); connection.close(); }
void rewrapConnection(Connection connection) throws IllegalAccessException { assert connection != null; if (jboss && connection.getClass().getSimpleName().startsWith("WrappedConnection")) { final Object baseWrapperManagedConnection = JdbcWrapperHelper.getFieldValue(connection, "mc"); final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper .getFieldValue(baseWrapperManagedConnection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(baseWrapperManagedConnection, conFieldName, con); } } else if (glassfish && ("com.sun.gjc.spi.jdbc40.ConnectionHolder40" .equals(connection.getClass().getName()) || "com.sun.gjc.spi.jdbc40.ConnectionWrapper40" .equals(connection.getClass().getName()))) { final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper.getFieldValue(connection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(connection, conFieldName, con); } } }
JdbcWrapper { void rewrapConnection(Connection connection) throws IllegalAccessException { assert connection != null; if (jboss && connection.getClass().getSimpleName().startsWith("WrappedConnection")) { final Object baseWrapperManagedConnection = JdbcWrapperHelper.getFieldValue(connection, "mc"); final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper .getFieldValue(baseWrapperManagedConnection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(baseWrapperManagedConnection, conFieldName, con); } } else if (glassfish && ("com.sun.gjc.spi.jdbc40.ConnectionHolder40" .equals(connection.getClass().getName()) || "com.sun.gjc.spi.jdbc40.ConnectionWrapper40" .equals(connection.getClass().getName()))) { final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper.getFieldValue(connection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(connection, conFieldName, con); } } } }
JdbcWrapper { void rewrapConnection(Connection connection) throws IllegalAccessException { assert connection != null; if (jboss && connection.getClass().getSimpleName().startsWith("WrappedConnection")) { final Object baseWrapperManagedConnection = JdbcWrapperHelper.getFieldValue(connection, "mc"); final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper .getFieldValue(baseWrapperManagedConnection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(baseWrapperManagedConnection, conFieldName, con); } } else if (glassfish && ("com.sun.gjc.spi.jdbc40.ConnectionHolder40" .equals(connection.getClass().getName()) || "com.sun.gjc.spi.jdbc40.ConnectionWrapper40" .equals(connection.getClass().getName()))) { final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper.getFieldValue(connection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(connection, conFieldName, con); } } } private  JdbcWrapper(Counter sqlCounter); }
JdbcWrapper { void rewrapConnection(Connection connection) throws IllegalAccessException { assert connection != null; if (jboss && connection.getClass().getSimpleName().startsWith("WrappedConnection")) { final Object baseWrapperManagedConnection = JdbcWrapperHelper.getFieldValue(connection, "mc"); final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper .getFieldValue(baseWrapperManagedConnection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(baseWrapperManagedConnection, conFieldName, con); } } else if (glassfish && ("com.sun.gjc.spi.jdbc40.ConnectionHolder40" .equals(connection.getClass().getName()) || "com.sun.gjc.spi.jdbc40.ConnectionWrapper40" .equals(connection.getClass().getName()))) { final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper.getFieldValue(connection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(connection, conFieldName, con); } } } private  JdbcWrapper(Counter sqlCounter); static int getUsedConnectionCount(); static int getActiveConnectionCount(); static long getTransactionCount(); static int getActiveThreadCount(); static int getRunningBuildCount(); static int getBuildQueueLength(); static long getBuildQueueWaitingDurationsSum(); static List<ConnectionInformations> getConnectionInformationsList(); Counter getSqlCounter(); static int getMaxConnectionCount(); static Map<String, Map<String, Object>> getBasicDataSourceProperties(); static Map<String, DataSource> getJndiAndSpringDataSources(); static void registerSpringDataSource(String name, DataSource dataSource); DataSource createDataSourceProxy(DataSource dataSource); DataSource createDataSourceProxy(String name, final DataSource dataSource); Connection createConnectionProxy(Connection connection); }
JdbcWrapper { void rewrapConnection(Connection connection) throws IllegalAccessException { assert connection != null; if (jboss && connection.getClass().getSimpleName().startsWith("WrappedConnection")) { final Object baseWrapperManagedConnection = JdbcWrapperHelper.getFieldValue(connection, "mc"); final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper .getFieldValue(baseWrapperManagedConnection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(baseWrapperManagedConnection, conFieldName, con); } } else if (glassfish && ("com.sun.gjc.spi.jdbc40.ConnectionHolder40" .equals(connection.getClass().getName()) || "com.sun.gjc.spi.jdbc40.ConnectionWrapper40" .equals(connection.getClass().getName()))) { final String conFieldName = "con"; Connection con = (Connection) JdbcWrapperHelper.getFieldValue(connection, conFieldName); if (!isProxyAlready(con)) { con = createConnectionProxy(con); JdbcWrapperHelper.setFieldValue(connection, conFieldName, con); } } } private  JdbcWrapper(Counter sqlCounter); static int getUsedConnectionCount(); static int getActiveConnectionCount(); static long getTransactionCount(); static int getActiveThreadCount(); static int getRunningBuildCount(); static int getBuildQueueLength(); static long getBuildQueueWaitingDurationsSum(); static List<ConnectionInformations> getConnectionInformationsList(); Counter getSqlCounter(); static int getMaxConnectionCount(); static Map<String, Map<String, Object>> getBasicDataSourceProperties(); static Map<String, DataSource> getJndiAndSpringDataSources(); static void registerSpringDataSource(String name, DataSource dataSource); DataSource createDataSourceProxy(DataSource dataSource); DataSource createDataSourceProxy(String name, final DataSource dataSource); Connection createConnectionProxy(Connection connection); static final JdbcWrapper SINGLETON; }