public FillTask(ConnectionInfo connectionInfo) { managedConnectionFactory = connectionInfo.getManagedConnectionInfo().getManagedConnectionFactory(); subject = connectionInfo.getManagedConnectionInfo().getSubject(); cri = connectionInfo.getManagedConnectionInfo().getConnectionRequestInfo(); }
/** * Removes the released collection from the garbage collection reference tracker, since this * connection is being release via a normal close method. * * @param interceptor ignored * @param connectionInfo the connection that was released * @param action ignored */ public void handleReleased(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo connectionInfo, final ConnectionReturnAction action) { final PhantomReference phantomReference = references.remove(connectionInfo.getManagedConnectionInfo()); if (phantomReference != null) { phantomReference.clear(); } }
/** * Removes the released collection from the garbage collection reference tracker, since this * connection is being release via a normal close method. * * @param interceptor ignored * @param connectionInfo the connection that was released * @param action ignored */ public void handleReleased(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo connectionInfo, final ConnectionReturnAction action) { final PhantomReference phantomReference = references.remove(connectionInfo.getManagedConnectionInfo()); if (phantomReference != null) { phantomReference.clear(); } }
/** * Removes the released collection from the garbage collection reference tracker, since this * connection is being release via a normal close method. * * @param interceptor ignored * @param connectionInfo the connection that was released * @param action ignored */ public void handleReleased(ConnectionTrackingInterceptor interceptor, ConnectionInfo connectionInfo, ConnectionReturnAction action) { PhantomReference phantomReference = references.remove(connectionInfo.getManagedConnectionInfo()); if (phantomReference != null) { phantomReference.clear(); } }
public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { if (connectionReturnAction == ConnectionReturnAction.DESTROY || connectionInfo.isUnshareable() || !connectionInfo.getManagedConnectionInfo().hasConnectionHandles()) { if (connections.get() == connectionInfo.getManagedConnectionInfo()) { connections.remove(); } next.returnConnection(connectionInfo, connectionReturnAction); } }
public void returnConnection( ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); ConnectionInterceptor poolInterceptor = mci.getPoolInterceptor(); poolInterceptor.returnConnection(connectionInfo, connectionReturnAction); }
private void internalReturn(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { if (connectionInfo.getManagedConnectionInfo().hasConnectionHandles()) { if (log.isTraceEnabled()) { log.trace("not returning connection from tx cache (has handles) " + infoString(connectionInfo)); } return; } //No transaction, no handles, we return it. next.returnConnection(connectionInfo, connectionReturnAction); if (log.isTraceEnabled()) { log.trace("completed return of connection through tx cache " + infoString(connectionInfo)); } }
public void returnConnection( ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); ManagedConnection mc = mci.getManagedConnection(); try { mc.destroy(); } catch (ResourceException e) { //log and forget } catch (Error e) { throw e; } catch (Throwable t) { //log and forget } }
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); } }
/** * 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); }
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); } }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); SubjectCRIKey key = new SubjectCRIKey( useSubject ? mci.getSubject() : null, useCRI ? mci.getConnectionRequestInfo() : null); ConnectionInterceptor poolInterceptor = null; synchronized (pools) { if (destroyed) { throw new ResourceException("ConnectionManaged has been destroyed"); } poolInterceptor = (ConnectionInterceptor) pools.get(key); if (poolInterceptor == null) { poolInterceptor = singlePoolFactory.addPoolingInterceptors(next); pools.put(key, (PoolingAttributes) poolInterceptor); } } poolInterceptor.getConnection(connectionInfo); connectionInfo.getManagedConnectionInfo().setPoolInterceptor(poolInterceptor); }
public void exit(Collection<ConnectionInfo> connectionInfos) throws ResourceException { for (Iterator<ConnectionInfo> iterator = connectionInfos.iterator(); iterator.hasNext();) { ConnectionInfo connectionInfo = iterator.next(); if (connectionInfo.isUnshareable()) { //if one is, they all are return; } ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo(); ManagedConnection managedConnection = managedConnectionInfo.getManagedConnection(); if (managedConnection instanceof DissociatableManagedConnection && managedConnectionInfo.isFirstConnectionInfo(connectionInfo)) { iterator.remove(); ((DissociatableManagedConnection) managedConnection).dissociateConnections(); managedConnectionInfo.clearConnectionHandles(); //todo this needs some kind of check so cx isn't returned more than once //in case dissociate calls connection closed event and returns cx to pool. returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE); } } }
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 getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); mci.setXAResource( new LogXAResource( mci.getManagedConnection().getLocalTransaction(), name)); }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); mci.setXAResource(new WrapperNamedXAResource(mci.getManagedConnection().getXAResource(), name)); }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); mci.setXAResource( new LocalXAResource(mci.getManagedConnection().getLocalTransaction(), name)); }
public NamedXAResource getNamedXAResource() throws SystemException { try { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, null); ConnectionInfo recoveryConnectionInfo = new ConnectionInfo(mci); recoveryStack.getConnection(recoveryConnectionInfo); // For pooled resources, we may now have a new MCI (not the one constructed above). Make sure we use the correct MCI return new NamedXAResourceWithConnectioninfo((NamedXAResource) recoveryConnectionInfo.getManagedConnectionInfo().getXAResource(), recoveryConnectionInfo); } catch (ResourceException e) { throw (SystemException) new SystemException("Could not get XAResource for recovery for mcf: " + name).initCause(e); } }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); if (mci.getManagedConnection() != null) { return; } try { ManagedConnection mc = mci.getManagedConnectionFactory().createManagedConnection( mci.getSubject(), mci.getConnectionRequestInfo()); mci.setManagedConnection(mc); GeronimoConnectionEventListener listener = new GeronimoConnectionEventListener(stack, mci); mci.setConnectionEventListener(listener); mc.addConnectionEventListener(listener); } catch (ResourceException re) { log.error("Error occurred creating ManagedConnection for " + connectionInfo, re); throw re; } }