1 /***
2 * @(#)JotmTransactionServiceImpl.java
3 *
4 * JFoxSOAF, Service-Oriented Application Framework
5 *
6 * Copyright(c) JFoxSOAF Team
7 *
8 * Licensed under the GNU LGPL, Version 2.1 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.gnu.org/copyleft/lesser.html
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 * For more information, please visit:
21 * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22 * http://www.huihoo.org/jfox/jfoxsoaf
23 */
24
25 package org.huihoo.jfox.soaf.services.transaction;
26
27 import javax.naming.NamingException;
28 import javax.transaction.TransactionManager;
29 import javax.transaction.UserTransaction;
30
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33 import org.objectweb.jotm.Jotm;
34 import org.objectweb.transaction.jta.TMService;
35 import org.picocontainer.Startable;
36
37 /***
38 * <p>
39 * JOTM transaction service implementation.
40 * </p>
41 *
42 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
43 * @version $Revision: 1.1 $ $Date: 2006/02/15 08:45:46 $
44 * @version Revision: 1.0
45 */
46
47 public class JotmTransactionServiceImpl implements JotmTransactionService,
48 Startable {
49
50 private TMService jotm;
51
52 private final Log logger = LogFactory.getLog(getClass());
53
54 /***
55 * @see org.huihoo.jfox.soaf.services.transaction.JotmTransactionService#getTransactionManager()
56 */
57 public TransactionManager getTransactionManager() {
58 return jotm.getTransactionManager();
59 }
60
61 /***
62 * @see org.huihoo.jfox.soaf.services.transaction.JotmTransactionService#getUserTransaction()
63 */
64 public UserTransaction getUserTransaction() {
65 return jotm.getUserTransaction();
66 }
67
68 /***
69 * Start jotm transaction service.
70 *
71 * @see org.picocontainer.Startable#start()
72 */
73 public void start() {
74 try {
75 jotm = new Jotm(true, false);
76 } catch (NamingException e) {
77 logger.error("Failed to start JOTM transaction service " + e.getMessage());
78 }
79 logger.info("Start JOTM transaction service successful.");
80 }
81
82 /***
83 * Stop jotm transaction service.
84 *
85 * @see org.picocontainer.Startable#stop()
86 */
87 public void stop() {
88 jotm.stop();
89 logger.info("Stop JOTM transaction service successful.");
90 }
91 }