/** * in: non-null connection object, from non-null mcf. * connection object is not associated with a managed connection * out: supplied connection object is assiciated with a non-null ManagedConnection from mcf. */ public void associateConnection(Object connection, ManagedConnectionFactory managedConnectionFactory, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo); ConnectionInfo ci = new ConnectionInfo(mci); ci.setConnectionHandle(connection); getStack().getConnection(ci); }
public void connectionClosed(ConnectionEvent connectionEvent) { if (connectionEvent.getSource() != managedConnectionInfo.getManagedConnection()) { throw new IllegalArgumentException( "ConnectionClosed event received from wrong ManagedConnection. Expected " + managedConnectionInfo.getManagedConnection() + ", actual " + connectionEvent.getSource()); } if (log.isTraceEnabled()) { log.trace("connectionClosed called with " + connectionEvent.getConnectionHandle() + " for MCI: " + managedConnectionInfo + " and MC: " + managedConnectionInfo.getManagedConnection()); } ConnectionInfo ci = new ConnectionInfo(managedConnectionInfo); ci.setConnectionHandle(connectionEvent.getConnectionHandle()); try { stack.returnConnection(ci, ConnectionReturnAction.RETURN_HANDLE); } catch (Throwable e) { if (log.isTraceEnabled()) { log.trace("connectionClosed failed with " + connectionEvent.getConnectionHandle() + " for MCI: " + managedConnectionInfo + " and MC: " + managedConnectionInfo.getManagedConnection(), e); } if (e instanceof Error) { throw (Error)e; } } }
public void connectionErrorOccurred(ConnectionEvent connectionEvent) { if (connectionEvent.getSource() != managedConnectionInfo.getManagedConnection()) { throw new IllegalArgumentException( "ConnectionError event received from wrong ManagedConnection. Expected " + managedConnectionInfo.getManagedConnection() + ", actual " + connectionEvent.getSource()); } log.warn("connectionErrorOccurred called with " + connectionEvent.getConnectionHandle(), connectionEvent.getException()); boolean errorOccurred = this.errorOccurred; this.errorOccurred = true; if (!errorOccurred) { ConnectionInfo ci = new ConnectionInfo(managedConnectionInfo); ci.setConnectionHandle(connectionEvent.getConnectionHandle()); stack.returnConnection(ci, ConnectionReturnAction.DESTROY); } }
/** * in: connectionInfo not null, managedConnectionInfo not null. ManagedConnection may or may not be null. ConnectionHandle may or may not be null * out: managedConnection not null. connection handle not null. managedConnectionInfo has connection handle registered. Connection handle is associated with ManagedConnection. * @param connectionInfo * @throws ResourceException */ public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); if (connectionInfo.getConnectionHandle() == null) { connectionInfo.setConnectionHandle( mci.getManagedConnection().getConnection( mci.getSubject(), mci.getConnectionRequestInfo())); mci.addConnectionHandle(connectionInfo); } else if (!mci.hasConnectionInfo(connectionInfo)) { mci.getManagedConnection().associateConnection( connectionInfo.getConnectionHandle()); mci.addConnectionHandle(connectionInfo); } connectionInfo.setTrace(); }
returningConnectionInfo.setConnectionHandle(connectionInfo.getConnectionHandle());