You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2007/10/17 19:56:59 UTC

svn commit: r585608 - in /geronimo/components/txmanager/trunk/geronimo-connector/src: main/java/org/apache/geronimo/connector/outbound/ main/java/org/apache/geronimo/connector/outbound/connectiontracking/ main/java/org/apache/geronimo/connector/work/po...

Author: dain
Date: Wed Oct 17 10:56:54 2007
New Revision: 585608

URL: http://svn.apache.org/viewvc?rev=585608&view=rev
Log:
Added generic types to all collections usage

Modified:
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GeronimoConnectionEventListener.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolMatchAllConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContext.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContextImpl.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/WorkExecutorPoolImpl.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorProxyTest.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java Wed Oct 17 10:56:54 2007
@@ -17,9 +17,9 @@
 package org.apache.geronimo.connector.outbound;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.List;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.ReadWriteLock;
@@ -269,7 +269,7 @@
         }
     }
 
-    protected abstract void getExpiredManagedConnectionInfos(long threshold, ArrayList killList);
+    protected abstract void getExpiredManagedConnectionInfos(long threshold, List<ManagedConnectionInfo> killList);
 
     protected abstract boolean addToPool(ManagedConnectionInfo mci);
 
@@ -296,10 +296,9 @@
             interceptor.resizeLock.readLock().lock();
             try {
                 long threshold = System.currentTimeMillis() - interceptor.idleTimeoutMilliseconds;
-                ArrayList killList = new ArrayList(interceptor.getPartitionMaxSize());
+                List<ManagedConnectionInfo> killList = new ArrayList<ManagedConnectionInfo>(interceptor.getPartitionMaxSize());
                 interceptor.getExpiredManagedConnectionInfos(threshold, killList);
-                for (Iterator i = killList.iterator(); i.hasNext();) {
-                    ManagedConnectionInfo managedConnectionInfo = (ManagedConnectionInfo) i.next();
+                for (ManagedConnectionInfo managedConnectionInfo : killList) {
                     ConnectionInfo killInfo = new ConnectionInfo(managedConnectionInfo);
                     interceptor.internalReturn(killInfo, ConnectionReturnAction.DESTROY);
                 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java Wed Oct 17 10:56:54 2007
@@ -27,14 +27,12 @@
  * @version 1.0
  */
 public class ConnectionReturnAction {
-
     public final static ConnectionReturnAction RETURN_HANDLE =
             new ConnectionReturnAction();
     public final static ConnectionReturnAction DESTROY =
             new ConnectionReturnAction();
 
     private ConnectionReturnAction() {
+    }
 
-    } // ConnectionReturnAction constructor
-
-} // ConnectionReturnAction
+}

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java Wed Oct 17 10:56:54 2007
@@ -95,19 +95,17 @@
         next.destroy();
     }
     
