1 | /* |
2 | |
3 | Derby - Class org.apache.derby.client.net.NetXACallInfo |
4 | |
5 | Copyright (c) 2002, 2005 The Apache Software Foundation or its licensors, where applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | /********************************************************************** |
21 | * |
22 | * |
23 | * Component Name = |
24 | * |
25 | * Package Name = org.apache.derby.client.net |
26 | * |
27 | * Descriptive Name = XACallInfo class |
28 | * |
29 | * Function = Handle XA information |
30 | * |
31 | * List of Classes |
32 | * - NetXACallInfo |
33 | * |
34 | * Restrictions : None |
35 | * |
36 | **********************************************************************/ |
37 | package org.apache.derby.client.net; |
38 | |
39 | import javax.transaction.xa.XAResource; |
40 | import javax.transaction.xa.Xid; |
41 | |
42 | import org.apache.derby.client.am.Connection; |
43 | |
44 | public class NetXACallInfo { |
45 | Xid xid_; // current xid |
46 | int xaFlags_; // current xaFlags |
47 | // may not be needed!!!~~~ |
48 | int xaFunction_; // queued XA function being performed |
49 | int xaRetVal_; // xaretval from server |
50 | boolean xaInProgress_; // set at start(), reset at commit(), |
51 | // rollback(), or prepare() on RDONLY |
52 | boolean xaWasSuspended; // used to indicate an XA tyrans was suspended |
53 | // one or more times, overrides empty transaction |
54 | boolean currConnection_; // set when actualConn_ is the current connection |
55 | boolean freeEntry_; // set when no actualConn_, entry is free / available |
56 | boolean convReleased_; // release coversation, reuse successfull = true |
57 | NetXAResource xaResource_; // NetXAResource containing this NetXACallInfo |
58 | NetXAConnection actualConn_; // the actual connection object, not necessarily |
59 | // the user's connection object |
60 | /* only the first connection object is actually used. The other connection |
61 | * objects are used only for their TCP/IP variables to simulate |
62 | * suspend / resume |
63 | */ |
64 | |
65 | private byte[] crrtkn_; |
66 | private java.io.InputStream in_; |
67 | private java.io.OutputStream out_; |
68 | |
69 | private byte[] uowid_; // Unit of Work ID |
70 | |
71 | private boolean readOnlyTransaction_; // readOnlyTransaction Flag |
72 | |
73 | public NetXACallInfo() { |
74 | xid_ = null; |
75 | xaFlags_ = XAResource.TMNOFLAGS; |
76 | xaInProgress_ = false; |
77 | currConnection_ = false; |
78 | freeEntry_ = true; |
79 | convReleased_ = false; |
80 | actualConn_ = null; |
81 | readOnlyTransaction_ = true; |
82 | xaResource_ = null; |
83 | xaRetVal_ = 0; |
84 | xaWasSuspended = false; |
85 | } |
86 | |
87 | public NetXACallInfo(Xid xid, int flags, NetXAResource xares, NetXAConnection actualConn) { |
88 | xid_ = xid; |
89 | xaFlags_ = flags; |
90 | xaInProgress_ = false; |
91 | currConnection_ = false; |
92 | freeEntry_ = true; |
93 | actualConn_ = actualConn; |
94 | readOnlyTransaction_ = true; |
95 | xaResource_ = xares; |
96 | xaRetVal_ = 0; |
97 | xaWasSuspended = false; |
98 | } |
99 | |
100 | public void saveConnectionVariables() { |
101 | in_ = actualConn_.getNetConnection().getInputStream(); |
102 | out_ = actualConn_.getNetConnection().getOutputStream(); |
103 | crrtkn_ = actualConn_.getCorrelatorToken(); |
104 | } |
105 | |
106 | public java.io.InputStream getInputStream() { |
107 | return in_; |
108 | } |
109 | |
110 | public java.io.OutputStream getOutputStream() { |
111 | return out_; |
112 | } |
113 | |
114 | public byte[] getCorrelatorToken() { |
115 | return crrtkn_; |
116 | } |
117 | |
118 | protected void setUOWID(byte[] uowid) { |
119 | uowid_ = uowid; |
120 | } |
121 | |
122 | protected byte[] getUOWID() { |
123 | return uowid_; |
124 | } |
125 | |
126 | protected void setReadOnlyTransactionFlag(boolean flag) { |
127 | readOnlyTransaction_ = flag; |
128 | } |
129 | |
130 | protected boolean getReadOnlyTransactionFlag() { |
131 | return readOnlyTransaction_; |
132 | } |
133 | |
134 | |
135 | } |
136 | |
137 | |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | |