Coverage Report - org.mule.transaction.XaTransactionFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
XaTransactionFactory
0%
0/15
0%
0/2
3.667
 
 1  
 /*
 2  
  * $Id: XaTransactionFactory.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.transaction;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.transaction.ExternalTransactionAwareTransactionFactory;
 15  
 import org.mule.api.transaction.Transaction;
 16  
 import org.mule.api.transaction.TransactionException;
 17  
 import org.mule.config.i18n.CoreMessages;
 18  
 
 19  
 import javax.transaction.TransactionManager;
 20  
 
 21  
 /**
 22  
  * <code>XaTransactionFactory</code> Is used to create/retrieve a Transaction from
 23  
  * a transaction manager configured on the MuleManager.
 24  
  */
 25  0
 public class XaTransactionFactory implements ExternalTransactionAwareTransactionFactory
 26  
 {
 27  
     public Transaction beginTransaction(MuleContext muleContext) throws TransactionException
 28  
     {
 29  
         try
 30  
         {
 31  0
             XaTransaction xat = new XaTransaction(muleContext);
 32  0
             xat.begin();
 33  0
             return xat;
 34  
         }
 35  0
         catch (Exception e)
 36  
         {
 37  0
             throw new TransactionException(CoreMessages.cannotStartTransaction("XA"), e);
 38  
         }
 39  
     }
 40  
 
 41  
     /**
 42  
      * Create a Mule transaction that represents a transaction started outside of Mule
 43  
      */
 44  
     public Transaction joinExternalTransaction(MuleContext muleContext) throws TransactionException
 45  
     {
 46  
         try
 47  
         {
 48  0
             TransactionManager txManager = muleContext.getTransactionManager();
 49  0
             if (txManager.getTransaction() == null)
 50  
             {
 51  0
                 return null;
 52  
             }
 53  0
             XaTransaction xat = new ExternalXaTransaction(muleContext);
 54  0
             xat.begin();
 55  0
             return xat;
 56  
         }
 57  0
         catch (Exception e)
 58  
         {
 59  0
             throw new TransactionException(CoreMessages.cannotStartTransaction("XA"), e);
 60  
         }
 61  
     }
 62  
 
 63  
     /**
 64  
      * Determines whether this transaction factory creates transactions that are
 65  
      * really transacted or if they are being used to simulate batch actions, such as
 66  
      * using Jms Client Acknowledge.
 67  
      */
 68  
     public boolean isTransacted()
 69  
     {
 70  0
         return true;
 71  
     }
 72  
 }