Class ActiveMQRAManagedConnection

  • All Implemented Interfaces:
    jakarta.jms.ExceptionListener, jakarta.resource.spi.ManagedConnection

    public final class ActiveMQRAManagedConnection
    extends Object
    implements jakarta.resource.spi.ManagedConnection, jakarta.jms.ExceptionListener
    The managed connection
    • Method Detail

      • getConnection

        public Object getConnection​(Subject subject,
                                    jakarta.resource.spi.ConnectionRequestInfo cxRequestInfo)
                             throws jakarta.resource.ResourceException
        Get a connection
        Specified by:
        getConnection in interface jakarta.resource.spi.ManagedConnection
        Parameters:
        subject - The security subject
        cxRequestInfo - The request info
        Returns:
        The connection
        Throws:
        jakarta.resource.ResourceException - Thrown if an error occurs
      • destroy

        public void destroy()
                     throws jakarta.resource.ResourceException
        Destroy the physical connection.
        Specified by:
        destroy in interface jakarta.resource.spi.ManagedConnection
        Throws:
        jakarta.resource.ResourceException - Could not property close the session and connection.
      • cleanup

        public void cleanup()
                     throws jakarta.resource.ResourceException
        Cleanup
        Specified by:
        cleanup in interface jakarta.resource.spi.ManagedConnection
        Throws:
        jakarta.resource.ResourceException - Thrown if an error occurs
      • associateConnection

        public void associateConnection​(Object obj)
                                 throws jakarta.resource.ResourceException
        Move a handler from one mc to this one.
        Specified by:
        associateConnection in interface jakarta.resource.spi.ManagedConnection
        Parameters:
        obj - An object of type ActiveMQSession.
        Throws:
        jakarta.resource.ResourceException - Failed to associate connection.
        jakarta.resource.spi.IllegalStateException - ManagedConnection in an illegal state.
      • checkTransactionActive

        public void checkTransactionActive()
                                    throws jakarta.jms.JMSException
        Throws:
        jakarta.jms.JMSException
      • lock

        protected void lock()
        Aqquire a lock on the managed connection
      • tryLock

        protected void tryLock()
                        throws jakarta.jms.JMSException
        Aqquire a lock on the managed connection within the specified period
        Throws:
        jakarta.jms.JMSException - Thrown if an error occurs
      • unlock

        protected void unlock()
        Unlock the managed connection
      • addConnectionEventListener

        public void addConnectionEventListener​(jakarta.resource.spi.ConnectionEventListener l)
        Add a connection event listener.
        Specified by:
        addConnectionEventListener in interface jakarta.resource.spi.ManagedConnection
        Parameters:
        l - The connection event listener to be added.
      • removeConnectionEventListener

        public void removeConnectionEventListener​(jakarta.resource.spi.ConnectionEventListener l)
        Remove a connection event listener.
        Specified by:
        removeConnectionEventListener in interface jakarta.resource.spi.ManagedConnection
        Parameters:
        l - The connection event listener to be removed.
      • getXAResource

        public XAResource getXAResource()
                                 throws jakarta.resource.ResourceException
        Get the XAResource for the connection.
        Specified by:
        getXAResource in interface jakarta.resource.spi.ManagedConnection
        Returns:
        The XAResource for the connection.
        Throws:
        jakarta.resource.ResourceException - XA transaction not supported
      • getLocalTransaction

        public jakarta.resource.spi.LocalTransaction getLocalTransaction()
                                                                  throws jakarta.resource.ResourceException
        Get the location transaction for the connection.
        Specified by:
        getLocalTransaction in interface jakarta.resource.spi.ManagedConnection
        Returns:
        The local transaction for the connection.
        Throws:
        jakarta.resource.ResourceException - Thrown if operation fails.
      • getMetaData

        public jakarta.resource.spi.ManagedConnectionMetaData getMetaData()
                                                                   throws jakarta.resource.ResourceException
        Get the meta data for the connection.
        Specified by:
        getMetaData in interface jakarta.resource.spi.ManagedConnection
        Returns:
        The meta data for the connection.
        Throws:
        jakarta.resource.ResourceException - Thrown if the operation fails.
        jakarta.resource.spi.IllegalStateException - Thrown if the managed connection already is destroyed.
      • setLogWriter

        public void setLogWriter​(PrintWriter out)
                          throws jakarta.resource.ResourceException
        Set the log writer -- NOT SUPPORTED
        Specified by:
        setLogWriter in interface jakarta.resource.spi.ManagedConnection
        Parameters:
        out - The log writer
        Throws:
        jakarta.resource.ResourceException - If operation fails
      • getLogWriter

        public PrintWriter getLogWriter()
                                 throws jakarta.resource.ResourceException
        Get the log writer -- NOT SUPPORTED
        Specified by:
        getLogWriter in interface jakarta.resource.spi.ManagedConnection
        Returns:
        Always null
        Throws:
        jakarta.resource.ResourceException - If operation fails
      • onException

        public void onException​(jakarta.jms.JMSException exception)
        Notifies user of a JMS exception.
        Specified by:
        onException in interface jakarta.jms.ExceptionListener
        Parameters:
        exception - The JMS exception
      • getSession

        protected jakarta.jms.Session getSession()
                                          throws jakarta.jms.JMSException
        Get the session for this connection.
        Returns:
        The session
        Throws:
        jakarta.jms.JMSException
      • sendEvent

        protected void sendEvent​(jakarta.resource.spi.ConnectionEvent event)
        Send an event.
        Parameters:
        event - The event to send.
      • removeHandle

        protected void removeHandle​(ActiveMQRASession handle)
        Remove a handle from the handle map.
        Parameters:
        handle - The handle to remove.
      • getCRI

        protected ActiveMQRAConnectionRequestInfo getCRI()
        Get the request info for this connection.
        Returns:
        The connection request info for this connection.
      • getManagedConnectionFactory

        protected ActiveMQRAManagedConnectionFactory getManagedConnectionFactory()
        Get the connection factory for this connection.
        Returns:
        The connection factory for this connection.
      • getUserName

        protected String getUserName()
        Get the user name
        Returns:
        The user name
      • setInManagedTx

        protected void setInManagedTx​(boolean inManagedTx)