View Javadoc

1   /*
2    * $Id: XaTransactionFactory.java 10489 2008-01-23 17:53:38Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.Transaction;
15  import org.mule.api.transaction.TransactionException;
16  import org.mule.api.transaction.TransactionFactory;
17  import org.mule.config.i18n.CoreMessages;
18  
19  /**
20   * <code>XaTransactionFactory</code> Is used to create/retrieve a Transaction from
21   * a transaction manager configured on the MuleManager.
22   */
23  public class XaTransactionFactory implements TransactionFactory
24  {
25      public Transaction beginTransaction(MuleContext muleContext) throws TransactionException
26      {
27          try
28          {
29              XaTransaction xat = new XaTransaction(muleContext.getTransactionManager());
30              xat.begin();
31              return xat;
32          }
33          catch (Exception e)
34          {
35              throw new TransactionException(CoreMessages.cannotStartTransaction("XA"), e);
36          }
37      }
38  
39      /**
40       * Determines whether this transaction factory creates transactions that are
41       * really transacted or if they are being used to simulate batch actions, such as
42       * using Jms Client Acknowledge.
43       * 
44       * @return
45       */
46      public boolean isTransacted()
47      {
48          return true;
49      }
50  }