-    public void enter(Collection connectionInfos)
-            throws ResourceException {
-        for (Iterator i = connectionInfos.iterator(); i.hasNext();) {
-            ConnectionInfo connectionInfo = (ConnectionInfo) i.next();
+    public void enter(Collection<ConnectionInfo> connectionInfos) throws ResourceException {
+        for (ConnectionInfo connectionInfo : connectionInfos) {
             next.getConnection(connectionInfo);
         }
 
     }
 
-    public void exit(Collection connectionInfos)
+    public void exit(Collection<ConnectionInfo> connectionInfos)
             throws ResourceException {
-        for (Iterator i = connectionInfos.iterator(); i.hasNext();) {
-            ConnectionInfo connectionInfo = (ConnectionInfo) i.next();
+        for (Iterator<ConnectionInfo> iterator = connectionInfos.iterator(); iterator.hasNext();) {
+            ConnectionInfo connectionInfo = iterator.next();
             if (connectionInfo.isUnshareable()) {
                 //if one is, they all are
                 return;
@@ -116,7 +114,7 @@
             ManagedConnection managedConnection = managedConnectionInfo.getManagedConnection();
             if (managedConnection instanceof DissociatableManagedConnection
                     && managedConnectionInfo.isFirstConnectionInfo(connectionInfo)) {
-                i.remove();
+                iterator.remove();
                 ((DissociatableManagedConnection) managedConnection).dissociateConnections();
                 managedConnectionInfo.clearConnectionHandles();
                 //todo this needs some kind of check so cx isn't returned more than once

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GeronimoConnectionEventListener.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GeronimoConnectionEventListener.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GeronimoConnectionEventListener.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GeronimoConnectionEventListener.java Wed Oct 17 10:56:54 2007
@@ -42,7 +42,7 @@
 
     private final ManagedConnectionInfo managedConnectionInfo;
     private final ConnectionInterceptor stack;
-    private final List connectionInfos = new ArrayList();
+    private final List<ConnectionInfo> connectionInfos = new ArrayList<ConnectionInfo>();
     private boolean errorOccurred = false;
 
     public GeronimoConnectionEventListener(
@@ -143,7 +143,7 @@
         return !connectionInfos.isEmpty() && connectionInfos.get(0) == connectionInfo;
     }
 
-    public Collection getConnectionInfos() {
+    public Collection<ConnectionInfo> getConnectionInfos() {
         return Collections.unmodifiableCollection(connectionInfos);
     }
 

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java Wed Oct 17 10:56:54 2007
@@ -129,7 +129,7 @@
         listener.clearConnectionInfos();
     }
 
-    public Collection getConnectionInfos() {
+    public Collection<ConnectionInfo> getConnectionInfos() {
         return listener.getConnectionInfos();
     }
 

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java Wed Oct 17 10:56:54 2007
@@ -18,7 +18,6 @@
 package org.apache.geronimo.connector.outbound;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.resource.ResourceException;
@@ -45,7 +44,7 @@
 
     private final boolean useCRI;
 
-    private final Map pools = new HashMap();
+    private final Map<SubjectCRIKey,PoolingAttributes> pools = new HashMap<SubjectCRIKey,PoolingAttributes>();
 
     // volatile is not necessary, here, because of synchronization. but maintained for consistency with other Interceptors...
     private volatile boolean destroyed = false;
@@ -75,7 +74,7 @@
             poolInterceptor = (ConnectionInterceptor) pools.get(key);
             if (poolInterceptor == null) {
                 poolInterceptor = singlePoolFactory.addPoolingInterceptors(next);
-                pools.put(key, poolInterceptor);
+                pools.put(key, (PoolingAttributes) poolInterceptor);
             }
         }
         mci.setPoolInterceptor(poolInterceptor);
@@ -94,10 +93,11 @@
     public void destroy() {
         synchronized (pools) {
             destroyed = true;
-            for (Iterator it = pools.entrySet().iterator(); it.hasNext(); ) {
-                ((ConnectionInterceptor)((Map.Entry)it.next()).getValue()).destroy();
-                it.remove();
+            for (PoolingAttributes poolingAttributes : pools.values()) {
+                ConnectionInterceptor poolInterceptor = (ConnectionInterceptor) poolingAttributes;
+                poolInterceptor.destroy();
             }
+            pools.clear();
         }
         next.destroy();
     }
@@ -112,8 +112,7 @@
 
     public void setPartitionMaxSize(int maxSize) throws InterruptedException {
         singlePoolFactory.setPartitionMaxSize(maxSize);
-        for (Iterator iterator = pools.entrySet().iterator(); iterator.hasNext();) {
-            PoolingAttributes poolingAttributes = (PoolingAttributes) ((Map.Entry) iterator.next()).getValue();
+        for (PoolingAttributes poolingAttributes : pools.values()) {
             poolingAttributes.setPartitionMaxSize(maxSize);
         }
     }
@@ -124,16 +123,14 @@
 
     public void setPartitionMinSize(int minSize) {
         singlePoolFactory.setPartitionMinSize(minSize);
-        for (Iterator iterator = pools.entrySet().iterator(); iterator.hasNext();) {
-            PoolingAttributes poolingAttributes = (PoolingAttributes) ((Map.Entry) iterator.next()).getValue();
+        for (PoolingAttributes poolingAttributes : pools.values()) {
             poolingAttributes.setPartitionMinSize(minSize);
         }
     }
 
     public int getIdleConnectionCount() {
         int count = 0;
-        for (Iterator iterator = pools.entrySet().iterator(); iterator.hasNext();) {
-            PoolingAttributes poolingAttributes = (PoolingAttributes) ((Map.Entry) iterator.next()).getValue();
+        for (PoolingAttributes poolingAttributes : pools.values()) {
             count += poolingAttributes.getIdleConnectionCount();
         }
         return count;
@@ -141,8 +138,7 @@
 
     public int getConnectionCount() {
         int count = 0;
-        for (Iterator iterator = pools.entrySet().iterator(); iterator.hasNext();) {
-            PoolingAttributes poolingAttributes = (PoolingAttributes) ((Map.Entry) iterator.next()).getValue();
+        for (PoolingAttributes poolingAttributes : pools.values()) {
             count += poolingAttributes.getConnectionCount();
         }
         return count;
@@ -154,8 +150,7 @@
 
     public void setBlockingTimeoutMilliseconds(int timeoutMilliseconds) {
         singlePoolFactory.setBlockingTimeoutMilliseconds(timeoutMilliseconds);
-        for (Iterator iterator = pools.entrySet().iterator(); iterator.hasNext();) {
-            PoolingAttributes poolingAttributes = (PoolingAttributes) ((Map.Entry) iterator.next()).getValue();
+        for (PoolingAttributes poolingAttributes : pools.values()) {
             poolingAttributes.setBlockingTimeoutMilliseconds(timeoutMilliseconds);
         }
     }
@@ -166,8 +161,7 @@
 
     public void setIdleTimeoutMinutes(int idleTimeoutMinutes) {
         singlePoolFactory.setIdleTimeoutMinutes(idleTimeoutMinutes);
-        for (Iterator iterator = pools.entrySet().iterator(); iterator.hasNext();) {
-            PoolingAttributes poolingAttributes = (PoolingAttributes) ((Map.Entry) iterator.next()).getValue();
+        for (PoolingAttributes poolingAttributes : pools.values()) {
             poolingAttributes.setIdleTimeoutMinutes(idleTimeoutMinutes);
         }
     }
@@ -194,15 +188,11 @@
         public boolean equals(Object other) {
             if (!(other instanceof SubjectCRIKey)) {
                 return false;
-            } // end of if ()
+            }
             SubjectCRIKey o = (SubjectCRIKey) other;
-            if (hashcode != o.hashcode) {
-                return false;
-            } // end of if ()
-            return subject == null
-                    ? o.subject == null
-                    : subject.equals(o.subject)
-                    && cri == null ? o.cri == null : cri.equals(o.cri);
+            return hashcode == o.hashcode &&
+                    (subject == null ? o.subject == null : subject.equals(o.subject) && 
+                    cri == null ? o.cri == null : cri.equals(o.cri));
         }
     }
-} // MultiPoolConnectionInterceptor
+}

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java Wed Oct 17 10:56:54 2007
@@ -17,9 +17,9 @@
 
 package org.apache.geronimo.connector.outbound;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.List;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnection;
@@ -96,7 +96,6 @@
                     if (log.isTraceEnabled()) {
                         log.trace("Supplying pooled connection  MCI: " + connectionInfo.getManagedConnectionInfo() + " MC: " + connectionInfo.getManagedConnectionInfo().getManagedConnection() + " from pool: " + this);
                     }
-                    return;
                 } else {
                     //matching failed.
                     ConnectionInfo returnCI = new ConnectionInfo();
@@ -194,7 +193,7 @@
     }
 
 
-    protected void getExpiredManagedConnectionInfos(long threshold, ArrayList killList) {
+    protected void getExpiredManagedConnectionInfos(long threshold, List<ManagedConnectionInfo> killList) {
         synchronized (pool) {
             for (int i = 0; i < pool.currentSize(); i++) {
                 ManagedConnectionInfo mci = pool.peek(i);

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolMatchAllConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolMatchAllConnectionInterceptor.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolMatchAllConnectionInterceptor.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolMatchAllConnectionInterceptor.java Wed Oct 17 10:56:54 2007
@@ -17,10 +17,10 @@
 
 package org.apache.geronimo.connector.outbound;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.List;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnection;
@@ -37,9 +37,9 @@
  */
 public class SinglePoolMatchAllConnectionInterceptor extends AbstractSinglePoolConnectionInterceptor {
 
-    private HashMap pool;
+    private Map<ManagedConnection, ManagedConnectionInfo> pool;
 
-    private int maxSize;
+    private final int maxSize;
 
     public SinglePoolMatchAllConnectionInterceptor(final ConnectionInterceptor next,
                                                    int maxSize,
@@ -49,7 +49,7 @@
 
         super(next, maxSize, minSize, blockingTimeoutMilliseconds, idleTimeoutMinutes);
         this.maxSize = maxSize;
-        pool = new HashMap(maxSize);
+        pool = new HashMap<ManagedConnection, ManagedConnectionInfo>(maxSize);
     }
 
     protected void internalGetConnection(ConnectionInfo connectionInfo) throws ResourceException {
@@ -67,7 +67,7 @@
                                     mci.getSubject(),
                                     mci.getConnectionRequestInfo());
                     if (matchedMC != null) {
-                        connectionInfo.setManagedConnectionInfo((ManagedConnectionInfo) pool.get(matchedMC));
+                        connectionInfo.setManagedConnectionInfo(pool.get(matchedMC));
                         pool.remove(matchedMC);
                         if (log.isTraceEnabled()) {
                             log.trace("Returning pooled connection " + connectionInfo.getManagedConnectionInfo());
@@ -143,14 +143,13 @@
 
     protected void internalDestroy() {
         synchronized (pool) {
-            Iterator it = pool.keySet().iterator();
-            for (; it.hasNext(); ) {
+            for (ManagedConnection managedConnection : pool.keySet()) {
                 try {
-                    ((ManagedConnection)it.next()).destroy();
+                    managedConnection.destroy();
+                } catch (ResourceException ignore) {
                 }
-                catch (ResourceException re) { } // ignore
-                it.remove();
             }
+            pool.clear();
         }
     }
 
@@ -159,33 +158,35 @@
     }
 
     public int getIdleConnectionCount() {
-        return pool.size();
+        synchronized (pool) {
+            return pool.size();
+        }
     }
 
     protected void transferConnections(int maxSize, int shrinkNow) {
         //1st example: copy 0 (none)
         //2nd example: copy 10 (all)
-        HashMap oldPool = pool;
-        pool = new HashMap(maxSize);
-        //since we have replaced pool already, pool.remove will be very fast:-)
-        assert oldPool.size() == connectionCount;
-        Iterator it = oldPool.entrySet().iterator();
-        for (int i = 0; i < shrinkNow; i++) {
-            ConnectionInfo killInfo = new ConnectionInfo((ManagedConnectionInfo) ((Map.Entry)it.next()).getValue());
-            internalReturn(killInfo, ConnectionReturnAction.DESTROY);
-        }
-        for (; it.hasNext(); ) {
-            Map.Entry entry = (Map.Entry) it.next();
-            pool.put(entry.getKey(), entry.getValue());
+        synchronized (pool) {
+            Map<ManagedConnection, ManagedConnectionInfo> oldPool = pool;
+            Map<ManagedConnection, ManagedConnectionInfo> newPool = new HashMap<ManagedConnection, ManagedConnectionInfo>(maxSize);
+            //since we have replaced pool already, pool.remove will be very fast:-)
+            assert oldPool.size() == connectionCount;
+            Iterator<Map.Entry<ManagedConnection, ManagedConnectionInfo>> it = oldPool.entrySet().iterator();
+            for (int i = 0; i < shrinkNow; i++) {
+                ConnectionInfo killInfo = new ConnectionInfo((ManagedConnectionInfo) ((Map.Entry)it.next()).getValue());
+                internalReturn(killInfo, ConnectionReturnAction.DESTROY);
+            }
+            for (; it.hasNext(); ) {
+                Map.Entry<ManagedConnection, ManagedConnectionInfo> entry = it.next();
+                newPool.put(entry.getKey(), entry.getValue());
+            }
+            pool = newPool;
         }
-
     }
 
-    protected void getExpiredManagedConnectionInfos(long threshold, ArrayList killList) {
+    protected void getExpiredManagedConnectionInfos(long threshold, List<ManagedConnectionInfo> killList) {
         synchronized (pool) {
-            for (Iterator iterator = pool.entrySet().iterator(); iterator.hasNext();) {
-                Map.Entry entry = (Map.Entry) iterator.next();
-                ManagedConnectionInfo mci = (ManagedConnectionInfo) entry.getValue();
+            for (ManagedConnectionInfo mci : pool.values()) {
                 if (mci.getLastUsed() < threshold) {
                     killList.add(mci);
                 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java Wed Oct 17 10:56:54 2007
@@ -31,7 +31,7 @@
 
     private final ConnectionInterceptor next;
 
-    private final ThreadLocal connections = new ThreadLocal();
+    private final ThreadLocal<ManagedConnectionInfo> connections = new ThreadLocal<ManagedConnectionInfo>();
     private final boolean matchConnections;
 
     public ThreadLocalCachingConnectionInterceptor(final ConnectionInterceptor next, final boolean matchConnections) {
@@ -45,7 +45,7 @@
             next.getConnection(connectionInfo);
             return;
         }
-        ManagedConnectionInfo managedConnectionInfo = (ManagedConnectionInfo) connections.get();
+        ManagedConnectionInfo managedConnectionInfo = connections.get();
         if (managedConnectionInfo != null) {
             if (matchConnections) {
                 ManagedConnectionInfo mciRequest = connectionInfo.getManagedConnectionInfo();

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java Wed Oct 17 10:56:54 2007
@@ -17,9 +17,7 @@
 
 package org.apache.geronimo.connector.outbound;
 
-import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 import javax.resource.ResourceException;
@@ -160,8 +158,7 @@
             }
             returnHandle(sharedMCI);
         }
-        for (Iterator iterator = managedConnectionInfos.getUnshared().iterator(); iterator.hasNext();) {
-            ManagedConnectionInfo managedConnectionInfo = (ManagedConnectionInfo) iterator.next();
+        for (ManagedConnectionInfo managedConnectionInfo : managedConnectionInfos.getUnshared()) {
             if (log.isTraceEnabled()) {
                 log.trace("Transaction completed, attempting to return unshared connection MCI: " + managedConnectionInfo + " for managed connection " + managedConnectionInfo.getManagedConnection() + " to tx caching interceptor " + this);
             }
@@ -177,7 +174,7 @@
 
     public static class ManagedConnectionInfos {
         private ManagedConnectionInfo shared;
-        private Set unshared = Collections.EMPTY_SET;
+        private Set<ManagedConnectionInfo> unshared = new HashSet<ManagedConnectionInfo>(1);
 
         public ManagedConnectionInfo getShared() {
             return shared;
@@ -187,19 +184,16 @@
             this.shared = shared;
         }
 
-        public Set getUnshared() {
+        public Set<ManagedConnectionInfo> getUnshared() {
             return unshared;
         }
 
         public void addUnshared(ManagedConnectionInfo unsharedMCI) {
-            if (this.unshared == Collections.EMPTY_SET) {
-                this.unshared = new HashSet();
-            }
-            this.unshared.add(unsharedMCI);
+            unshared.add(unsharedMCI);
         }
 
         public boolean containsUnshared(ManagedConnectionInfo unsharedMCI) {
-            return this.unshared.contains(unsharedMCI);
+            return unshared.contains(unsharedMCI);
         }
 
         public void remove(ManagedConnectionInfo managedConnectionInfo) {
@@ -210,5 +204,4 @@
             }
         }
     }
-
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java Wed Oct 17 10:56:54 2007
@@ -59,8 +59,8 @@
     private static final Log log = LogFactory.getLog(ConnectionTrackingCoordinator.class.getName());
 
     private final boolean lazyConnect;
-    private final ThreadLocal currentInstanceContexts = new ThreadLocal();
-    private final ConcurrentMap proxiesByConnectionInfo = new ConcurrentHashMap();
+    private final ThreadLocal<ConnectorInstanceContext> currentInstanceContexts = new ThreadLocal<ConnectorInstanceContext>();
+    private final ConcurrentMap<ConnectionInfo,Object> proxiesByConnectionInfo = new ConcurrentHashMap<ConnectionInfo,Object>();
 
     public ConnectionTrackingCoordinator() {
         this(false);
@@ -75,25 +75,23 @@
     }
 
     public ConnectorInstanceContext enter(ConnectorInstanceContext newContext) throws ResourceException {
-        ConnectorInstanceContext oldContext = (ConnectorInstanceContext) currentInstanceContexts.get();
+        ConnectorInstanceContext oldContext = currentInstanceContexts.get();
         currentInstanceContexts.set(newContext);
         associateConnections(newContext);
         return oldContext;
     }
 
     private void associateConnections(ConnectorInstanceContext context) throws ResourceException {
-            Map connectionManagerToManagedConnectionInfoMap = context.getConnectionManagerMap();
-            for (Iterator i = connectionManagerToManagedConnectionInfoMap.entrySet().iterator(); i.hasNext();) {
-                Map.Entry entry = (Map.Entry) i.next();
-                ConnectionTrackingInterceptor mcci =
-                        (ConnectionTrackingInterceptor) entry.getKey();
-                Set connections = (Set) entry.getValue();
-                mcci.enter(connections);
-            }
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerToManagedConnectionInfoMap = context.getConnectionManagerMap();
+        for (Map.Entry<ConnectionTrackingInterceptor, Set<ConnectionInfo>> entry : connectionManagerToManagedConnectionInfoMap.entrySet()) {
+            ConnectionTrackingInterceptor mcci = entry.getKey();
+            Set<ConnectionInfo> connections = entry.getValue();
+            mcci.enter(connections);
+        }
     }
 
     public void newTransaction() throws ResourceException {
-        ConnectorInstanceContext currentContext = (ConnectorInstanceContext) currentInstanceContexts.get();
+        ConnectorInstanceContext currentContext = currentInstanceContexts.get();
         if (currentContext == null) {
             return;
         }
@@ -101,20 +99,18 @@
     }
 
     public void exit(ConnectorInstanceContext oldContext) throws ResourceException {
-        ConnectorInstanceContext currentContext = (ConnectorInstanceContext) currentInstanceContexts.get();
+        ConnectorInstanceContext currentContext = currentInstanceContexts.get();
         try {
             // for each connection type opened in this componet
-            Map resources = currentContext.getConnectionManagerMap();
-            for (Iterator i = resources.entrySet().iterator(); i.hasNext();) {
-                Map.Entry entry = (Map.Entry) i.next();
-                ConnectionTrackingInterceptor mcci =
-                        (ConnectionTrackingInterceptor) entry.getKey();
-                Set connections = (Set) entry.getValue();
+            Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> resources = currentContext.getConnectionManagerMap();
+            for (Iterator<Map.Entry<ConnectionTrackingInterceptor, Set<ConnectionInfo>>> iterator = resources.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry<ConnectionTrackingInterceptor, Set<ConnectionInfo>> entry = iterator.next();
+                ConnectionTrackingInterceptor mcci = entry.getKey();
+                Set<ConnectionInfo> connections = entry.getValue();
 
                 // release proxy connections
                 if (lazyConnect) {
-                    for (Iterator infoIterator = connections.iterator(); infoIterator.hasNext();) {
-                        ConnectionInfo connectionInfo = (ConnectionInfo) infoIterator.next();
+                    for (ConnectionInfo connectionInfo : connections) {
                         releaseProxyConnection(connectionInfo);
                     }
                 }
@@ -124,7 +120,7 @@
 
                 // if no connection remain clear context... we could support automatic commit, rollback or exception here
                 if (connections.isEmpty()) {
-                    i.remove();
+                    iterator.remove();
                 }
             }
         } finally {
@@ -147,15 +143,15 @@
             ConnectionInfo connectionInfo,
             boolean reassociate) throws ResourceException {
 
-        ConnectorInstanceContext currentContext = (ConnectorInstanceContext) currentInstanceContexts.get();
+        ConnectorInstanceContext currentContext = currentInstanceContexts.get();
         if (currentContext == null) {
             return;
         }
 
-        Map resources = currentContext.getConnectionManagerMap();
-        Set infos = (Set) resources.get(connectionTrackingInterceptor);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> resources = currentContext.getConnectionManagerMap();
+        Set<ConnectionInfo> infos = resources.get(connectionTrackingInterceptor);
         if (infos == null) {
-            infos = new HashSet();
+            infos = new HashSet<ConnectionInfo>();
             resources.put(connectionTrackingInterceptor, infos);
         }
 
@@ -178,18 +174,18 @@
             ConnectionInfo connectionInfo,
             ConnectionReturnAction connectionReturnAction) {
 
-        ConnectorInstanceContext currentContext = (ConnectorInstanceContext) currentInstanceContexts.get();
+        ConnectorInstanceContext currentContext = currentInstanceContexts.get();
         if (currentContext == null) {
             return;
         }
 
-        Map resources = currentContext.getConnectionManagerMap();
-        Set infos = (Set) resources.get(connectionTrackingInterceptor);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> resources = currentContext.getConnectionManagerMap();
+        Set<ConnectionInfo> infos = resources.get(connectionTrackingInterceptor);
         if (infos != null) {
             if (connectionInfo.getConnectionHandle() == null) {
                 //destroy was called as a result of an error
                 ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
-                Collection toRemove = mci.getConnectionInfos();
+                Collection<ConnectionInfo> toRemove = mci.getConnectionInfos();
                 infos.removeAll(toRemove);
             } else {
                 infos.remove(connectionInfo);
@@ -216,15 +212,15 @@
      * @param key the unique id of the connection manager
      */
     public void setEnvironment(ConnectionInfo connectionInfo, String key) {
-        ConnectorInstanceContext currentContext = (ConnectorInstanceContext) currentInstanceContexts.get();
+        ConnectorInstanceContext currentContext = currentInstanceContexts.get();
         if (currentContext != null) {
             // is this resource unshareable in this component context
-            Set unshareableResources = currentContext.getUnshareableResources();
+            Set<String> unshareableResources = currentContext.getUnshareableResources();
             boolean unshareable = unshareableResources.contains(key);
             connectionInfo.setUnshareable(unshareable);
 
             // does this resource use application managed security in this component context
-            Set applicationManagedSecurityResources = currentContext.getApplicationManagedSecurityResources();
+            Set<String> applicationManagedSecurityResources = currentContext.getApplicationManagedSecurityResources();
             boolean applicationManagedSecurity = applicationManagedSecurityResources.contains(key);
             connectionInfo.setApplicationManagedSecurity(applicationManagedSecurity);
         }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContext.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContext.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContext.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContext.java Wed Oct 17 10:56:54 2007
@@ -17,6 +17,9 @@
 
 package org.apache.geronimo.connector.outbound.connectiontracking;
 
+import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
+import org.apache.geronimo.connector.outbound.ConnectionInfo;
+
 import java.util.Map;
 import java.util.Set;
 
@@ -28,9 +31,9 @@
      * IMPORTANT INVARIANT: this should always return a map, never null.
      * @return map of ConnectionManager to (list of ) managed connection info objects.
      */
-    Map getConnectionManagerMap();
+    Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> getConnectionManagerMap();
 
-    Set getUnshareableResources();
+    Set<String> getUnshareableResources();
 
-    Set getApplicationManagedSecurityResources();
+    Set<String> getApplicationManagedSecurityResources();
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContextImpl.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContextImpl.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectorInstanceContextImpl.java Wed Oct 17 10:56:54 2007
@@ -17,6 +17,9 @@
 
 package org.apache.geronimo.connector.outbound.connectiontracking;
 
+import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
+import org.apache.geronimo.connector.outbound.ConnectionInfo;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -29,24 +32,24 @@
  *
  * */
 public class ConnectorInstanceContextImpl implements ConnectorInstanceContext {
-    private final Map connectionManagerMap = new HashMap();
-    private final Set unshareableResources;
-    private final Set applicationManagedSecurityResources;
+    private final Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = new HashMap<ConnectionTrackingInterceptor, Set<ConnectionInfo>>();
+    private final Set<String> unshareableResources;
+    private final Set<String> applicationManagedSecurityResources;
 
-    public ConnectorInstanceContextImpl(Set unshareableResources, Set applicationManagedSecurityResources) {
+    public ConnectorInstanceContextImpl(Set<String> unshareableResources, Set<String> applicationManagedSecurityResources) {
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
     }
 
-    public Map getConnectionManagerMap() {
+    public Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> getConnectionManagerMap() {
         return connectionManagerMap;
     }
 
-    public Set getUnshareableResources() {
+    public Set<String> getUnshareableResources() {
         return unshareableResources;
     }
 
-    public Set getApplicationManagedSecurityResources() {
+    public Set<String> getApplicationManagedSecurityResources() {
         return applicationManagedSecurityResources;
     }
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java Wed Oct 17 10:56:54 2007
@@ -16,6 +16,9 @@
  */
 package org.apache.geronimo.connector.outbound.connectiontracking;
 
+import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
+import org.apache.geronimo.connector.outbound.ConnectionInfo;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -26,18 +29,18 @@
  */
 public class SharedConnectorInstanceContext implements ConnectorInstanceContext {
 
-    private Map connectionManagerMap = new HashMap();
+    private Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = new HashMap<ConnectionTrackingInterceptor, Set<ConnectionInfo>>();
 
-    private final Set unshareableResources;
-    private final Set applicationManagedSecurityResources;
+    private final Set<String> unshareableResources;
+    private final Set<String> applicationManagedSecurityResources;
 
     private boolean hide = false;
 
-    public SharedConnectorInstanceContext(Set unshareableResources, Set applicationManagedSecurityResources, boolean share) {
+    public SharedConnectorInstanceContext(Set<String> unshareableResources, Set<String> applicationManagedSecurityResources, boolean share) {
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
         if (!share) {
-            connectionManagerMap = new HashMap();
+            connectionManagerMap = new HashMap<ConnectionTrackingInterceptor, Set<ConnectionInfo>>();
         }
     }
 
@@ -49,18 +52,18 @@
         this.hide = true;
     }
 
-    public Map getConnectionManagerMap() {
+    public Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> getConnectionManagerMap() {
         if (hide) {
-            return Collections.EMPTY_MAP;
+            return Collections.emptyMap();
         }
         return connectionManagerMap;
     }
 
-    public Set getUnshareableResources() {
+    public Set<String> getUnshareableResources() {
         return unshareableResources;
     }
 
-    public Set getApplicationManagedSecurityResources() {
+    public Set<String> getApplicationManagedSecurityResources() {
         return applicationManagedSecurityResources;
     }
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/WorkExecutorPoolImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/WorkExecutorPoolImpl.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/WorkExecutorPoolImpl.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/WorkExecutorPoolImpl.java Wed Oct 17 10:56:54 2007
@@ -47,7 +47,7 @@
      * @param maxSize Maximum size of the work executor pool.
      */
     public WorkExecutorPoolImpl(int maxSize) {
-        pooledExecutor = new ThreadPoolExecutor(1, maxSize, 60, TimeUnit.SECONDS, new LinkedBlockingQueue());
+        pooledExecutor = new ThreadPoolExecutor(1, maxSize, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
         /*
         FIXME: How to do this with concurrent.util ?
         pooledExecutor.waitWhenBlocked();

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java Wed Oct 17 10:56:54 2007
@@ -66,7 +66,7 @@
                         for (int i = 0; i < repeatCount; i++) {
                             try {
                                 long start = System.currentTimeMillis();
-                                defaultComponentInterceptor.invoke(new ConnectorInstanceContextImpl(new HashSet(), new HashSet()));
+                                defaultComponentInterceptor.invoke(new ConnectorInstanceContextImpl(new HashSet<String>(), new HashSet<String>()));
                                 long duration = System.currentTimeMillis() - start;
                                 if (duration > 100) {
                                     localSlowCount++;

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java Wed Oct 17 10:56:54 2007
@@ -73,8 +73,8 @@
     protected MockManagedConnectionFactory mockManagedConnectionFactory;
     protected ConnectorInstanceContextImpl connectorInstanceContext;
     protected DefaultComponentInterceptor defaultComponentInterceptor;
-    protected Set unshareableResources = new HashSet();
-    protected Set applicationManagedSecurityResources = new HashSet();
+    protected Set<String> unshareableResources = new HashSet<String>();
+    protected Set<String> applicationManagedSecurityResources = new HashSet<String>();
     protected MockManagedConnection mockManagedConnection;
     protected Subject subject;
     protected UserTransaction userTransaction;
@@ -93,6 +93,7 @@
     private ClassLoader classLoader = this.getClass().getClassLoader();
 
     protected void setUp() throws Exception {
+        super.setUp();
         TransactionManagerImpl transactionManager = new TransactionManagerImpl();
         this.transactionManager = transactionManager;
 
@@ -126,6 +127,7 @@
         connectionManagerDeployment = null;
         connectionFactory = null;
         connectorInstanceContext = null;
+        super.tearDown();
     }
 
     public Object invoke(ConnectorInstanceContext newConnectorInstanceContext) throws Throwable {

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorProxyTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorProxyTest.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorProxyTest.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorProxyTest.java Wed Oct 17 10:56:54 2007
@@ -46,8 +46,8 @@
     private ConnectionTrackingCoordinator connectionTrackingCoordinator;
     private ConnectionTrackingInterceptor key1;
     private Subject subject = null;
-    private Set unshareableResources;
-    private Set applicationManagedSecurityResources;
+    private Set<String> unshareableResources;
+    private Set<String> applicationManagedSecurityResources;
     private ManagedConnectionInfo mci;
     private ConnectionImpl connection;
 
@@ -55,8 +55,8 @@
         super.setUp();
         connectionTrackingCoordinator = new ConnectionTrackingCoordinator(true);
         key1 = new ConnectionTrackingInterceptor(this, name1, connectionTrackingCoordinator);
-        unshareableResources = new HashSet();
-        applicationManagedSecurityResources = new HashSet();
+        unshareableResources = new HashSet<String>();
+        applicationManagedSecurityResources = new HashSet<String>();
 
         mci = new ManagedConnectionInfo(null, null);
         mci.setManagedConnection(new MockManagedConnection());
@@ -81,8 +81,8 @@
         connectionTrackingCoordinator.handleObtained(key1, connectionInfo, false);
 
         // connection should be in component instance context
-        Map connectionManagerMap = componentContext.getConnectionManagerMap();
-        Set infos = (Set) connectionManagerMap.get(key1);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = componentContext.getConnectionManagerMap();
+        Set<ConnectionInfo> infos = connectionManagerMap.get(key1);
         assertNotNull("Expected one connections for key1", infos);
         assertEquals("Expected one connection for key1", 1, infos.size());
         assertTrue("Expected to get supplied ConnectionInfo from infos", connectionInfo == infos.iterator().next());
@@ -108,7 +108,7 @@
 
         // connection should not be in context
         connectionManagerMap = componentContext.getConnectionManagerMap();
-        infos = (Set) connectionManagerMap.get(key1);
+        infos = connectionManagerMap.get(key1);
         assertEquals("Expected no connection set for key1", null, infos);
 
         // enter again, and close the handle
@@ -135,8 +135,8 @@
         connectionTrackingCoordinator.handleObtained(key1, connectionInfo, false);
 
         // connection should be in component instance context
-        Map connectionManagerMap = componentContext.getConnectionManagerMap();
-        Set infos = (Set) connectionManagerMap.get(key1);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = componentContext.getConnectionManagerMap();
+        Set<ConnectionInfo> infos = connectionManagerMap.get(key1);
         assertNotNull("Expected one connections for key1", infos);
         assertEquals("Expected one connection for key1", 1, infos.size());
         assertTrue("Expected to get supplied ConnectionInfo from infos", connectionInfo == infos.iterator().next());
@@ -180,7 +180,7 @@
 
         // connection should not be in context
         connectionManagerMap = componentContext.getConnectionManagerMap();
-        infos = (Set) connectionManagerMap.get(key1);
+        infos = connectionManagerMap.get(key1);
         assertNull("Expected no connection set for key1", infos);
 
         // use connection which will cause it to get a new handle if it is not closed
@@ -203,8 +203,8 @@
         connectionTrackingCoordinator.handleObtained(key1, connectionInfo, false);
 
         // connection should be in component instance context
-        Map connectionManagerMap = componentContext.getConnectionManagerMap();
-        Set infos = (Set) connectionManagerMap.get(key1);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = componentContext.getConnectionManagerMap();
+        Set<ConnectionInfo> infos = connectionManagerMap.get(key1);
         assertNotNull("Expected one connections for key1", infos);
         assertEquals("Expected one connection for key1", 1, infos.size());
         assertTrue("Expected to get supplied ConnectionInfo from infos", connectionInfo == infos.iterator().next());
@@ -246,7 +246,7 @@
 
         // connection should not be in context
         connectionManagerMap = componentContext.getConnectionManagerMap();
-        infos = (Set) connectionManagerMap.get(key1);
+        infos = connectionManagerMap.get(key1);
         assertNull("Expected no connection set for key1", infos);
 
         // enter again

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java?rev=585608&r1=585607&r2=585608&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java Wed Oct 17 10:56:54 2007
@@ -44,16 +44,16 @@
     private ConnectionTrackingInterceptor key1;
     private ConnectionTrackingInterceptor nestedKey;
     private Subject subject = null;
-    private Set unshareableResources;
-    private Set applicationManagedSecurityResources;
+    private Set<String> unshareableResources;
+    private Set<String> applicationManagedSecurityResources;
 
     protected void setUp() throws Exception {
         super.setUp();
         connectionTrackingCoordinator = new ConnectionTrackingCoordinator(false);
         key1 = new ConnectionTrackingInterceptor(this, name1, connectionTrackingCoordinator);
         nestedKey = new ConnectionTrackingInterceptor(this, name2, connectionTrackingCoordinator);
-        unshareableResources = new HashSet();
-        applicationManagedSecurityResources = new HashSet();
+        unshareableResources = new HashSet<String>();
+        applicationManagedSecurityResources = new HashSet<String>();
     }
 
     protected void tearDown() throws Exception {
@@ -77,8 +77,8 @@
         connectionTrackingCoordinator.exit(oldConnectorInstanceContext);
 
         // connection should be in component instance context
-        Map connectionManagerMap = componentContext.getConnectionManagerMap();
-        Set infos = (Set) connectionManagerMap.get(key1);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = componentContext.getConnectionManagerMap();
+        Set<ConnectionInfo> infos = connectionManagerMap.get(key1);
         assertNotNull("Expected one connections for key1", infos);
         assertEquals("Expected one connection for key1", 1, infos.size());
         assertTrue("Expected to get supplied ConnectionInfo from infos", connectionInfo == infos.iterator().next());
@@ -91,7 +91,7 @@
 
         // connection should not be in context
         connectionManagerMap = componentContext.getConnectionManagerMap();
-        infos = (Set) connectionManagerMap.get(key1);
+        infos = connectionManagerMap.get(key1);
         assertEquals("Expected no connection set for key1", null, infos);
     }
 
@@ -125,8 +125,8 @@
 
         // exit nested component context
         connectionTrackingCoordinator.exit(oldConnectorInstanceContext2);
-        Map nestedConnectionManagerMap = nextedComponentContext.getConnectionManagerMap();
-        Set nestedInfos = (Set) nestedConnectionManagerMap.get(nestedKey);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> nestedConnectionManagerMap = nextedComponentContext.getConnectionManagerMap();
+        Set<ConnectionInfo> nestedInfos = nestedConnectionManagerMap.get(nestedKey);
         assertNotNull("Expected one connections for key2", nestedInfos);
         assertEquals("Expected one connection for key2", 1, nestedInfos.size());
         assertSame("Expected to get supplied ConnectionInfo from infos", nestedConnectionInfo, nestedInfos.iterator().next());
@@ -135,8 +135,8 @@
 
         // exit outer component context
         connectionTrackingCoordinator.exit(oldConnectorInstanceContext1);
-        Map connectionManagerMap = componentContext1.getConnectionManagerMap();
-        Set infos1 = (Set) connectionManagerMap.get(key1);
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = componentContext1.getConnectionManagerMap();
+        Set<ConnectionInfo> infos1 = connectionManagerMap.get(key1);
         assertNotNull("Expected one connections for key1", infos1);
         assertEquals("Expected one connection for key1", 1, infos1.size());
         assertSame("Expected to get supplied ConnectionInfo from infos", connectionInfo1, infos1.iterator().next());
@@ -150,7 +150,7 @@
 
         // connection should not be in context
         connectionManagerMap = componentContext1.getConnectionManagerMap();
-        infos1 = (Set) connectionManagerMap.get(key1);
+        infos1 = connectionManagerMap.get(key1);
         assertNull("Expected no connection set for key1", infos1);
     }