1 17 18 package org.apache.geronimo.connector.outbound; 19 20 import javax.resource.ResourceException ; 21 22 28 public class ConnectionHandleInterceptor implements ConnectionInterceptor { 29 30 private final ConnectionInterceptor next; 31 32 public ConnectionHandleInterceptor(ConnectionInterceptor next) { 33 this.next = next; 34 } 35 36 42 public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { 43 next.getConnection(connectionInfo); 44 ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); 45 if (connectionInfo.getConnectionHandle() == null) { 46 connectionInfo.setConnectionHandle( 47 mci.getManagedConnection().getConnection( 48 mci.getSubject(), 49 mci.getConnectionRequestInfo())); 50 mci.addConnectionHandle(connectionInfo); 51 52 } else if (!mci.hasConnectionInfo(connectionInfo)) { 53 mci.getManagedConnection().associateConnection( 54 connectionInfo.getConnectionHandle()); 55 mci.addConnectionHandle(connectionInfo); 56 } 57 connectionInfo.setTrace(); 58 } 59 60 66 public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { 67 if (connectionInfo.getConnectionHandle() != null) { 68 connectionInfo.getManagedConnectionInfo().removeConnectionHandle( 69 connectionInfo); 70 } 71 next.returnConnection(connectionInfo, connectionReturnAction); 72 } 73 74 public void destroy() { 75 next.destroy(); 76 } 77 } 78 | Popular Tags |