activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r666887 - /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnection.java
Date Wed, 11 Jun 2008 23:13:59 GMT
Author: rajdavies
Date: Wed Jun 11 16:13:59 2008
New Revision: 666887

URL: http://svn.apache.org/viewvc?rev=666887&view=rev
Log:
Fix for https://issues.apache.org/activemq/browse/AMQ-1777

Modified:
    activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnection.java

Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnection.java?rev=666887&r1=666886&r2=666887&view=diff
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnection.java
(original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnection.java
Wed Jun 11 16:13:59 2008
@@ -17,9 +17,9 @@
 package org.apache.activemq.ra;
 
 import java.io.PrintWriter;
-import java.util.ArrayList;
 import java.util.Iterator;
-
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 import javax.jms.Connection;
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
@@ -32,7 +32,6 @@
 import javax.resource.spi.ManagedConnectionMetaData;
 import javax.security.auth.Subject;
 import javax.transaction.xa.XAResource;
-
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.LocalTransactionEventListener;
 import org.apache.activemq.TransactionContext;
@@ -63,8 +62,8 @@
 
     private final ActiveMQConnection physicalConnection;
     private final TransactionContext transactionContext;
-    private final ArrayList<ManagedConnectionProxy> proxyConnections = new ArrayList<ManagedConnectionProxy>();
-    private final ArrayList<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
+    private final List<ManagedConnectionProxy> proxyConnections = new CopyOnWriteArrayList<ManagedConnectionProxy>();
+    private final List<ConnectionEventListener> listeners = new CopyOnWriteArrayList<ConnectionEventListener>();
     private final LocalAndXATransaction localAndXATransaction;
 
     private Subject subject;
@@ -81,9 +80,7 @@
             this.localAndXATransaction = new LocalAndXATransaction(transactionContext) {
                 public void setInManagedTx(boolean inManagedTx) throws JMSException {
                     super.setInManagedTx(inManagedTx);
-                    Iterator<ManagedConnectionProxy> iterator = proxyConnections.iterator();
-                    while (iterator.hasNext()) {
-                        ManagedConnectionProxy proxy = iterator.next();
+                    for (ManagedConnectionProxy proxy:proxyConnections) {
                         proxy.setUseSharedTxContext(inManagedTx);
                     }
                 }
@@ -145,27 +142,21 @@
 
     private void fireBeginEvent() {
         ConnectionEvent event = new ConnectionEvent(ActiveMQManagedConnection.this, ConnectionEvent.LOCAL_TRANSACTION_STARTED);
-        Iterator<ConnectionEventListener> iterator = listeners.iterator();
-        while (iterator.hasNext()) {
-            ConnectionEventListener l = iterator.next();
+        for(ConnectionEventListener l:listeners) {
             l.localTransactionStarted(event);
         }
     }
 
     private void fireCommitEvent() {
         ConnectionEvent event = new ConnectionEvent(ActiveMQManagedConnection.this, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
-        Iterator<ConnectionEventListener> iterator = listeners.iterator();
-        while (iterator.hasNext()) {
-            ConnectionEventListener l = iterator.next();
+        for(ConnectionEventListener l:listeners) {
             l.localTransactionCommitted(event);
         }
     }
 
     private void fireRollbackEvent() {
         ConnectionEvent event = new ConnectionEvent(ActiveMQManagedConnection.this, ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
-        Iterator<ConnectionEventListener> iterator = listeners.iterator();
-        while (iterator.hasNext()) {
-            ConnectionEventListener l = iterator.next();
+        for(ConnectionEventListener l:listeners) {
             l.localTransactionRolledback(event);
         }
     }
@@ -174,18 +165,14 @@
         ConnectionEvent event = new ConnectionEvent(ActiveMQManagedConnection.this, ConnectionEvent.CONNECTION_CLOSED);
         event.setConnectionHandle(proxy);
 
-        Iterator<ConnectionEventListener> iterator = listeners.iterator();
-        while (iterator.hasNext()) {
-            ConnectionEventListener l = iterator.next();
+        for(ConnectionEventListener l:listeners) {
             l.connectionClosed(event);
         }
     }
 
     private void fireErrorOccurredEvent(Exception error) {
         ConnectionEvent event = new ConnectionEvent(ActiveMQManagedConnection.this, ConnectionEvent.CONNECTION_ERROR_OCCURRED,
error);
-        Iterator<ConnectionEventListener> iterator = listeners.iterator();
-        while (iterator.hasNext()) {
-            ConnectionEventListener l = iterator.next();
+        for(ConnectionEventListener l:listeners) {
             l.connectionErrorOccurred(event);
         }
     }
@@ -238,9 +225,7 @@
             return;
         }
 
-        Iterator<ManagedConnectionProxy> iterator = proxyConnections.iterator();
-        while (iterator.hasNext()) {
-            ManagedConnectionProxy proxy = iterator.next();
+        for (ManagedConnectionProxy proxy:proxyConnections) {
             proxy.cleanup();
         }
         proxyConnections.clear();
@@ -399,9 +384,7 @@
         LOG.warn("Connection failed: " + e);
         LOG.debug("Cause: ", e);
 
-        // Let any active proxy connections know that exception occured.
-        for (Iterator<ManagedConnectionProxy> iter = proxyConnections.iterator(); iter.hasNext();)
{
-            ManagedConnectionProxy proxy = iter.next();
+        for (ManagedConnectionProxy proxy:proxyConnections) {
             proxy.onException(e);
         }
         // Let the container know that the error occured.



Mime
View raw message