01: /*
02: * $Id: XaTransactionFactory.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: public Transaction beginTransaction(MuleContext muleContext)
25: throws TransactionException {
26: try {
27: XaTransaction xat = new XaTransaction(muleContext
28: .getTransactionManager());
29: xat.begin();
30: return xat;
31: } catch (Exception e) {
32: throw new TransactionException(CoreMessages
33: .cannotStartTransaction("XA"), e);
34: }
35: }
36:
37: /**
38: * Determines whether this transaction factory creates transactions that are
39: * really transacted or if they are being used to simulate batch actions, such as
40: * using Jms Client Acknowledge.
41: *
42: * @return
43: */
44: public boolean isTransacted() {
45: return true;
46: }
47: }
|