public void addConnectionInfo(ConnectionInfo connectionInfo) { assert connectionInfo.getConnectionHandle() != null; connectionInfos.add(connectionInfo); }
public void removeConnectionInfo(ConnectionInfo connectionInfo) { assert connectionInfo.getConnectionHandle() != null; connectionInfos.remove(connectionInfo); }
/** * in: connectionInfo not null, managedConnectionInfo not null, managedConnection not null. Handle can be null if mc is being destroyed from pool. * out: managedCOnnectionInfo null, handle not in mci.handles. * @param connectionInfo * @param connectionReturnAction */ public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { if (connectionInfo.getConnectionHandle() != null) { connectionInfo.getManagedConnectionInfo().removeConnectionHandle( connectionInfo); } next.returnConnection(connectionInfo, connectionReturnAction); }
Set<ConnectionInfo> infos = resources.get(connectionTrackingInterceptor); if (infos != null) { if (connectionInfo.getConnectionHandle() == null) { log.trace("No infos found for handle " + connectionInfo.getConnectionHandle() + " for MCI: " + connectionInfo.getManagedConnectionInfo() + " for MC: " + connectionInfo.getManagedConnectionInfo().getManagedConnection() +
private void proxyConnection(ConnectionTrackingInterceptor interceptor, ConnectionInfo connectionInfo) throws ResourceException { // if this connection already has a proxy no need to create another if (connectionInfo.getConnectionProxy() != null) return; // DissociatableManagedConnection do not need to be proxied if (connectionInfo.getManagedConnectionInfo().getManagedConnection() instanceof DissociatableManagedConnection) { return; } try { Object handle = connectionInfo.getConnectionHandle(); ConnectionInvocationHandler invocationHandler = new ConnectionInvocationHandler(handle); Object proxy = Proxy.newProxyInstance(handle.getClass().getClassLoader(), handle.getClass().getInterfaces(), invocationHandler); connectionInfo.setConnectionProxy(proxy); ProxyPhantomReference reference = new ProxyPhantomReference(interceptor, connectionInfo.getManagedConnectionInfo(), invocationHandler, referenceQueue); references.put(connectionInfo.getManagedConnectionInfo(), reference); } catch (Throwable e) { throw new ResourceException("Unable to construct connection proxy", e); } }
private void proxyConnection(ConnectionTrackingInterceptor connectionTrackingInterceptor, ConnectionInfo connectionInfo) throws ResourceException { // if this connection already has a proxy no need to create another if (connectionInfo.getConnectionProxy() != null) return; // DissociatableManagedConnection do not need to be proxied if (connectionInfo.getManagedConnectionInfo().getManagedConnection() instanceof DissociatableManagedConnection) { return; } try { Object handle = connectionInfo.getConnectionHandle(); ConnectionInvocationHandler invocationHandler = new ConnectionInvocationHandler(connectionTrackingInterceptor, connectionInfo, handle); Object proxy = Proxy.newProxyInstance(getClassLoader(handle), handle.getClass().getInterfaces(), invocationHandler); // add it to our map... if the map already has a proxy for this connection, use the existing one Object existingProxy = proxiesByConnectionInfo.putIfAbsent(connectionInfo, proxy); if (existingProxy != null) proxy = existingProxy; connectionInfo.setConnectionProxy(proxy); } catch (Throwable e) { throw new ResourceException("Unable to construct connection proxy", e); } }
public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { if (log.isTraceEnabled()) { log.trace("returning connection " + connectionInfo.getConnectionHandle() + " for MCI " + connectionInfo.getManagedConnectionInfo() + " and MC " + connectionInfo.getManagedConnectionInfo().getManagedConnection() + " to pool " + this); if (connectionReturnAction == ConnectionReturnAction.RETURN_HANDLE && mci.hasConnectionHandles()) { if (log.isTraceEnabled()) { log.trace("Return request at pool with connection handles! " + connectionInfo.getConnectionHandle() + " for MCI " + connectionInfo.getManagedConnectionInfo() + " and MC " + connectionInfo.getManagedConnectionInfo().getManagedConnection() + " to pool " + this, new Exception("Stack trace"));
/** * in: mcf != null, is a deployed mcf * out: useable connection object. */ public Object allocateConnection(ManagedConnectionFactory managedConnectionFactory, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo); ConnectionInfo ci = new ConnectionInfo(mci); getStack().getConnection(ci); Object connection = ci.getConnectionProxy(); if (connection == null) { connection = ci.getConnectionHandle(); } else { // connection proxy is used only once so we can be notified // by the garbage collector when a connection is abandoned ci.setConnectionProxy(null); } return connection; }
/** * 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(); }
private void proxyConnection(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo connectionInfo) throws ResourceException { // if this connection already has a proxy no need to create another if (connectionInfo.getConnectionProxy() != null) { return; } // DissociatableManagedConnection do not need to be proxied if (connectionInfo.getManagedConnectionInfo().getManagedConnection() instanceof DissociatableManagedConnection) { return; } try { final Object handle = connectionInfo.getConnectionHandle(); final ConnectionInvocationHandler invocationHandler = new ConnectionInvocationHandler(handle); final Object proxy = newProxy(handle, invocationHandler); connectionInfo.setConnectionProxy(proxy); final ProxyPhantomReference reference = new ProxyPhantomReference(interceptor, connectionInfo.getManagedConnectionInfo(), invocationHandler, referenceQueue); references.put(connectionInfo.getManagedConnectionInfo(), reference); } catch (final Throwable e) { throw new ResourceException("Unable to construct connection proxy", e); } }
private void proxyConnection(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo connectionInfo) throws ResourceException { // if this connection already has a proxy no need to create another if (connectionInfo.getConnectionProxy() != null) { return; } // DissociatableManagedConnection do not need to be proxied if (connectionInfo.getManagedConnectionInfo().getManagedConnection() instanceof DissociatableManagedConnection) { return; } try { final Object handle = connectionInfo.getConnectionHandle(); final ConnectionInvocationHandler invocationHandler = new ConnectionInvocationHandler(handle); final Object proxy = newProxy(handle, invocationHandler); connectionInfo.setConnectionProxy(proxy); final ProxyPhantomReference reference = new ProxyPhantomReference(interceptor, connectionInfo.getManagedConnectionInfo(), invocationHandler, referenceQueue); references.put(connectionInfo.getManagedConnectionInfo(), reference); } catch (final Throwable e) { throw new ResourceException("Unable to construct connection proxy", e); } }
managedConnectionInfos.setShared(connectionInfo.getManagedConnectionInfo()); if (log.isTraceEnabled()) { log.trace("supplying connection from pool " + connectionInfo.getConnectionHandle() + " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection() + " to tx caching interceptor " + this);
returningConnectionInfo.setConnectionHandle(connectionInfo.getConnectionHandle());