Package bitronix.tm

Examples of bitronix.tm.BitronixTransactionManager


     *
     */
    public static void cleanUp(HashMap<String, Object> context) {
        if (context != null) {
           
            BitronixTransactionManager txm = TransactionManagerServices.getTransactionManager();
            if( txm != null ) {
                txm.shutdown();
            }
           
            Object emfObject = context.remove(ENTITY_MANAGER_FACTORY);
            if (emfObject != null) {
                try {
View Full Code Here


     *
     */
    public static void cleanUp(HashMap<String, Object> context) {
        if (context != null) {
           
            BitronixTransactionManager txm = TransactionManagerServices.getTransactionManager();
            if( txm != null ) {
                txm.shutdown();
            }
           
            Object emfObject = context.remove(ENTITY_MANAGER_FACTORY);
            if (emfObject != null) {
                try {
View Full Code Here

    protected void shutdownEmf() {
        emf.close();
    }

    protected void beginTransaction() throws Exception {
        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        if (tm.getStatus() != Status.STATUS_NO_TRANSACTION) {
            throw new RuntimeException("Active transaction in progress! Please commit or roll it back!");
        }
        tm.begin();
    }
View Full Code Here

        }
        tm.begin();
    }

    protected void commitTransaction() throws Exception {
        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        if (tm.getStatus() != Status.STATUS_ACTIVE) {
            throw new RuntimeException("Transaction is not active and cannot be committed! Please start a new transaction first!");
        }
        tm.commit();
    }
View Full Code Here

        }
        tm.commit();
    }

    protected void rollbackTransaction() throws Exception {
        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        if (tm.getStatus() != Status.STATUS_ACTIVE && tm.getStatus() != Status.STATUS_MARKED_ROLLBACK) {
            throw new RuntimeException("Transaction is not active and cannot be rolled back! Please start a new transaction first!");
        }
        tm.rollback();
    }
View Full Code Here

     *
     */
    public static void cleanUp(HashMap<String, Object> context) {
        if (context != null) {
           
            BitronixTransactionManager txm = TransactionManagerServices.getTransactionManager();
            if( txm != null ) {
                txm.shutdown();
            }
           
            Object emfObject = context.remove(ENTITY_MANAGER_FACTORY);
            if (emfObject != null) {
                try {
View Full Code Here

    private static final int LOOPS = 2;

    public void testSimpleWorkingCase() throws Exception {
        Thread.currentThread().setName("testSimpleWorkingCase");
        if (log.isDebugEnabled()) { log.debug("*** getting TM"); }
        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        if (log.isDebugEnabled()) { log.debug("*** before begin"); }
        tm.setTransactionTimeout(10);
        tm.begin();
        if (log.isDebugEnabled()) { log.debug("*** after begin"); }

        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS1"); }
        Connection connection1 = poolingDataSource1.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 1"); }
        connection1.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 1"); }
        connection1.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS2"); }
        Connection connection2 = poolingDataSource2.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 2"); }
        connection2.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 2"); }
        connection2.createStatement();

        if (log.isDebugEnabled()) { log.debug("*** closing connection 1"); }
        connection1.close();
        if (log.isDebugEnabled()) { log.debug("*** closing connection 2"); }
        connection2.close();

        if (log.isDebugEnabled()) { log.debug("*** committing"); }
        tm.commit();
        if (log.isDebugEnabled()) { log.debug("*** TX is done"); }

        // check flow
        List orderedEvents = EventRecorder.getOrderedEvents();
        log.info(EventRecorder.dumpToString());
View Full Code Here

        Thread.currentThread().setName("testOrderedCommitResources");
        poolingDataSource1.setTwoPcOrderingPosition(200);
        poolingDataSource2.setTwoPcOrderingPosition(-1);

        if (log.isDebugEnabled()) { log.debug("*** getting TM"); }
        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        if (log.isDebugEnabled()) { log.debug("*** before begin"); }
        tm.setTransactionTimeout(10);
        tm.begin();
        if (log.isDebugEnabled()) { log.debug("*** after begin"); }

        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS1"); }
        Connection connection1 = poolingDataSource1.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 1"); }
        connection1.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 1"); }
        connection1.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS2"); }
        Connection connection2 = poolingDataSource2.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 2"); }
        connection2.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 2"); }
        connection2.createStatement();

        if (log.isDebugEnabled()) { log.debug("*** closing connection 1"); }
        connection1.close();
        if (log.isDebugEnabled()) { log.debug("*** closing connection 2"); }
        connection2.close();

        if (log.isDebugEnabled()) { log.debug("*** committing"); }
        tm.commit();
        if (log.isDebugEnabled()) { log.debug("*** TX is done"); }

        // check flow
        List orderedEvents = EventRecorder.getOrderedEvents();
        log.info(EventRecorder.dumpToString());
View Full Code Here

        poolingDataSource1.setTwoPcOrderingPosition(1);
        poolingDataSource2.setTwoPcOrderingPosition(1);

        if (log.isDebugEnabled()) { log.debug("*** getting TM"); }
        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        if (log.isDebugEnabled()) { log.debug("*** before begin"); }
        tm.setTransactionTimeout(10);
        tm.begin();
        if (log.isDebugEnabled()) { log.debug("*** after begin"); }

        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS1"); }
        Connection connection1 = poolingDataSource1.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 1"); }
        connection1.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 1"); }
        connection1.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS2"); }
        Connection connection2 = poolingDataSource2.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 2"); }
        connection2.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 2"); }
        connection2.createStatement();

        if (log.isDebugEnabled()) { log.debug("*** closing connection 1"); }
        connection1.close();
        if (log.isDebugEnabled()) { log.debug("*** closing connection 2"); }
        connection2.close();

        if (log.isDebugEnabled()) { log.debug("*** committing"); }
        tm.commit();
        if (log.isDebugEnabled()) { log.debug("*** TX is done"); }

        // check flow
        List orderedEvents = EventRecorder.getOrderedEvents();
        log.info(EventRecorder.dumpToString());
View Full Code Here

        poolingDataSource2.getDriverProperties().setProperty("password", "password");
        poolingDataSource2.init();


        if (log.isDebugEnabled()) { log.debug("*** getting TM"); }
        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        if (log.isDebugEnabled()) { log.debug("*** before begin"); }
        tm.setTransactionTimeout(10);
        tm.begin();
        if (log.isDebugEnabled()) { log.debug("*** after begin"); }

        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS2"); }
        Connection connection2 = poolingDataSource2.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 2"); }
        connection2.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 2"); }
        connection2.createStatement();

        if (log.isDebugEnabled()) { log.debug("*** getting connection from DS1"); }
        Connection connection1 = poolingDataSource1.getConnection();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 1 on connection 1"); }
        connection1.createStatement();
        if (log.isDebugEnabled()) { log.debug("*** creating statement 2 on connection 1"); }
        connection1.createStatement();

        if (log.isDebugEnabled()) { log.debug("*** closing connection 2"); }
        connection2.close();

        if (log.isDebugEnabled()) { log.debug("*** closing connection 1"); }
        connection1.close();

        if (log.isDebugEnabled()) { log.debug("*** committing"); }
        tm.commit();
        if (log.isDebugEnabled()) { log.debug("*** TX is done"); }

        // check flow
        List orderedEvents = EventRecorder.getOrderedEvents();
        log.info(EventRecorder.dumpToString());
View Full Code Here

TOP

Related Classes of bitronix.tm.BitronixTransactionManager

Copyright © 2018 www.massapicom. 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.