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