servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1055303 - in /servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi: EndpointExporter.java EndpointTracker.java
Date Wed, 05 Jan 2011 06:11:05 GMT
Author: ffang
Date: Wed Jan  5 06:11:04 2011
New Revision: 1055303

URL: http://svn.apache.org/viewvc?rev=1055303&view=rev
Log:
[SMXCOMP-836]EndpointExporter should unregister the endpoint with it if failed to create a
ServiceAssembly

Modified:
    servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java
    servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointTracker.java

Modified: servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java?rev=1055303&r1=1055302&r2=1055303&view=diff
==============================================================================
--- servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java
(original)
+++ servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java
Wed Jan  5 06:11:04 2011
@@ -119,7 +119,9 @@ public class EndpointExporter implements
             };
             Dictionary props = new Properties();
             ServiceRegistration reg = bundleContext.registerService(EndpointWrapper.class.getName(),
wrapper, props);
-            endpointRegistrations.add(reg);
+            if (reg != null) {
+                endpointRegistrations.add(reg);
+            }
         }
         if (assemblyRegistration == null) {
             LOG.info("Waiting for all endpoints to be deployed before registering service
assembly");
@@ -130,6 +132,15 @@ public class EndpointExporter implements
         if (assemblyRegistration != null) {
             return;
         }
+        if (ep != null && (ep.getServiceUnit() == null 
+            || !ep.getServiceUnit().getComponent().getRegistry().isRegistered(ep.getServiceUnit())))
{
+            LOG.info("something wrong during register endpoint " + ep.getKey());
+            //get chance to unregister all endpoints with this EndpointExporter
+            for (Endpoint e : deployed) {
+                e.getServiceUnit().getComponent().getRegistry().unregisterServiceUnit(e.getServiceUnit());
+            }
+            return;
+        }
         if (ep != null) {
             deployed.add(ep);
         }

Modified: servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointTracker.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointTracker.java?rev=1055303&r1=1055302&r2=1055303&view=diff
==============================================================================
--- servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointTracker.java
(original)
+++ servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointTracker.java
Wed Jan  5 06:11:04 2011
@@ -55,9 +55,13 @@ public class EndpointTracker {
             if (LOGGER.isDebugEnabled()) {
     	        LOGGER.debug("[" + component.getComponentName() + "] Endpoint recognized");
             }
-            OsgiServiceUnit su = new OsgiServiceUnit(component, endpoint, wrapper.getClassLoader());
-            component.getRegistry().registerServiceUnit(su);
-            wrapper.setDeployed();
+            try {
+                OsgiServiceUnit su = new OsgiServiceUnit(component, endpoint, wrapper.getClassLoader());
+                component.getRegistry().registerServiceUnit(su);
+            } finally {
+                //get chance to do some clean up
+                wrapper.setDeployed();
+            }
         }
     }
 



Mime
View raw message