KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > J2EETransactionManager


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;
24
25 import com.sun.ejb.*;
26 import com.sun.enterprise.resource.ResourceHandle;
27 import javax.transaction.*;
28 import javax.transaction.xa.XAResource JavaDoc;
29 import javax.transaction.xa.Xid JavaDoc;
30 import java.rmi.RemoteException JavaDoc;
31 import javax.resource.spi.XATerminator JavaDoc;
32 import javax.resource.spi.work.WorkException JavaDoc;
33
34 // START IASRI 4705808 TTT002 -- use List instead of Vector
35
import java.util.List JavaDoc;
36 // END IASRI 4705808 TTT002
37

38 /**
39  *
40  * Manages transacations, acting as a gateway to the TM state machine.
41  *
42  * @author Tony Ng
43  */

44 public interface J2EETransactionManager extends TransactionManager {
45
46     /**
47      * register a synchronization object with the transaction
48      * associated with the current thread
49      *
50      * @param sync the synchronization object
51      *
52      * @exception IllegalStateException Thrown if the transaction in the
53      * target object is in prepared state or the transaction is inactive.
54      *
55      * @exception SystemException Thrown if the transaction manager
56      * encounters an unexpected error condition
57      *
58      */

59     public void registerSynchronization(Synchronization sync)
60         throws RollbackException, IllegalStateException JavaDoc, SystemException;
61
62
63     /**
64      * Enlist the resource specified with the transaction
65      *
66      *
67      * @param tran The transaction object
68      *
69      * @param h The resource handle object
70      *
71      * @return <i>true</i> if the resource was enlisted successfully; otherwise * false.
72      *
73      * @exception RollbackException Thrown to indicate that
74      * the transaction has been marked for rollback only.
75      *
76      * @exception IllegalStateException Thrown if the transaction in the
77      * target object is in prepared state or the transaction is inactive.
78      *
79      * @exception SystemException Thrown if the transaction manager
80      * encounters an unexpected error condition
81      *
82      */

83     public boolean enlistResource(Transaction tran,
84                                   ResourceHandle h)
85         throws RollbackException,
86                IllegalStateException JavaDoc, SystemException;
87
88     /**
89      * Delist the resource specified from the transaction
90      *
91      * @param tran The transaction object
92      *
93      * @param h The resource handle object
94      *
95      * @param flag One of the values of TMSUCCESS, TMSUSPEND, or TMFAIL.
96      *
97      * @exception IllegalStateException Thrown if the transaction in the
98      * target object is inactive.
99      *
100      * @exception SystemException Thrown if the transaction manager
101      * encounters an unexpected error condition
102      *
103      */

104     public boolean delistResource(Transaction tran,
105                                   ResourceHandle h,
106                                   int flag)
107         throws IllegalStateException JavaDoc, SystemException;
108
109     /**
110      * This is called by the Container to ask the Transaction
111      * Manager to enlist all resources held by a component and
112      * to associate the current Transaction with the current
113      * Invocation
114      * The TM finds the component through the InvocationManager
115      */

116     public void enlistComponentResources() throws RemoteException JavaDoc;
117
118     /**
119      * This is called by the Container to ask the Transaction
120      * Manager to delist all resources held by a component
121      *
122      * The TM finds the component through the InvocationManager
123      *
124      * @param suspend true if the resources should be delisted
125      * with TMSUSPEND flag; false otherwise
126      *
127      */

128     public void delistComponentResources(boolean suspend)
129         throws RemoteException JavaDoc;
130
131     /**
132      * This is called by Container to indicate that a component
133      * is being destroyed. All resources registered in the context
134      * should be released
135      *
136      * @param instance The component instance
137      */

138     public void componentDestroyed(Object JavaDoc instance);
139
140     public void ejbDestroyed(ComponentContext context);
141
142     /**
143      * Called by InvocationManager
144      */

145
146     public void preInvoke(ComponentInvocation prev)
147     throws InvocationException;
148
149     /**
150      * Called by InvocationManager
151      */

152
153     public void postInvoke(ComponentInvocation curr, ComponentInvocation prev)
154     throws InvocationException;
155
156     public void setDefaultTransactionTimeout(int seconds);
157     public void cleanTxnTimeout(); // clean up thread specific timeout
158
/**
159      * Returns a list of resource handles held by the component
160      */

161
162     public List JavaDoc getExistingResourceList(Object JavaDoc instance, ComponentInvocation inv);
163
164     public void registerComponentResource(ResourceHandle h);
165
166     public void unregisterComponentResource(ResourceHandle h);
167
168     public void recover(XAResource JavaDoc[] resourceList);
169
170     public void begin(int timeout)
171         throws NotSupportedException, SystemException;
172
173     /**
174      * Return true if a "null transaction context" was received
175      * from the client or if the server's transaction.interoperability
176      * flag is false.
177      * A null tx context indicates that the client had an active
178      * tx but the client container did not support tx interop.
179      * See EJB2.0 spec section 18.5.2.1.
180      */

181     public boolean isNullTransaction();
182
183     /**
184      * Perform checks during export of a transaction on a remote call.
185      */

186     public void checkTransactionExport(boolean isLocal);
187
188     /**
189      * Perform checks during import of a transaction on a remote call.
190      * This is called from the reply interceptors after a remote call completes.
191      */

192     public void checkTransactionImport();
193
194
195     /**
196      * Utility for the ejb container to check if the transaction is marked for
197      * rollback because of timeout. This is applicable only for local transactions
198      * as jts transaction will rollback instead of setting the txn for rollback
199      */

200     public boolean isTimedOut();
201
202     // START IASRI 4662745
203

204     /*
205      * Returns the list of ActiveTransactions. Called by Admin framework
206      * The ArrayList contains TransactionAdminBean
207      */

208     public java.util.ArrayList JavaDoc getActiveTransactions();
209
210     /*
211      * Called by Admin Framework. Forces the given transaction to be rolled back
212      */

213     public void forceRollback(Transaction tran) throws IllegalStateException JavaDoc, SystemException;
214
215     /*
216      * Called by Admin Framework. Returnes number of transactions commited till now.
217      */

218     public int getNumberOfTransactionsCommitted();
219
220     /*
221      * Called by Admin Framework. Returnes number of transactions rolledback till now.
222      */

223     public int getNumberOfTransactionsRolledBack();
224
225     /*
226      * Called by Admin Framework. Returnes number of Active transactions.
227      */

228     public int getNumberOfActiveTransactions();
229
230     /*
231      * Called by Admin Framework.
232      */

233     public void setMonitoringEnabled(boolean enabled);
234
235     /*
236      * Called by Admin Framework.
237      */

238     public void freeze();
239     /*
240      * Called by Admin Framework.
241      */

242     public void unfreeze();
243
244     /*
245      * Called by Admin Framework
246      */

247     public boolean isFrozen();
248
249     // END IASRI 4662745
250

251
252    /**
253      * recreate a transaction based on the Xid. This call causes the calling
254      * thread to be associated with the specified transaction. <p>
255      * This is used by importing transactions via the Connector contract.
256      *
257      * @param xid the Xid object representing a transaction.
258      */

259     public void recreate(Xid JavaDoc xid, long timeout) throws WorkException JavaDoc ;
260
261     /**
262      * Release a transaction. This call causes the calling thread to be
263      * dissociated from the specified transaction. <p>
264      * This is used by importing transactions via the Connector contract.
265      *
266      * @param xid the Xid object representing a transaction.
267      */

268     public void release(Xid JavaDoc xid) throws WorkException JavaDoc ;
269
270     /**
271      * Provides a handle to a <code>XATerminator</code> instance. The
272      * <code>XATerminator</code> instance could be used by a resource adapter
273      * to flow-in transaction completion and crash recovery calls from an EIS.
274      * <p>
275      * This is used by importing transactions via the Connector contract.
276      *
277      * @return a <code>XATerminator</code> instance.
278      */

279     public XATerminator JavaDoc getXATerminator() ;
280
281
282 }
283
Popular Tags