KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > extras > jotm > JotmTransactionManagerFactory


1 /*
2  * $Id: JotmTransactionManagerFactory.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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 import org.objectweb.jotm.Current;
15 import org.objectweb.jotm.Jotm;
16
17 import javax.transaction.TransactionManager JavaDoc;
18
19 /**
20  * This factory retrieves the transaction manager for <a
21  * HREF="http://jotm.objectweb.org">JOTM </a>. If an existing JOTM instance exists
22  * (for example if running on JOnAS) it will retrieve it, else if will create a new
23  * local JOTM instance.
24  *
25  * @author Guillaume Nodet
26  * @version $Revision: 3798 $
27  */

28 public class JotmTransactionManagerFactory implements UMOTransactionManagerFactory
29 {
30     private TransactionManager JavaDoc jotmCurrent;
31
32     public JotmTransactionManagerFactory()
33     {
34         super();
35     }
36
37     /**
38      * Retrieves the JOTM Current object that implements the TransactionManager
39      * interface.
40      *
41      * @see org.mule.umo.manager.UMOTransactionManagerFactory#create()
42      */

43     public synchronized TransactionManager JavaDoc create() throws Exception JavaDoc
44     {
45         if (jotmCurrent == null)
46         {
47             // check for already active JOTM instance
48
jotmCurrent = Current.getCurrent();
49             // if none found, create new local JOTM instance
50
if (jotmCurrent == null)
51             {
52                 jotmCurrent = new Jotm(true, false).getTransactionManager();
53             }
54         }
55         return jotmCurrent;
56     }
57
58 }
59
Popular Tags