Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.ra
Class ActiveMQManagedConnection  view ActiveMQManagedConnection download ActiveMQManagedConnection.java

java.lang.Object
  extended byorg.activemq.ra.ActiveMQManagedConnection
All Implemented Interfaces:
javax.jms.ExceptionListener, javax.resource.spi.ManagedConnection

public class ActiveMQManagedConnection
extends java.lang.Object
implements javax.resource.spi.ManagedConnection, javax.jms.ExceptionListener

ActiveMQManagedConnection maps to real physical connection to the server. Since a ManagedConnection has to provide a transaction managment interface to the physical connection, and sessions are the objects implement transaction managment interfaces in the JMS API, this object also maps to a singe physical JMS session.

The side-effect is that JMS connection the application gets will allways create the same session object. This is good if running in an app server since the sessions are elisted in the context transaction. This is bad if used outside of an app server since the user may be trying to create 2 different sessions to coordinate 2 different uow.

Version:
$Revision: 1.1.1.1 $

Field Summary
private  boolean destoryed
           
private  ActiveMQConnectionRequestInfo info
           
private  java.util.ArrayList listeners
           
private  LocalAndXATransaction localAndXATransaction
           
private static org.apache.commons.logging.Log log
           
private  java.io.PrintWriter logWriter
           
private  org.activemq.ActiveMQConnection physicalConnection
           
private  java.util.ArrayList proxyConnections
           
private  javax.security.auth.Subject subject
           
private  org.activemq.TransactionContext transactionContext
           
 
Constructor Summary
ActiveMQManagedConnection(javax.security.auth.Subject subject, org.activemq.ActiveMQConnection physicalConnection, ActiveMQConnectionRequestInfo info)
           
 
Method Summary
 void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
           
 void associate(javax.security.auth.Subject subject, ActiveMQConnectionRequestInfo info)
           
 void associateConnection(java.lang.Object connection)
           
 void cleanup()
          Cleans up all proxy handles attached to this physical connection so that they cannot be used anymore.
 void destroy()
          Close down the physical connection to the server.
private  void fireBeginEvent()
           
private  void fireCloseEvent(JMSConnectionProxy proxy)
           
private  void fireCommitEvent()
           
private  void fireErrorOccurredEvent(java.lang.Exception error)
           
private  void fireRollbackEvent()
           
 java.lang.Object getConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo info)
           
 javax.resource.spi.LocalTransaction getLocalTransaction()
           
 java.io.PrintWriter getLogWriter()
           
 javax.resource.spi.ManagedConnectionMetaData getMetaData()
           
 javax.jms.Connection getPhysicalConnection()
           
 org.activemq.TransactionContext getTransactionContext()
           
 javax.transaction.xa.XAResource getXAResource()
           
private  boolean isDestroyed()
           
 boolean isInManagedTx()
           
static boolean matches(java.lang.Object x, java.lang.Object y)
           
 boolean matches(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo info)
           
 void onException(javax.jms.JMSException e)
           
 void proxyClosedEvent(JMSConnectionProxy proxy)
          When a proxy is closed this cleans up the proxy and notifys the ConnectionEventListeners that a connection closed.
 void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
           
 void setLogWriter(java.io.PrintWriter logWriter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

logWriter

private java.io.PrintWriter logWriter

physicalConnection

private final org.activemq.ActiveMQConnection physicalConnection

transactionContext

private final org.activemq.TransactionContext transactionContext

proxyConnections

private final java.util.ArrayList proxyConnections

listeners

private final java.util.ArrayList listeners

localAndXATransaction

private final LocalAndXATransaction localAndXATransaction

subject

private javax.security.auth.Subject subject

info

private ActiveMQConnectionRequestInfo info

destoryed

private boolean destoryed
Constructor Detail

ActiveMQManagedConnection

public ActiveMQManagedConnection(javax.security.auth.Subject subject,
                                 org.activemq.ActiveMQConnection physicalConnection,
                                 ActiveMQConnectionRequestInfo info)
                          throws javax.resource.ResourceException
Method Detail

isInManagedTx

public boolean isInManagedTx()

matches

public static boolean matches(java.lang.Object x,
                              java.lang.Object y)

associate

public void associate(javax.security.auth.Subject subject,
                      ActiveMQConnectionRequestInfo info)
               throws javax.jms.JMSException

getPhysicalConnection

public javax.jms.Connection getPhysicalConnection()

fireBeginEvent

private void fireBeginEvent()

fireCommitEvent

private void fireCommitEvent()

fireRollbackEvent

private void fireRollbackEvent()

fireCloseEvent

private void fireCloseEvent(JMSConnectionProxy proxy)

fireErrorOccurredEvent

private void fireErrorOccurredEvent(java.lang.Exception error)

getConnection

public java.lang.Object getConnection(javax.security.auth.Subject subject,
                                      javax.resource.spi.ConnectionRequestInfo info)
                               throws javax.resource.ResourceException
Specified by:
getConnection in interface javax.resource.spi.ManagedConnection

isDestroyed

private boolean isDestroyed()

destroy

public void destroy()
             throws javax.resource.ResourceException
Close down the physical connection to the server.

Specified by:
destroy in interface javax.resource.spi.ManagedConnection

cleanup

public void cleanup()
             throws javax.resource.ResourceException
Cleans up all proxy handles attached to this physical connection so that they cannot be used anymore.

Specified by:
cleanup in interface javax.resource.spi.ManagedConnection

associateConnection

public void associateConnection(java.lang.Object connection)
                         throws javax.resource.ResourceException
Specified by:
associateConnection in interface javax.resource.spi.ManagedConnection

addConnectionEventListener

public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Specified by:
addConnectionEventListener in interface javax.resource.spi.ManagedConnection

removeConnectionEventListener

public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Specified by:
removeConnectionEventListener in interface javax.resource.spi.ManagedConnection

getXAResource

public javax.transaction.xa.XAResource getXAResource()
                                              throws javax.resource.ResourceException
Specified by:
getXAResource in interface javax.resource.spi.ManagedConnection

getLocalTransaction

public javax.resource.spi.LocalTransaction getLocalTransaction()
                                                        throws javax.resource.ResourceException
Specified by:
getLocalTransaction in interface javax.resource.spi.ManagedConnection

getMetaData

public javax.resource.spi.ManagedConnectionMetaData getMetaData()
                                                         throws javax.resource.ResourceException
Specified by:
getMetaData in interface javax.resource.spi.ManagedConnection

setLogWriter

public void setLogWriter(java.io.PrintWriter logWriter)
                  throws javax.resource.ResourceException
Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnection

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws javax.resource.ResourceException
Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnection

matches

public boolean matches(javax.security.auth.Subject subject,
                       javax.resource.spi.ConnectionRequestInfo info)

proxyClosedEvent

public void proxyClosedEvent(JMSConnectionProxy proxy)
When a proxy is closed this cleans up the proxy and notifys the ConnectionEventListeners that a connection closed.


onException

public void onException(javax.jms.JMSException e)
Specified by:
onException in interface javax.jms.ExceptionListener

getTransactionContext

public org.activemq.TransactionContext getTransactionContext()