1 22 package org.jboss.resource.connectionmanager; 23 24 import javax.resource.ResourceException ; 25 import javax.resource.spi.ConnectionEvent ; 26 import javax.resource.spi.ManagedConnection ; 27 28 import org.jboss.logging.Logger; 29 30 44 public class NoTxConnectionManager extends BaseConnectionManager2 45 { 46 public NoTxConnectionManager() 47 { 48 } 49 50 57 public NoTxConnectionManager(CachedConnectionManager ccm, 58 ManagedConnectionPool poolingStrategy) 59 { 60 super(ccm, poolingStrategy); 61 } 62 63 public ConnectionListener createConnectionListener(ManagedConnection mc, Object context) 64 { 65 ConnectionListener cli = new NoTxConnectionEventListener(mc, poolingStrategy, context, log); 66 mc.addConnectionEventListener(cli); 67 return cli; 68 } 69 70 protected void managedConnectionDisconnected(ConnectionListener cl) throws ResourceException 71 { 72 if (cl.isManagedConnectionFree()) 74 returnManagedConnection(cl, false); 75 } 76 77 private class NoTxConnectionEventListener extends BaseConnectionEventListener 78 { 79 private NoTxConnectionEventListener(final ManagedConnection mc, final ManagedConnectionPool mcp, final Object context, Logger log) 80 { 81 super(mc, mcp, context, log); 82 } 83 84 public void connectionClosed(ConnectionEvent ce) 85 { 86 try 87 { 88 getCcm().unregisterConnection(NoTxConnectionManager.this, ce.getConnectionHandle()); 89 } 90 catch (Throwable t) 91 { 92 log.info("Throwable from unregisterConnection", t); 93 } 94 try 95 { 96 unregisterAssociation(this, ce.getConnectionHandle()); 97 if (isManagedConnectionFree()) 98 { 99 returnManagedConnection(this, false); 100 } 101 } 102 catch (ResourceException re) 103 { 104 log.error("ResourceException while closing connection handle!", re); 105 } 106 } 107 108 public void localTransactionStarted(ConnectionEvent ce) 109 { 110 } 112 113 public void localTransactionCommitted(ConnectionEvent ce) 114 { 115 } 117 118 public void localTransactionRolledback(ConnectionEvent ce) 119 { 120 } 122 } 123 } 124 | Popular Tags |