Package org.apache.activemq.artemis.ra
Class ActiveMQRAManagedConnection
- java.lang.Object
-
- org.apache.activemq.artemis.ra.ActiveMQRAManagedConnection
-
- All Implemented Interfaces:
javax.jms.ExceptionListener,javax.resource.spi.ManagedConnection
public final class ActiveMQRAManagedConnection extends java.lang.Object implements javax.resource.spi.ManagedConnection, javax.jms.ExceptionListenerThe managed connection
-
-
Constructor Summary
Constructors Constructor Description ActiveMQRAManagedConnection(ActiveMQRAManagedConnectionFactory mcf, ActiveMQRAConnectionRequestInfo cri, ActiveMQResourceAdapter ra, java.lang.String userName, java.lang.String password)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectionEventListener(javax.resource.spi.ConnectionEventListener l)Add a connection event listener.voidassociateConnection(java.lang.Object obj)Move a handler from one mc to this one.voidcheckTransactionActive()voidcleanup()Cleanupvoiddestroy()Destroy the physical connection.java.lang.ObjectgetConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)Get a connectionorg.apache.activemq.artemis.jms.client.ActiveMQConnectionFactorygetConnectionFactory()protected ActiveMQRAConnectionRequestInfogetCRI()Get the request info for this connection.javax.resource.spi.LocalTransactiongetLocalTransaction()Get the location transaction for the connection.java.io.PrintWritergetLogWriter()Get the log writer -- NOT SUPPORTEDprotected ActiveMQRAManagedConnectionFactorygetManagedConnectionFactory()Get the connection factory for this connection.javax.resource.spi.ManagedConnectionMetaDatagetMetaData()Get the meta data for the connection.protected javax.jms.SessiongetSession()Get the session for this connection.protected java.lang.StringgetUserName()Get the user namejavax.transaction.xa.XAResourcegetXAResource()Get the XAResource for the connection.protected voidlock()Aqquire a lock on the managed connectionvoidonException(javax.jms.JMSException exception)Notifies user of a JMS exception.voidremoveConnectionEventListener(javax.resource.spi.ConnectionEventListener l)Remove a connection event listener.protected voidremoveHandle(ActiveMQRASession handle)Remove a handle from the handle map.protected voidsendEvent(javax.resource.spi.ConnectionEvent event)Send an event.protected voidsetInManagedTx(boolean inManagedTx)voidsetLogWriter(java.io.PrintWriter out)Set the log writer -- NOT SUPPORTEDprotected voidtryLock()Aqquire a lock on the managed connection within the specified periodprotected voidunlock()Unlock the managed connection
-
-
-
Constructor Detail
-
ActiveMQRAManagedConnection
public ActiveMQRAManagedConnection(ActiveMQRAManagedConnectionFactory mcf, ActiveMQRAConnectionRequestInfo cri, ActiveMQResourceAdapter ra, java.lang.String userName, java.lang.String password) throws javax.resource.ResourceException
Constructor- Parameters:
mcf- The managed connection factorycri- The connection request informationuserName- The user namepassword- The password- Throws:
javax.resource.ResourceException
-
-
Method Detail
-
getConnection
public java.lang.Object getConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo) throws javax.resource.ResourceExceptionGet a connection- Specified by:
getConnectionin interfacejavax.resource.spi.ManagedConnection- Parameters:
subject- The security subjectcxRequestInfo- The request info- Returns:
- The connection
- Throws:
javax.resource.ResourceException- Thrown if an error occurs
-
destroy
public void destroy() throws javax.resource.ResourceExceptionDestroy the physical connection.- Specified by:
destroyin interfacejavax.resource.spi.ManagedConnection- Throws:
javax.resource.ResourceException- Could not property close the session and connection.
-
cleanup
public void cleanup() throws javax.resource.ResourceExceptionCleanup- Specified by:
cleanupin interfacejavax.resource.spi.ManagedConnection- Throws:
javax.resource.ResourceException- Thrown if an error occurs
-
associateConnection
public void associateConnection(java.lang.Object obj) throws javax.resource.ResourceExceptionMove a handler from one mc to this one.- Specified by:
associateConnectionin interfacejavax.resource.spi.ManagedConnection- Parameters:
obj- An object of type ActiveMQSession.- Throws:
javax.resource.ResourceException- Failed to associate connection.javax.resource.spi.IllegalStateException- ManagedConnection in an illegal state.
-
checkTransactionActive
public void checkTransactionActive() throws javax.jms.JMSException- Throws:
javax.jms.JMSException
-
lock
protected void lock()
Aqquire a lock on the managed connection
-
tryLock
protected void tryLock() throws javax.jms.JMSExceptionAqquire a lock on the managed connection within the specified period- Throws:
javax.jms.JMSException- Thrown if an error occurs
-
unlock
protected void unlock()
Unlock the managed connection
-
addConnectionEventListener
public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener l)
Add a connection event listener.- Specified by:
addConnectionEventListenerin interfacejavax.resource.spi.ManagedConnection- Parameters:
l- The connection event listener to be added.
-
removeConnectionEventListener
public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener l)
Remove a connection event listener.- Specified by:
removeConnectionEventListenerin interfacejavax.resource.spi.ManagedConnection- Parameters:
l- The connection event listener to be removed.
-
getXAResource
public javax.transaction.xa.XAResource getXAResource() throws javax.resource.ResourceExceptionGet the XAResource for the connection.- Specified by:
getXAResourcein interfacejavax.resource.spi.ManagedConnection- Returns:
- The XAResource for the connection.
- Throws:
javax.resource.ResourceException- XA transaction not supported
-
getLocalTransaction
public javax.resource.spi.LocalTransaction getLocalTransaction() throws javax.resource.ResourceExceptionGet the location transaction for the connection.- Specified by:
getLocalTransactionin interfacejavax.resource.spi.ManagedConnection- Returns:
- The local transaction for the connection.
- Throws:
javax.resource.ResourceException- Thrown if operation fails.
-
getMetaData
public javax.resource.spi.ManagedConnectionMetaData getMetaData() throws javax.resource.ResourceExceptionGet the meta data for the connection.- Specified by:
getMetaDatain interfacejavax.resource.spi.ManagedConnection- Returns:
- The meta data for the connection.
- Throws:
javax.resource.ResourceException- Thrown if the operation fails.javax.resource.spi.IllegalStateException- Thrown if the managed connection already is destroyed.
-
setLogWriter
public void setLogWriter(java.io.PrintWriter out) throws javax.resource.ResourceExceptionSet the log writer -- NOT SUPPORTED- Specified by:
setLogWriterin interfacejavax.resource.spi.ManagedConnection- Parameters:
out- The log writer- Throws:
javax.resource.ResourceException- If operation fails
-
getLogWriter
public java.io.PrintWriter getLogWriter() throws javax.resource.ResourceExceptionGet the log writer -- NOT SUPPORTED- Specified by:
getLogWriterin interfacejavax.resource.spi.ManagedConnection- Returns:
- Always null
- Throws:
javax.resource.ResourceException- If operation fails
-
onException
public void onException(javax.jms.JMSException exception)
Notifies user of a JMS exception.- Specified by:
onExceptionin interfacejavax.jms.ExceptionListener- Parameters:
exception- The JMS exception
-
getSession
protected javax.jms.Session getSession() throws javax.jms.JMSExceptionGet the session for this connection.- Returns:
- The session
- Throws:
javax.jms.JMSException
-
sendEvent
protected void sendEvent(javax.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 java.lang.String getUserName()
Get the user name- Returns:
- The user name
-
setInManagedTx
protected void setInManagedTx(boolean inManagedTx)
-
getConnectionFactory
public org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory getConnectionFactory()
-
-