1 25 26 package org.objectweb.jonas.resource; 27 28 import java.util.ArrayList ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 import java.util.Vector ; 32 33 import javax.resource.ResourceException ; 34 import javax.resource.spi.ManagedConnection ; 35 import javax.transaction.Synchronization ; 36 import javax.transaction.xa.XAResource ; 37 38 44 public class MCInfo { 45 48 public ManagedConnection mc; 49 50 53 public Vector usedCs = null; 54 55 58 public RMEImpl rme = null; 59 60 63 public boolean rmeCalled = false; 64 65 68 public boolean localTransaction = false; 69 70 74 public LocalXAWrapper lw = null; 75 76 83 public Object ctx; 84 85 89 public Synchronization synchro = null; 90 91 95 public List pStmts = null; 96 97 98 101 public boolean connectionEventListener = false; 102 103 107 public MCInfo(ManagedConnection mc) { 108 this.mc = mc; 109 localTransaction = false; 110 usedCs = new Vector (); 111 pStmts = new ArrayList (); 112 } 113 114 115 121 public String getState(String prefix) { 122 String res = prefix + "* mc=" + mc + "\n"; 123 res += prefix + "Context=" + ctx + "\n"; 124 res += prefix + "size of usedCs:" + usedCs.size() + "\n"; 125 for (int i = 0; i < usedCs.size(); i++) { 126 res += prefix + "\t" + usedCs.elementAt(i).toString() + "\n"; 127 } 128 res += prefix + "size of pStmts:" + pStmts.size() + "\n"; 129 for (Iterator it = pStmts.iterator(); it.hasNext();) { 130 res += prefix + "\t" + it.next() + "\n"; 131 } 132 return res; 133 } 134 135 136 140 public String getState() { 141 return getState(""); 142 } 143 144 149 public int findFreeStmt() { 150 int offset = -1; 151 int size = pStmts.size(); 152 PreparedStatementWrapper psw = null; 153 if (pStmts != null) { 154 for (int i = 0; i < size; i++) { 155 psw = (PreparedStatementWrapper) pStmts.get(i); 156 if (psw.isClosed()) { 157 offset = i; 158 break; 159 } 160 } 161 } 162 return offset; 163 } 164 165 169 public void destroy() throws Exception { 170 mc.destroy(); 171 } 172 173 178 public XAResource getXAResource() throws ResourceException { 179 if (lw != null) { 180 return lw; 181 } else { 182 return mc.getXAResource(); 183 } 184 } 185 } 186 187 188 | Popular Tags |