KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > transaction > TransactionManagerHelper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.transaction;
24
25 import javax.transaction.*;
26 import com.sun.enterprise.*;
27
28 /**
29 * This class is wrapper for the actual transaction manager implementation.
30 * JNDI lookup name "java:appserver/TransactionManager"
31 * see the com/sun/enterprise/naming/java/javaURLContext.java
32 **/

33
34 public class TransactionManagerHelper implements TransactionManager {
35
36     public void begin() throws NotSupportedException, SystemException {
37     Switch.getSwitch().getTransactionManager().begin();
38     }
39
40     
41     public void commit() throws RollbackException,
42     HeuristicMixedException, HeuristicRollbackException, SecurityException JavaDoc,
43     IllegalStateException JavaDoc, SystemException {
44     Switch.getSwitch().getTransactionManager().commit();
45     }
46
47     public int getStatus() throws SystemException {
48     return Switch.getSwitch().getTransactionManager().getStatus();
49     }
50
51     public Transaction getTransaction() throws SystemException {
52     return Switch.getSwitch().getTransactionManager().getTransaction();
53     }
54
55     
56     public void resume(Transaction tobj)
57             throws InvalidTransactionException, IllegalStateException JavaDoc,
58             SystemException {
59     Switch.getSwitch().getTransactionManager().resume(tobj);
60     }
61
62     
63     public void rollback() throws IllegalStateException JavaDoc, SecurityException JavaDoc,
64                             SystemException {
65     Switch.getSwitch().getTransactionManager().rollback();
66     }
67
68     public void setRollbackOnly() throws IllegalStateException JavaDoc, SystemException {
69     Switch.getSwitch().getTransactionManager().setRollbackOnly();
70     }
71
72     public void setTransactionTimeout(int seconds) throws SystemException {
73     Switch.getSwitch().getTransactionManager().setTransactionTimeout(seconds);
74     }
75
76     public Transaction suspend() throws SystemException {
77     return Switch.getSwitch().getTransactionManager().suspend();
78     }
79
80     public static TransactionManager getTransactionManager() {
81     return tmHelper;
82     }
83
84     private static TransactionManagerHelper tmHelper = new TransactionManagerHelper();
85
86 }
87
Popular Tags