Examples of TransactionContext


Examples of org.apache.geronimo.transaction.TransactionContext

        this.next = next;
        this.connectionTracker = connectionTracker;
    }

    public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
        TransactionContext transactionContext = TransactionContext.getContext();
        ManagedConnectionInfo managedConnectionInfo = (ManagedConnectionInfo)transactionContext.getManagedConnectionInfo(this);
        if (managedConnectionInfo != null) {
            connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
            return;
        } else {
            next.getConnection(connectionInfo);
            transactionContext.setManagedConnectionInfo(this, connectionInfo.getManagedConnectionInfo());
        }
    }
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        this.newTxIndex = newTxIndex;
        this.transactionContextManager = transactionContextManager;
    }

    public void before(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse) {
        TransactionContext oldTransactionContext = transactionContextManager.getContext();
        TransactionContext newTransactionContext = null;
        if (oldTransactionContext == null || !oldTransactionContext.isInheritable()) {
            newTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();
        }
        context[oldTxIndex] = oldTransactionContext;
        context[newTxIndex] = newTransactionContext;
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        try {
            if (next != null) {
                next.after(context, httpRequest, httpResponse);
            }
        } finally {
            TransactionContext oldTransactionContext = (TransactionContext) context[oldTxIndex];
            TransactionContext newTransactionContext = (TransactionContext) context[newTxIndex];
            try {
                if (newTransactionContext != null) {
                    if (newTransactionContext != transactionContextManager.getContext()) {
                        transactionContextManager.getContext().rollback();
                        newTransactionContext.rollback();
                        throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
                    }
                    newTransactionContext.commit();

                } else {
                    if (oldTransactionContext != transactionContextManager.getContext()) {
                        if (transactionContextManager.getContext() != null) {
                            transactionContextManager.getContext().rollback();
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        if (connectionReturnAction == ConnectionReturnAction.DESTROY) {
            next.returnConnection(connectionInfo, connectionReturnAction);
            return;
        }

        TransactionContext transactionContext = transactionContextManager.getContext();
        if (transactionContext != null && transactionContext.isInheritable() && transactionContext.isActive()) {
            return;
        }
        internalReturn(connectionInfo, connectionReturnAction);
    }
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

    }

    public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
        //There can be an inactive transaction context when a connection is requested in
        //Synchronization.afterCompletion().
        TransactionContext transactionContext = transactionContextManager.getContext();
        if (transactionContext != null && transactionContext.isInheritable() && transactionContext.isActive()) {
            ManagedConnectionInfos managedConnectionInfos = (ManagedConnectionInfos) transactionContext.getManagedConnectionInfo(this);
            if (managedConnectionInfos == null) {
                managedConnectionInfos = new ManagedConnectionInfos();
                transactionContext.setManagedConnectionInfo(this, managedConnectionInfos);
            }
            if (connectionInfo.isUnshareable()) {
                if (!managedConnectionInfos.containsUnshared(connectionInfo.getManagedConnectionInfo())) {
                    next.getConnection(connectionInfo);
                    managedConnectionInfos.addUnshared(connectionInfo.getManagedConnectionInfo());
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

            transactionContextManager.setContext(null);
        }
    }

    public void testTasksInTransaction() throws Exception {
        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
        for (long i = 0; i < COUNT; i++) {
            timer.schedule(userTaskFactory, key, userId, userKey, i);
        }
        Thread.sleep(COUNT + SLOP);
        assertEquals(0, counter.get());
        transactionContext.commit();
        Thread.sleep(COUNT + SLOP);
        assertEquals(COUNT, counter.get());
    }
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        for (long i = 0; i < COUNT; i++) {
            workInfos[(int) i] = timer.scheduleAtFixedRate(key, userTaskFactory, userId, userKey, DELAY, DELAY);
        }
        Thread.sleep(SLOP + DELAY);
        assertEquals(COUNT, counter.get());
        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
        for (int i = 0; i < workInfos.length; i++) {
            workInfos[i].getExecutorFeedingTimerTask().cancel();
        }
        Thread.sleep(SLOP + DELAY);
        assertEquals(COUNT, counter.get());
        transactionContext.commit();
        Thread.sleep(SLOP + DELAY);
        assertEquals(COUNT, counter.get());
    }
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        for (long i = 0; i < COUNT; i++) {
            workInfos[(int) i] = timer.scheduleAtFixedRate(key, userTaskFactory, userId, userKey, DELAY, DELAY);
        }
        Thread.sleep(SLOP + DELAY);
        assertEquals(COUNT, counter.get());
        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
        for (int i = 0; i < workInfos.length; i++) {
            workInfos[i].getExecutorFeedingTimerTask().cancel();
        }
        Thread.sleep(SLOP + DELAY);
        assertEquals(COUNT, counter.get());
        transactionContext.rollback();
        Thread.sleep(SLOP + DELAY);
        // Catches up with two periods.
        assertEquals(3 * COUNT, counter.get());
    }
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        this.newTxIndex = newTxIndex;
        this.transactionContextManager = transactionContextManager;
    }

    public void before(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse) {
        TransactionContext oldTransactionContext = transactionContextManager.getContext();
        TransactionContext newTransactionContext = null;
        if (oldTransactionContext == null || !oldTransactionContext.isInheritable()) {
            newTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();
        }
        context[oldTxIndex] = oldTransactionContext;
        context[newTxIndex] = newTransactionContext;
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        try {
            if (next != null) {
                next.after(context, httpRequest, httpResponse);
            }
        } finally {
            TransactionContext oldTransactionContext = (TransactionContext) context[oldTxIndex];
            TransactionContext newTransactionContext = (TransactionContext) context[newTxIndex];
            try {
                if (newTransactionContext != null) {
                    if (newTransactionContext != transactionContextManager.getContext()) {
                        transactionContextManager.getContext().rollback();
                        newTransactionContext.rollback();
                        throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
                    }
                    newTransactionContext.commit();

                } else {
                    if (oldTransactionContext != transactionContextManager.getContext()) {
                        if (transactionContextManager.getContext() != null) {
                            transactionContextManager.getContext().rollback();
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.