cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r988291 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
Date Mon, 23 Aug 2010 20:22:23 GMT
Author: dkulp
Date: Mon Aug 23 20:22:23 2010
New Revision: 988291

URL: http://svn.apache.org/viewvc?rev=988291&view=rev
Log:
[CXF-2954] Synchronize some stuff in the Extension bus

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java?rev=988291&r1=988290&r2=988291&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
Mon Aug 23 20:22:23 2010
@@ -30,6 +30,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.ResourceInjector;
@@ -116,15 +117,19 @@ public class ExtensionManagerImpl implem
             activateViaNS(deferred.keySet().iterator().next());
         }
     }
-    public <T> void activateAllByType(Class<T> type) {
+    public synchronized <T> void activateAllByType(Class<T> type) {
         for (Map.Entry<String, Collection<Extension>> e : deferred.entrySet())
{
-            Iterator<Extension> it = e.getValue().iterator();
-            while (it.hasNext()) {
-                Extension ex = it.next();
-                if (type.isAssignableFrom(ex.getClassObject(loader))) {
-                    loadAndRegister(ex);
-                    it.remove();
+            if (!e.getValue().isEmpty()) {
+                List<Extension> removes = new ArrayList<Extension>(e.getValue().size());
+                Iterator<Extension> it = e.getValue().iterator();
+                while (it.hasNext()) {
+                    Extension ex = it.next();
+                    if (type.isAssignableFrom(ex.getClassObject(loader))) {
+                        loadAndRegister(ex);
+                        removes.add(ex);
+                    }
                 }
+                e.getValue().removeAll(removes);
             }
         }
     }
@@ -156,7 +161,7 @@ public class ExtensionManagerImpl implem
             for (String ns : namespaces) {
                 Collection<Extension> extensions = deferred.get(ns);
                 if (null == extensions) {
-                    extensions = new ArrayList<Extension>();
+                    extensions = new CopyOnWriteArrayList<Extension>();
                     deferred.put(ns, extensions);
                 }
                 extensions.add(e);
@@ -214,7 +219,7 @@ public class ExtensionManagerImpl implem
         for (String ns : e.getNamespaces()) {
             Collection<Object> intf2Obj = namespaced.get(ns);
             if (intf2Obj == null) {
-                intf2Obj = new ArrayList<Object>();
+                intf2Obj = new CopyOnWriteArrayList<Object>();
                 if (!namespaced.containsKey(ns)) {
                     namespaced.put(ns, intf2Obj);
                 }



Mime
View raw message