cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amic...@apache.org
Subject svn commit: r1494130 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service: ImportRegistrationImpl.java RemoteServiceAdminCore.java RemoteServiceAdminInstance.java RemoteServiceadminFactory.java
Date Tue, 18 Jun 2013 13:13:45 GMT
Author: amichai
Date: Tue Jun 18 13:13:44 2013
New Revision: 1494130

URL: http://svn.apache.org/r1494130
Log:
DOSGI-188 Improve fix so imports are closed only when last service instance is released and
prevent false removal events

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
    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/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java?rev=1494130&r1=1494129&r2=1494130&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
Tue Jun 18 13:13:44 2013
@@ -99,9 +99,6 @@ public class ImportRegistrationImpl impl
 
         LOG.debug("really closing ImportRegistration now");
 
-        if (clientServiceFactory != null) {
-            clientServiceFactory.setCloseable(true);
-        }
         if (importedService != null) {
             try {
                 importedService.unregister();
@@ -110,6 +107,9 @@ public class ImportRegistrationImpl impl
             }
             importedService = null;
         }
+        if (clientServiceFactory != null) {
+            clientServiceFactory.setCloseable(true);
+        }
     }
 
     public void close() {

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=1494130&r1=1494129&r2=1494130&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
Tue Jun 18 13:13:44 2013
@@ -449,15 +449,11 @@ public class RemoteServiceAdminCore impl
             Collection<ImportRegistrationImpl> imRegs = importedServices.get(iri.getImportedEndpointAlways());
             if (imRegs != null && imRegs.contains(iri)) {
                 imRegs.remove(iri);
-            } else {
-                LOG.error("An importRegistration was intended to be removed from internal
management "
-                    + "structure but couldn't be found in it!");
+                eventProducer.notifyRemoval(iri);
             }
             if (imRegs == null || imRegs.isEmpty()) {
                 importedServices.remove(iri.getImportedEndpointAlways());
             }
-
-            eventProducer.notifyRemoval(iri);
         }
     }
 }

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=1494130&r1=1494129&r2=1494130&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
Tue Jun 18 13:13:44 2013
@@ -79,9 +79,11 @@ public class RemoteServiceAdminInstance 
         });
     }
 
-    public void close() {
+    public void close(boolean closeAll) {
         closed = true;
         rsaCore.removeExportRegistrations(bctx.getBundle());
-        rsaCore.removeImportRegistrations();
+        if (closeAll) {
+            rsaCore.removeImportRegistrations();
+        }
     }
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java?rev=1494130&r1=1494129&r2=1494130&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
Tue Jun 18 13:13:44 2013
@@ -29,20 +29,21 @@ public class RemoteServiceadminFactory i
     private static final Logger LOG = LoggerFactory.getLogger(RemoteServiceadminFactory.class);
 
     private final RemoteServiceAdminCore rsaCore;
+    private int instances;
 
     public RemoteServiceadminFactory(RemoteServiceAdminCore rsaCore) {
         this.rsaCore = rsaCore;
     }
 
-    public Object getService(Bundle b, ServiceRegistration sr) {
+    public synchronized Object getService(Bundle b, ServiceRegistration sreg) {
         LOG.debug("new RemoteServiceAdmin ServiceInstance created for Bundle {}", b.getSymbolicName());
+        instances++;
         return new RemoteServiceAdminInstance(b.getBundleContext(), rsaCore);
     }
 
-    public void ungetService(Bundle b, ServiceRegistration sr, Object serviceObject) {
+    public synchronized void ungetService(Bundle b, ServiceRegistration sreg, Object serviceObject)
{
         LOG.debug("RemoteServiceAdmin ServiceInstance removed for Bundle {}", b.getSymbolicName());
-        if (serviceObject instanceof RemoteServiceAdminInstance) {
-            ((RemoteServiceAdminInstance)serviceObject).close();
-        }
+        instances--;
+        ((RemoteServiceAdminInstance)serviceObject).close(instances == 0);
     }
 }



Mime
View raw message