00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 package org.objectweb.jonas.resource;
00027
00028 import java.util.HashSet;
00029 import java.util.Vector;
00030 import javax.resource.ResourceException;
00031 import javax.resource.spi.ManagedConnection;
00032 import javax.transaction.Synchronization;
00033 import javax.transaction.xa.XAResource;
00034
00041 public class MCInfo {
00045 public ManagedConnection mc;
00046
00050 public Vector usedCs = null;
00051
00055 public RMEImpl rme = null;
00056
00060 public boolean rmeCalled = false;
00061
00065 public boolean localTransaction = false;
00066
00071 public LocalXAWrapper lw = null;
00072
00080 public Object ctx;
00081
00086 public Synchronization synchro = null;
00087
00092 public Vector pStmts = null;
00093
00098 public HashSet stmtHash = null;
00099
00100
00104 public boolean connectionEventListener = false;
00105
00110 public MCInfo(ManagedConnection mc) {
00111 this.mc = mc;
00112 localTransaction = false;
00113 usedCs = new Vector();
00114 pStmts = new Vector();
00115 stmtHash = new HashSet();
00116 }
00117
00118
00125 public String getState(String prefix) {
00126 String res = prefix + "* mc=" + mc + "\n";
00127 res += prefix + "Context=" + ctx + "\n";
00128 res += prefix + "size of usedCs:" + usedCs.size() + "\n";
00129 for (int i = 0; i < usedCs.size(); i++) {
00130 res += prefix + "\t" + usedCs.elementAt(i).toString() + "\n";
00131 }
00132 res += prefix + "size of pStmts:" + pStmts.size() + "\n";
00133 for (int i = 0; i < pStmts.size(); i++) {
00134 res += prefix + "\t" + pStmts.elementAt(i).toString() + "\n";
00135 }
00136 return res;
00137 }
00138
00139
00144 public String getState() {
00145 return getState("");
00146 }
00147
00152 public boolean isFreeStmt() {
00153 Object obj = pStmts.firstElement();
00154 if (stmtHash.contains(obj)) {
00155 return false;
00156 }
00157 return true;
00158 }
00159
00164 public void destroy() throws Exception {
00165 mc.destroy();
00166 }
00167
00173 public XAResource getXAResource() throws ResourceException {
00174 if (lw != null) {
00175 return lw;
00176 } else {
00177 return mc.getXAResource();
00178 }
00179 }
00180 }
00181
00182