public void enter(Collection<ConnectionInfo> connectionInfos) throws ResourceException { for (ConnectionInfo connectionInfo : connectionInfos) { next.getConnection(connectionInfo); } }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { Thread currentThread = Thread.currentThread(); ClassLoader oldClassLoader = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(classLoader); next.getConnection(connectionInfo); } finally { currentThread.setContextClassLoader(oldClassLoader); } }
/** * Called when a proxied connection which has been released need to be reassociated with a real connection. */ public void reassociateConnection(ConnectionInfo connectionInfo) throws ResourceException { connectionTracker.setEnvironment(connectionInfo, key); next.getConnection(connectionInfo); connectionTracker.handleObtained(this, connectionInfo, true); }
/** * called by: GenericConnectionManager.allocateConnection, GenericConnectionManager.associateConnection, and enter. * in: connectionInfo is non-null, and has non-null ManagedConnectionInfo with non-null managedConnectionfactory. * connection handle may or may not be null. * out: connectionInfo has non-null connection handle, non null ManagedConnectionInfo with non-null ManagedConnection and GeronimoConnectionEventListener. * connection tracker has been notified of handle-managed connection association. * @param connectionInfo * @throws ResourceException */ public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { connectionTracker.setEnvironment(connectionInfo, key); next.getConnection(connectionInfo); connectionTracker.handleObtained(this, connectionInfo, false); }
public void run() { resizeLock.readLock().lock(); try { while (connectionCount < minSize) { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, cri); mci.setSubject(subject); ConnectionInfo ci = new ConnectionInfo(mci); try { next.getConnection(ci); } catch (ResourceException e) { return; } boolean added = addToPool(mci); if (!added) { internalReturn(ci, ConnectionReturnAction.DESTROY); return; } } } catch (Throwable t) { log.error("FillTask encountered error in run method", t); } finally { resizeLock.readLock().unlock(); } }
internalReturn(killInfo, ConnectionReturnAction.DESTROY); next.getConnection(connectionInfo); connectionCount++; if (log.isTraceEnabled()) {
/** * 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 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 LogXAResource( mci.getManagedConnection().getLocalTransaction(), name)); }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); mci.setXAResource( new LocalXAResource(mci.getManagedConnection().getLocalTransaction(), name)); }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { if (connectionInfo.isUnshareable()) { next.getConnection(connectionInfo); return; } ManagedConnectionInfo managedConnectionInfo = connections.get(); if (managedConnectionInfo != null) { if (matchConnections) { ManagedConnectionInfo mciRequest = connectionInfo.getManagedConnectionInfo(); if (null != managedConnectionInfo.getManagedConnectionFactory().matchManagedConnections( Collections.singleton(managedConnectionInfo.getManagedConnection()), mciRequest.getSubject(), mciRequest.getConnectionRequestInfo() )) { connectionInfo.setManagedConnectionInfo(managedConnectionInfo); return; } else { //match failed, get a new cx after returning this one connections.set(null); next.returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE); } } else { connectionInfo.setManagedConnectionInfo(managedConnectionInfo); return; } } //nothing for this thread or match failed next.getConnection(connectionInfo); connections.set(connectionInfo.getManagedConnectionInfo()); }
if (connectionInfo.isUnshareable()) { if (!managedConnectionInfos.containsUnshared(connectionInfo.getManagedConnectionInfo())) { next.getConnection(connectionInfo); managedConnectionInfos.addUnshared(connectionInfo.getManagedConnectionInfo()); if (log.isTraceEnabled()) { next.getConnection(connectionInfo); managedConnectionInfos.addUnshared(previousMci); if (log.isTraceEnabled()) { next.getConnection(connectionInfo); managedConnectionInfos.setShared(connectionInfo.getManagedConnectionInfo()); if (log.isTraceEnabled()) { next.getConnection(connectionInfo);
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 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 { next.getConnection(connectionInfo); try { ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); // get the current transation and status... if there is a problem just assume there is no transaction present Transaction transaction = TxUtil.getTransactionIfActive(transactionManager); if (transaction != null) { XAResource xares = mci.getXAResource(); if (log.isTraceEnabled()) { log.trace("Enlisting connection " + connectionInfo + " with XAResource " + xares + " in transaction: " + transaction); } transaction.enlistResource(xares); } else { if (log.isTraceEnabled()) { log.trace("not enlisting connection " + connectionInfo + " with XAResource " + mci.getXAResource() + " no transaction"); } } } catch (SystemException e) { returnConnection(connectionInfo, ConnectionReturnAction.DESTROY); throw new ResourceException("Could not get transaction", e); } catch (RollbackException e) { //transaction is marked rolled back, so the xaresource could not have been enlisted next.returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE); throw new ResourceException("Could not enlist resource in rolled back transaction", e); } catch (Throwable t) { returnConnection(connectionInfo, ConnectionReturnAction.DESTROY); throw new ResourceException("Unknown throwable when trying to enlist connection in tx", t); } }
/** * 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; }
next.getConnection(connectionInfo); connectionCount++; if (log.isTraceEnabled()) {
next.getConnection(connectionInfo); } else { Subject oldSubject = originalManagedConnectionInfo.getSubject(); newManagedConnectionInfo.setSubject(currentSubject); connectionInfo.setManagedConnectionInfo(newManagedConnectionInfo); next.getConnection(connectionInfo); next.getConnection(connectionInfo);
/** * 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(); }