1 25 26 27 package org.objectweb.jonas.resource; 28 29 import javax.transaction.Synchronization ; 30 31 import org.objectweb.util.monolog.api.BasicLevel; 32 33 import java.util.Iterator ; 34 import java.util.Map ; 35 36 45 public class MySynchro implements Synchronization { 46 47 51 private MCInfo mci = null; 52 55 private ConnectionManagerImpl cm = null; 56 57 58 65 public MySynchro(ConnectionManagerImpl pCm, MCInfo pMci) { 66 mci = pMci; 67 cm = pCm; 68 mci.synchro = this; 69 cm.synchros.add(mci); 70 } 71 72 73 79 public void afterCompletion(int status) { 80 if (mci == null) { 81 return; 82 } 83 synchronized (cm) { 84 mci.synchro = null; 85 cm.synchros.remove(mci); 86 if (!mci.usedCs.isEmpty()) { 87 cm.usedMCs.remove(mci.ctx); 90 mci.ctx = null; 91 if (cm.poolTrace.isLoggable(BasicLevel.DEBUG)) { 92 cm.poolTrace.log(BasicLevel.DEBUG, "state:\n" + cm.getState("\t")); 93 } 94 } else { 95 try { 98 cm.mcs.remove(mci); 99 if (mci.ctx != null) { 100 cm.usedMCs.remove(mci.ctx); 101 } else { 102 Iterator it = cm.usedMCs.entrySet().iterator(); 103 while (it.hasNext()) { 104 Map.Entry me = (Map.Entry ) it.next(); 105 if (mci.equals(me.getValue())) { 106 it.remove(); 107 } 108 } 109 } 110 111 mci.ctx = null; 112 mci.mc.cleanup(); 113 114 cm.poolMCs.releaseResource(mci.mc, false, false); 115 if (ConnectionManagerImpl.trace.isLoggable(BasicLevel.DEBUG)) { 116 ConnectionManagerImpl.trace.log(BasicLevel.DEBUG, "Later releasing of MC=" + mci.mc); 117 } 118 mci = null; 119 if (ConnectionManagerImpl.poolTrace.isLoggable(BasicLevel.DEBUG)) { 120 ConnectionManagerImpl.poolTrace.log(BasicLevel.DEBUG, "state\n" + cm.getState("\t")); 121 } 122 } catch (Exception e) { 123 ConnectionManagerImpl.trace.log(BasicLevel.ERROR, 124 "an error related during releasing of ManagedConection", 125 e, "MySynchro", "afterCompletion"); 126 } 127 } 128 mci = null; 129 cm = null; 130 } 131 } 132 133 134 138 public void beforeCompletion() { 139 } 140 } 141 142 | Popular Tags |