cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1467989 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/service/ test/java/org/apache/cxf/dosgi/dsw/service/
Date Mon, 15 Apr 2013 12:49:16 GMT
Author: cschneider
Date: Mon Apr 15 12:49:15 2013
New Revision: 1467989

URL: http://svn.apache.org/r1467989
Log:
DOSGI-169 Fix for issue in removeExportRegistrations. Patch applied with thanks to Amichai

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=1467989&r1=1467988&r2=1467989&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
Mon Apr 15 12:49:15 2013
@@ -29,7 +29,6 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
@@ -427,29 +426,25 @@ public class RemoteServiceAdminCore impl
     }
 
     // Remove all export registrations associated with the given bundle
-    protected void removeExportRegistrations(BundleContext exportingBundleCtx) {
-        Bundle exportingBundle = exportingBundleCtx.getBundle();
+    protected void removeExportRegistrations(Bundle exportingBundle) {
+        List<ExportRegistration> bundleExports = getExportsForBundle(exportingBundle);
+        for (ExportRegistration export : bundleExports) {
+            export.close();
+        }
+    }
 
-        // Work on a copy as the map gets modified as part of the behaviour by underlying
methods
-        Map<Map<String, Object>, Collection<ExportRegistration>> exportCopy
-            = new HashMap<Map<String, Object>, Collection<ExportRegistration>>(exportedServices);
-
-        for (Iterator<Map.Entry<Map<String, Object>, Collection<ExportRegistration>>>
it
-                = exportCopy.entrySet().iterator(); it.hasNext();) {
-
-            Entry<Map<String, Object>, Collection<ExportRegistration>>
entry = it.next();
-            Bundle regBundle = null;
-            Iterator<ExportRegistration> it2 = entry.getValue().iterator();
-            if (it2.hasNext())
-                regBundle = it2.next().getExportReference().getExportedService().getBundle();
-
-            if (exportingBundle.equals(regBundle)) {
-                // Again work on a copy, as the value gets modified by the behaviour inside
export.close()
-                for (ExportRegistration export : new ArrayList<ExportRegistration>(entry.getValue()))
{
-                    // This will remove the registration from the real map of exports
-                    export.close();
+    private List<ExportRegistration> getExportsForBundle(Bundle exportingBundle) {
+        synchronized (exportedServices) {
+            List<ExportRegistration> bundleRegs = new ArrayList<ExportRegistration>();
+            for (Collection<ExportRegistration> regs : exportedServices.values()) {
+                if (!regs.isEmpty()) {
+                    Bundle regBundle = regs.iterator().next().getExportReference().getExportedService().getBundle();
+                    if (exportingBundle.equals(regBundle)) {
+                        bundleRegs.addAll(regs);
+                    }
                 }
             }
+            return bundleRegs;
         }
     }
 

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java?rev=1467989&r1=1467988&r2=1467989&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
Mon Apr 15 12:49:15 2013
@@ -122,6 +122,6 @@ public class RemoteServiceAdminInstance 
     public void close() {
         closed = true;
 
-        rsaCore.removeExportRegistrations(bctx);
+        rsaCore.removeExportRegistrations(bctx.getBundle());
     }
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java?rev=1467989&r1=1467988&r2=1467989&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
Mon Apr 15 12:49:15 2013
@@ -317,7 +317,7 @@ public class RemoteServiceAdminCoreTest 
                 1, exportedServices.values().iterator().next().size());
 
         // Remove all export registrations from the service bundle
-        rsaCore.removeExportRegistrations(sref.getBundle().getBundleContext());
+        rsaCore.removeExportRegistrations(sref.getBundle());
         assertEquals("No more exported services", 0, exportedServices.size());
     }
 



Mime
View raw message