KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > containers > PMTransactionManagerImpl


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
24 package com.sun.ejb.containers;
25
26 import java.util.*;
27 import javax.transaction.*;
28 import com.sun.enterprise.*;
29
30
31 /**
32  * A "wrapper" implementation of javax.transaction.TransactionManager
33  * used by the container to communicate with the PersistenceManager.
34  * The PM can only call getTransaction and getStatus methods.
35  * This object is available at the JNDI name "java:pm/TransactionManager".
36  */

37 public class PMTransactionManagerImpl implements TransactionManager,
38                          java.io.Serializable JavaDoc {
39
40     transient private TransactionManager transactionManager = null;
41
42     /**
43      * Create a transaction manager instance
44      */

45     PMTransactionManagerImpl() {}
46
47     /**
48      * Obtain the status of the transaction associated with the current thread.
49      *
50      * @return The transaction status. If no transaction is associated with
51      * the current thread, this method returns the Status.NoTransaction
52      * value.
53      */

54     public int getStatus() throws SystemException
55     {
56     if ( transactionManager == null )
57         transactionManager = Switch.getSwitch().getTransactionManager();
58     return transactionManager.getStatus();
59     }
60
61     /**
62      * Get the transaction object that represents the transaction
63      * context of the calling thread
64      */

65     public Transaction getTransaction() throws SystemException
66     {
67     if ( transactionManager == null )
68         transactionManager = Switch.getSwitch().getTransactionManager();
69     Transaction tx = transactionManager.getTransaction();
70     if ( tx == null )
71         return null;
72     else
73         return new PMTransactionImpl(tx);
74     }
75
76
77     public void begin()
78         throws IllegalStateException JavaDoc, SystemException {
79
80         throw new IllegalStateException JavaDoc("Operation not allowed");
81     }
82
83     public void commit() throws RollbackException,
84     HeuristicMixedException, HeuristicRollbackException,
85         SecurityException JavaDoc, IllegalStateException JavaDoc, SystemException {
86
87         throw new IllegalStateException JavaDoc("Operation not allowed");
88     }
89
90     public void rollback()
91         throws IllegalStateException JavaDoc, SecurityException JavaDoc, SystemException {
92
93         throw new IllegalStateException JavaDoc("Operation not allowed");
94     }
95
96     public void setRollbackOnly()
97         throws IllegalStateException JavaDoc, SystemException {
98
99         throw new IllegalStateException JavaDoc("Operation not allowed");
100     }
101
102     public void resume(Transaction suspended) throws
103         InvalidTransactionException, IllegalStateException JavaDoc, SystemException {
104
105         throw new IllegalStateException JavaDoc("Operation not allowed");
106     }
107
108     public Transaction suspend() throws SystemException {
109         throw new IllegalStateException JavaDoc("Operation not allowed");
110     }
111
112     public void setTransactionTimeout(int seconds)
113         throws SystemException {
114
115         throw new IllegalStateException JavaDoc("Operation not allowed");
116     }
117
118 }
119
120
Popular Tags