Package org.mule.api.transaction

Examples of org.mule.api.transaction.Transaction


    public void bindsConnectionToActiveTransaction() throws Exception
    {
        Connection expectedConnection = mock(Connection.class);
        when(connectionFactory.create(datasource)).thenReturn(expectedConnection);

        Transaction transaction = mock(Transaction.class);
        when(transaction.hasResource(datasource)).thenReturn(false);

        when(dbTransactionManager.getTransaction()).thenReturn(transaction);

        factory = new TransactionalDbConnectionFactory(dbTransactionManager, null, connectionFactory, datasource);
View Full Code Here


    }

    @Test
    public void keepsTransactedConnectionOpenWhenJoinIfPossibleAndActiveTransaction() throws Exception
    {
        Transaction transaction = mock(Transaction.class);
        when(dbTransactionManager.getTransaction()).thenReturn(transaction);
        DbConnection connection = mock(DbConnection.class);
        when(connection.getTransactionalAction()).thenReturn(TransactionalAction.JOIN_IF_POSSIBLE);

        factory = new TransactionalDbConnectionFactory(dbTransactionManager, null, null, null);
View Full Code Here

    }

    @Test
    public void keepsTransactedConnectionOpenWhenAlwaysJoin() throws Exception
    {
        Transaction transaction = mock(Transaction.class);
        when(dbTransactionManager.getTransaction()).thenReturn(transaction);
        DbConnection connection = mock(DbConnection.class);
        when(connection.getTransactionalAction()).thenReturn(TransactionalAction.ALWAYS_JOIN);

        factory = new TransactionalDbConnectionFactory(dbTransactionManager, null, null, null);
View Full Code Here

    private CatchMessagingExceptionStrategy catchMessagingExceptionStrategy;

    @Before
    public void before() throws Exception
    {
        Transaction currentTransaction = TransactionCoordination.getInstance().getTransaction();
        if (currentTransaction != null)
        {
            TransactionCoordination.getInstance().unbindTransaction(currentTransaction);
        }
        catchMessagingExceptionStrategy = new CatchMessagingExceptionStrategy();
View Full Code Here

        if (ConnectionFactoryWrapper.logger.isDebugEnabled())
        {
            ConnectionFactoryWrapper.logger.debug("Invoking " + method);
        }
       
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
       
        if (method.getName().equals("createSession"))
        {
            if (tx != null)
            {
View Full Code Here

        if (logger.isDebugEnabled())
        {
            logger.debug("Enlistment request: " + this);
        }

        Transaction transaction = TransactionCoordination.getInstance().getTransaction();
        if (transaction == null)
        {
            throw new IllegalTransactionStateException(CoreMessages.noMuleTransactionAvailable());
        }
        if (!(transaction instanceof XaTransaction))
View Full Code Here

        if (logger.isDebugEnabled())
        {
            logger.debug("Delistment request: " + this);
        }

        Transaction transaction = TransactionCoordination.getInstance().getTransaction();
        if (transaction == null)
        {
            throw new IllegalTransactionStateException(CoreMessages.noMuleTransactionAvailable());
        }
        if (!(transaction instanceof XaTransaction))
View Full Code Here

    @Override
    public T execute(ExecutionCallback<T> callback) throws Exception
    {
        byte action = transactionConfig.getAction();
        boolean resolveStartedTransaction = false;
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        if (action == TransactionConfig.ACTION_ALWAYS_BEGIN
                || (action == TransactionConfig.ACTION_BEGIN_OR_JOIN && tx == null))
        {
            logger.debug("Beginning transaction");
            tx = transactionConfig.getFactory().beginTransaction(muleContext);
View Full Code Here

        }
    }

    private void resolveTransactionIfRequired(boolean mustResolveTransaction) throws TransactionException
    {
        Transaction transaction = TransactionCoordination.getInstance().getTransaction();
        if (mustResolveTransaction && transaction != null)
        {
            TransactionCoordination.getInstance().resolveTransaction();
        }
    }
View Full Code Here

     * @deprecated use {@link #rollback(Exception)} instead
     */
    @Deprecated
    protected void rollback(RollbackSourceCallback rollbackMethod)
    {
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        if (tx != null)
        {
            try
            {
                tx.rollback();

                // TODO The following was in the catch clause of TransactionTemplate previously.
                // Do we need to do this here?  If so, where can we store these variables (suspendedXATx, joinedExternal)
                // so that they are available to us in the exception handler?
                //
View Full Code Here

TOP

Related Classes of org.mule.api.transaction.Transaction

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.