Examples of DelegatingConnection


Examples of org.apache.commons.dbcp.DelegatingConnection

    Connection con = new TestConnectionImpl();

    // use a wrapper from DBCP to create a proxy of a proxy
    // Note: DBCP implements with JDBC 4.0 API so the Wrapper interface
    // is implemented here.
    DelegatingConnection underlying = new DelegatingConnection(con);

    Connection proxy = ProxyFactory.createProxy(underlying, new GenericInvocationHandler<Connection>(underlying));

    // TestConnection is an interface of the actual connection but not of the proxy.  Unwrapping works
    // but a proxy is not returned
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

    Connection con = new TestConnectionImpl();

    // use a wrapper from DBCP to create a proxy of a proxy
    // Note: DBCP implements with JDBC 4.0 API so the Wrapper interface
    // is implemented here.
    DelegatingConnection underlying = new DelegatingConnection(con);

    Connection proxy = ProxyFactory.createProxy(underlying, new GenericInvocationHandler<Connection>(underlying));

    // TestConnection is an interface of the wrapped underlying object.
    assertTrue(proxy.isWrapperFor(TestConnection.class));
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

    PooledConnectionImpl(Connection connection, KeyedObjectPool pool) {
        this.connection = connection;
        if (connection instanceof DelegatingConnection) {
            this.delegatingConnection = (DelegatingConnection) connection;
        } else {
            this.delegatingConnection = new DelegatingConnection(connection);
        }
        eventListeners = new Vector();
        isClosed = false;
        if (pool != null) {
            pstmtPool = pool;
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

    PooledConnectionImpl(Connection connection, KeyedObjectPool pool) {
        this.connection = connection;
        if (connection instanceof DelegatingConnection) {
            this.delegatingConnection = (DelegatingConnection) connection;
        } else {
            this.delegatingConnection = new DelegatingConnection(connection);  
        }
        eventListeners = new Vector();
        isClosed = false;
        if (pool != null) {
            pstmtPool = pool;
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

    PooledConnectionImpl(Connection connection, KeyedObjectPool pool) {
        this.connection = connection;
        if (connection instanceof DelegatingConnection) {
            this.delegatingConnection = (DelegatingConnection) connection;
        } else {
            this.delegatingConnection = new DelegatingConnection(connection);
        }
        eventListeners = new Vector();
        isClosed = false;
        if (pool != null) {
            pstmtPool = pool;
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

    PooledConnectionImpl(Connection connection, KeyedObjectPool pool) {
        this.connection = connection;
        if (connection instanceof DelegatingConnection) {
            this.delegatingConnection = (DelegatingConnection) connection;
        } else {
            this.delegatingConnection = new DelegatingConnection(connection);  
        }
        eventListeners = new Vector();
        isClosed = false;
        if (pool != null) {
            pstmtPool = pool;
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

        connection.close();
        sharedConnection.close();
    }

    public void testSharedConnection() throws Exception {
        DelegatingConnection connectionA = (DelegatingConnection) newConnection();
        DelegatingConnection connectionB = (DelegatingConnection) newConnection();

        assertTrue(connectionA.equals(connectionB));
        assertTrue(connectionB.equals(connectionA));
        assertTrue(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
        assertTrue(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));

        connectionA.close();
        connectionB.close();
    }
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

        connectionA.close();
        connectionB.close();
    }

    public void testSharedTransactionConversion() throws Exception {
        DelegatingConnection connectionA = (DelegatingConnection) newConnection();
        DelegatingConnection connectionB = (DelegatingConnection) newConnection();

        // in a transaciton the connections should be equal
        assertTrue(connectionA.equals(connectionB));
        assertTrue(connectionB.equals(connectionA));
        assertTrue(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
        assertTrue(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));

        transactionManager.commit();

        // use the connection so it adjusts to the completed transaction
        connectionA.getAutoCommit();
        connectionB.getAutoCommit();

        // no there is no transaction so connections should not be equal
        assertFalse(connectionA.equals(connectionB));
        assertFalse(connectionB.equals(connectionA));
        assertFalse(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
        assertFalse(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));

        transactionManager.begin();

        // use the connection so it adjusts to the new transaction
        connectionA.getAutoCommit();
        connectionB.getAutoCommit();

        // back in a transaction so should be equal again
        assertTrue(connectionA.equals(connectionB));
        assertTrue(connectionB.equals(connectionA));
        assertTrue(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
        assertTrue(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));

        connectionA.close();
        connectionB.close();
    }
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

        connectionA.close();
        connectionB.close();
    }

    public void testCloseInTransaction() throws Exception {
        DelegatingConnection connectionA = (DelegatingConnection) newConnection();
        DelegatingConnection connectionB = (DelegatingConnection) newConnection();

        assertTrue(connectionA.equals(connectionB));
        assertTrue(connectionB.equals(connectionA));
        assertTrue(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
        assertTrue(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));

        connectionA.close();
        connectionB.close();

        Connection connection = newConnection();

        // conection should be open
        assertFalse("Connection should be open", connection.isClosed());
View Full Code Here

Examples of org.apache.commons.dbcp.DelegatingConnection

    /**
     * Verify that conection sharing is working (or not working) as expected.
     */
    public void testSharedConnection() throws Exception {
        DelegatingConnection connectionA = (DelegatingConnection) newConnection();
        DelegatingConnection connectionB = (DelegatingConnection) newConnection();

        assertFalse(connectionA.equals(connectionB));
        assertFalse(connectionB.equals(connectionA));
        assertFalse(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
        assertFalse(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));

        connectionA.close();
        connectionB.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.