1 /* 2 * $Id: JotmTransactionManagerFactory.java 7976 2007-08-21 14:26:13Z dirk.olmes $ 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.extras.jotm; 12 13 import org.mule.umo.manager.UMOTransactionManagerFactory; 14 15 import javax.transaction.TransactionManager; 16 17 import org.objectweb.jotm.Current; 18 import org.objectweb.jotm.Jotm; 19 20 /** 21 * This factory retrieves the transaction manager for <a 22 * href="http://jotm.objectweb.org">JOTM </a>. If an existing JOTM instance exists 23 * (for example if running on JOnAS) it will retrieve it, else if will create a new 24 * local JOTM instance. 25 * 26 * @author Guillaume Nodet 27 * @version $Revision: 7976 $ 28 */ 29 public class JotmTransactionManagerFactory implements UMOTransactionManagerFactory 30 { 31 private TransactionManager jotmCurrent; 32 33 public JotmTransactionManagerFactory() 34 { 35 super(); 36 } 37 38 /** 39 * Retrieves the JOTM Current object that implements the TransactionManager 40 * interface. 41 * 42 * @see org.mule.umo.manager.UMOTransactionManagerFactory#create() 43 */ 44 public synchronized TransactionManager create() throws Exception 45 { 46 if (jotmCurrent == null) 47 { 48 // check for already active JOTM instance 49 jotmCurrent = Current.getCurrent(); 50 // if none found, create new local JOTM instance 51 if (jotmCurrent == null) 52 { 53 jotmCurrent = new Jotm(true, false).getTransactionManager(); 54 } 55 } 56 return jotmCurrent; 57 } 58 59 }