1 23 24 package com.sun.enterprise.resource; 25 26 import javax.transaction.xa.XAResource ; 27 import javax.naming.*; 28 import com.sun.enterprise.log.Log; 29 import com.sun.enterprise.PoolManager; 30 import com.sun.enterprise.Switch; 31 import javax.resource.spi.*; 32 import javax.resource.ResourceException ; 33 import java.util.*; 34 import java.util.logging.*; 35 import com.sun.logging.*; 36 37 40 public class LocalTxConnectionEventListener implements ConnectionEventListener { 41 42 private PoolManager poolMgr; 43 44 47 static Logger _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER); 48 49 private IdentityHashMap associatedHandles; 54 55 private ResourceHandle resource; 56 57 public LocalTxConnectionEventListener(ResourceHandle resource) { 58 this.resource = resource; 59 this.associatedHandles = new IdentityHashMap(10); 60 this.poolMgr = Switch.getSwitch().getPoolManager(); 61 } 62 63 public void connectionClosed(ConnectionEvent evt) { 64 Object connectionHandle = evt.getConnectionHandle(); 65 ResourceHandle handle = resource; 66 if (associatedHandles.containsKey(connectionHandle)) { 67 handle = (ResourceHandle) associatedHandles.get(connectionHandle); 68 } 69 poolMgr.resourceClosed(handle); 70 } 71 72 public void connectionErrorOccurred(ConnectionEvent evt) { 73 resource.setConnectionErrorOccurred(); 74 ManagedConnection mc = (ManagedConnection) evt.getSource(); 75 mc.removeConnectionEventListener(this); 76 poolMgr.resourceErrorOccurred( resource ); 77 try { 78 mc.destroy(); 79 } catch (ResourceException ex) { 80 } 82 } 83 84 public void localTransactionStarted(ConnectionEvent evt) { 85 } 87 88 public void localTransactionCommitted(ConnectionEvent evt) { 89 } 91 92 public void localTransactionRolledback(ConnectionEvent evt) { 93 } 95 96 public void associateHandle(Object c, ResourceHandle h) { 97 associatedHandles.put(c, h); 98 } 99 100 public void removeAssociation(Object c) { 101 associatedHandles.remove(c); 102 } 103 104 public Map getAssociatedHandles(){ 105 return associatedHandles; 106 } 107 108 } 109 110 | Popular Tags |