001: /*
002:
003: Derby - Class org.apache.derby.client.net.NetXACallInfo
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021: /**********************************************************************
022: *
023: *
024: * Component Name =
025: *
026: * Package Name = org.apache.derby.client.net
027: *
028: * Descriptive Name = XACallInfo class
029: *
030: * Function = Handle XA information
031: *
032: * List of Classes
033: * - NetXACallInfo
034: *
035: * Restrictions : None
036: *
037: **********************************************************************/package org.apache.derby.client.net;
038:
039: import javax.transaction.xa.XAResource;
040: import javax.transaction.xa.Xid;
041:
042: import org.apache.derby.client.am.Connection;
043:
044: public class NetXACallInfo {
045: Xid xid_; // current xid
046: int xaFlags_; // current xaFlags
047: // may not be needed!!!~~~
048: int xaFunction_; // queued XA function being performed
049: int xaRetVal_; // xaretval from server
050: boolean xaInProgress_; // set at start(), reset at commit(),
051: // rollback(), or prepare() on RDONLY
052: boolean xaWasSuspended; // used to indicate an XA tyrans was suspended
053: // one or more times, overrides empty transaction
054: boolean currConnection_; // set when actualConn_ is the current connection
055: boolean freeEntry_; // set when no actualConn_, entry is free / available
056: boolean convReleased_; // release coversation, reuse successfull = true
057: NetXAResource xaResource_; // NetXAResource containing this NetXACallInfo
058: NetXAConnection actualConn_; // the actual connection object, not necessarily
059: // the user's connection object
060: /* only the first connection object is actually used. The other connection
061: * objects are used only for their TCP/IP variables to simulate
062: * suspend / resume
063: */
064:
065: private byte[] crrtkn_;
066: private java.io.InputStream in_;
067: private java.io.OutputStream out_;
068:
069: private byte[] uowid_; // Unit of Work ID
070:
071: private boolean readOnlyTransaction_; // readOnlyTransaction Flag
072:
073: public NetXACallInfo() {
074: xid_ = null;
075: xaFlags_ = XAResource.TMNOFLAGS;
076: xaInProgress_ = false;
077: currConnection_ = false;
078: freeEntry_ = true;
079: convReleased_ = false;
080: actualConn_ = null;
081: readOnlyTransaction_ = true;
082: xaResource_ = null;
083: xaRetVal_ = 0;
084: xaWasSuspended = false;
085: }
086:
087: public NetXACallInfo(Xid xid, int flags, NetXAResource xares,
088: NetXAConnection actualConn) {
089: xid_ = xid;
090: xaFlags_ = flags;
091: xaInProgress_ = false;
092: currConnection_ = false;
093: freeEntry_ = true;
094: actualConn_ = actualConn;
095: readOnlyTransaction_ = true;
096: xaResource_ = xares;
097: xaRetVal_ = 0;
098: xaWasSuspended = false;
099: }
100:
101: public void saveConnectionVariables() {
102: in_ = actualConn_.getNetConnection().getInputStream();
103: out_ = actualConn_.getNetConnection().getOutputStream();
104: crrtkn_ = actualConn_.getCorrelatorToken();
105: }
106:
107: public java.io.InputStream getInputStream() {
108: return in_;
109: }
110:
111: public java.io.OutputStream getOutputStream() {
112: return out_;
113: }
114:
115: public byte[] getCorrelatorToken() {
116: return crrtkn_;
117: }
118:
119: protected void setUOWID(byte[] uowid) {
120: uowid_ = uowid;
121: }
122:
123: protected byte[] getUOWID() {
124: return uowid_;
125: }
126:
127: protected void setReadOnlyTransactionFlag(boolean flag) {
128: readOnlyTransaction_ = flag;
129: }
130:
131: protected boolean getReadOnlyTransactionFlag() {
132: return readOnlyTransaction_;
133: }
134:
135: }
|