1 17 18 package org.apache.geronimo.connector.outbound; 19 20 import javax.resource.ResourceException ; 21 import javax.resource.spi.ManagedConnection ; 22 23 29 public class MCFConnectionInterceptor implements ConnectionInterceptor { 30 31 private ConnectionInterceptor stack; 32 33 public MCFConnectionInterceptor() { 34 } 35 36 public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { 37 ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); 38 if (mci.getManagedConnection() != null) { 39 return; 40 } 41 ManagedConnection mc = 42 mci.getManagedConnectionFactory().createManagedConnection( 43 mci.getSubject(), 44 mci.getConnectionRequestInfo()); 45 mci.setManagedConnection(mc); 46 GeronimoConnectionEventListener listener = new GeronimoConnectionEventListener(stack, mci); 47 mci.setConnectionEventListener(listener); 48 mc.addConnectionEventListener(listener); 49 } 50 51 public void returnConnection( 52 ConnectionInfo connectionInfo, 53 ConnectionReturnAction connectionReturnAction) { 54 ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); 55 ManagedConnection mc = mci.getManagedConnection(); 56 try { 57 mc.destroy(); 58 } catch (ResourceException e) { 59 } catch (Error e) { 61 throw e; 62 } catch (Throwable t) { 63 } 65 } 66 67 public void destroy() { 68 } 70 71 public void setStack(ConnectionInterceptor stack) { 72 this.stack = stack; 73 } 74 75 } 76 | Popular Tags |