KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jotm > InternalTransactionContext


1 /*
2  * @(#) InternalTransactionContext.java
3  *
4  * JOTM: Java Open Transaction Manager
5  *
6  *
7  * This module was originally developed by
8  *
9  * - Bull S.A. as part of the JOnAS application server code released in
10  * July 1999 (www.bull.com)
11  *
12  * --------------------------------------------------------------------------
13  * The original code and portions created by Bull SA are
14  * Copyright (c) 1999 BULL SA
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are met:
19  *
20  * -Redistributions of source code must retain the above copyright notice, this
21  * list of conditions and the following disclaimer.
22  *
23  * -Redistributions in binary form must reproduce the above copyright notice,
24  * this list of conditions and the following disclaimer in the documentation
25  * and/or other materials provided with the distribution.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  *
39  * --------------------------------------------------------------------------
40  * $Id: InternalTransactionContext.java,v 1.12 2005/04/22 17:49:06 tonyortiz Exp $
41  * --------------------------------------------------------------------------
42  */

43 package org.objectweb.jotm;
44
45 // javax import (JTA)
46
import javax.transaction.xa.Xid JavaDoc;
47
48 /**
49  * Classe <code>InternalTransactionContext</code> is a generic implementation of
50  * the JOTM Transaction Context. This Context is used by JOTM and by the Current
51  * Object. It can't be propagate, it have to be transalate for each Transport
52  * Layer Transaction Prapagation implementation
53  *
54  * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
55  * @version 1.0, 12/09/2002
56  */

57 public class InternalTransactionContext implements TransactionContext {
58
59     /**
60      * @serial
61      */

62     private int timeout;
63
64     /**
65      * @serial
66      */

67     private Coordinator coordinator;
68     
69     /**
70      * @serial
71      */

72     private Terminator JavaDoc terminator;
73
74     /**
75      * @serial
76      */

77     private Xid xid;
78     
79     /**
80      * false if the Internal Tx Ctx is build from another VI's tx context
81      */

82     private boolean isJotmCtx=true;
83
84     /**
85      * Build a new TransactionContext (from JTA layer)
86      */

87     public InternalTransactionContext(int t, Coordinator c, Terminator JavaDoc term, Xid x) {
88         timeout = t;
89         coordinator = c;
90         terminator=term;
91         xid = x;
92         
93         if (TraceTm.jta.isDebugEnabled()) {
94             TraceTm.jta.debug("xid=" + xid + ", timeout=" + timeout);
95         }
96     }
97
98     public InternalTransactionContext(int t, Coordinator c, Xid x) {
99         timeout = t;
100         coordinator = c;
101         terminator=(Terminator JavaDoc)c;
102         xid = x;
103         
104         if (TraceTm.jta.isDebugEnabled()) {
105             TraceTm.jta.debug("xid=" + xid + ", timeout=" + timeout);
106         }
107     }
108
109     /**
110      * Get the timeout associated with the transaction
111      */

112     public int getTimeout() {
113         return timeout;
114     }
115
116     /**
117      * Get the coordinator associated with the transaction
118      */

119     public Coordinator getCoordinator() {
120         return coordinator;
121     }
122
123     /**
124      * Set the coordinator associated with the transaction
125      */

126     public void setCoordinator(Coordinator coord) {
127         this.coordinator = coord;
128     }
129
130     /**
131      * Get the Terminator associated with the transaction
132      */

133     public Terminator JavaDoc getTerminator() {
134         return terminator ;
135     }
136
137     /**
138      * Set the termiantor associated with the transaction
139      */

140     public void setTerminator(Terminator JavaDoc term) {
141         this.terminator = term;
142     }
143
144     /**
145      * Get the control associated with the transaction
146      */

147     public Control getControl() {
148         return (Control) coordinator;
149     }
150
151     /**
152      * Get the Xid associated with the transaction
153      */

154     public org.objectweb.jotm.Xid getXid() {
155         if (TraceTm.jta.isDebugEnabled()) {
156             TraceTm.jta.debug("xid=" + xid);
157         }
158         return (org.objectweb.jotm.Xid) xid;
159     }
160
161     /**
162      * Set a flag in the context to indicate as coming from another Vendor
163      *
164      * @return boolean
165      */

166     public void setNotJotmCtx() {
167         isJotmCtx= false;
168     }
169
170     /**
171      * return true if this context was build from a JOTM's context
172      *
173      * @return boolean
174      */

175     public boolean isJotmCtx() {
176         return isJotmCtx;
177     }
178
179 }
180
Popular Tags