public void checkState() throws JMSException { if (mc != null) { mc.checkTransactionActive(); } } }
/** * Cleanup * * @throws ResourceException Thrown if an error occurs */ @Override public void cleanup() throws ResourceException { if (logger.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("cleanup()"); } if (isDestroyed.get()) { throw new IllegalStateException("ManagedConnection already destroyed"); } destroyHandles(); inManagedTx = false; inManagedTx = false; // I'm recreating the lock object when we return to the pool // because it looks too nasty to expect the connection handle // to unlock properly in certain race conditions // where the dissociation of the managed connection is "random". lock = new ReentrantLock(); }
/** * Commit * * @throws ResourceException Thrown if the operation fails */ @Override public void commit() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("commit()"); } mc.lock(); try { if (mc.getSession().getTransacted()) { mc.getSession().commit(); } } catch (JMSException e) { throw new ResourceException("Could not commit LocalTransaction", e); } finally { //mc.setInManagedTx(false); mc.unlock(); } }
s = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); mc = (ActiveMQRAManagedConnection) ((ActiveMQRASession) s).getManagedConnection(); ActiveMQConnectionFactory cf1 = mc.getConnectionFactory(); ActiveMQConnectionFactory cf2 = mc2.getConnectionFactory(); mc.destroy(); mc2.destroy();
if (obj instanceof ActiveMQRAManagedConnection) { ActiveMQRAManagedConnection mc = (ActiveMQRAManagedConnection) obj; ManagedConnectionFactory mcf = mc.getManagedConnectionFactory(); if ((mc.getUserName() == null || mc.getUserName() != null && mc.getUserName().equals(credential.getUserName())) && mcf.equals(this)) { if (cri.equals(mc.getCRI())) { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Found matching connection: " + mc);
/** * Get the user name * * @return The user name * @throws ResourceException Thrown if operation fails */ @Override public String getUserName() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getUserName()"); } return mc.getUserName(); }
/** * Get the session and ensure that it is open * * @return The session * @throws JMSException Thrown if an error occurs * @throws IllegalStateException The session is closed */ Session getSessionInternal() throws JMSException { if (mc == null) { throw new IllegalStateException("The session is closed"); } Session session = mc.getSession(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getSessionInternal " + session + " for " + this); } return session; }
/** * Creates a new physical connection to the underlying EIS resource manager. * * @param subject Caller's security information * @param cxRequestInfo Additional resource adapter specific connection request information * @return The managed connection * @throws ResourceException Thrown if a managed connection can't be created */ @Override public ManagedConnection createManagedConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createManagedConnection(" + subject + ", " + cxRequestInfo + ")"); } ActiveMQRAConnectionRequestInfo cri = getCRI((ActiveMQRAConnectionRequestInfo) cxRequestInfo); ActiveMQRACredential credential = ActiveMQRACredential.getCredential(this, subject, cri); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("jms credential: " + credential); } ActiveMQRAManagedConnection mc = new ActiveMQRAManagedConnection(this, cri, ra, credential.getUserName(), credential.getPassword()); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("created new managed connection: " + mc); } registerRecovery(); return mc; }
/** * Rollback * * @throws ResourceException Thrown if the operation fails */ @Override public void rollback() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("rollback()"); } mc.lock(); try { if (mc.getSession().getTransacted()) { mc.getSession().rollback(); } } catch (JMSException ex) { throw new ResourceException("Could not rollback LocalTransaction", ex); } finally { //mc.setInManagedTx(false); mc.unlock(); } } }
ActiveMQRAManagedConnection mc = (ActiveMQRAManagedConnection) ((ActiveMQRASession) s).getManagedConnection(); managedConnections.add(mc); ActiveMQConnectionFactory cf1 = mc.getConnectionFactory(); mc.destroy();
if (obj instanceof ActiveMQRAManagedConnection) { ActiveMQRAManagedConnection mc = (ActiveMQRAManagedConnection) obj; ManagedConnectionFactory mcf = mc.getManagedConnectionFactory(); if ((mc.getUserName() == null || mc.getUserName() != null && mc.getUserName().equals(credential.getUserName())) && mcf.equals(this)) { if (cri.equals(mc.getCRI())) { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Found matching connection: " + mc);
/** * Get the user name * * @return The user name * @throws ResourceException Thrown if operation fails */ @Override public String getUserName() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getUserName()"); } return mc.getUserName(); }
/** * Get the session and ensure that it is open * * @return The session * @throws JMSException Thrown if an error occurs * @throws IllegalStateException The session is closed */ Session getSessionInternal() throws JMSException { if (mc == null) { throw new IllegalStateException("The session is closed"); } Session session = mc.getSession(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getSessionInternal " + session + " for " + this); } return session; }
/** * Creates a new physical connection to the underlying EIS resource manager. * * @param subject Caller's security information * @param cxRequestInfo Additional resource adapter specific connection request information * @return The managed connection * @throws ResourceException Thrown if a managed connection can't be created */ @Override public ManagedConnection createManagedConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createManagedConnection(" + subject + ", " + cxRequestInfo + ")"); } ActiveMQRAConnectionRequestInfo cri = getCRI((ActiveMQRAConnectionRequestInfo) cxRequestInfo); ActiveMQRACredential credential = ActiveMQRACredential.getCredential(this, subject, cri); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("jms credential: " + credential); } ActiveMQRAManagedConnection mc = new ActiveMQRAManagedConnection(this, cri, ra, credential.getUserName(), credential.getPassword()); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("created new managed connection: " + mc); } registerRecovery(); return mc; }
/** * Commit * * @throws ResourceException Thrown if the operation fails */ @Override public void commit() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("commit()"); } mc.lock(); try { if (mc.getSession().getTransacted()) { mc.getSession().commit(); } } catch (JMSException e) { throw new ResourceException("Could not commit LocalTransaction", e); } finally { //mc.setInManagedTx(false); mc.unlock(); } }