servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject svn commit: r1359337 - /servicemix/smx4/nmr/trunk/nmr/osgi/src/main/java/org/apache/servicemix/nmr/osgi/OsgiServiceRegistryTracker.java
Date Mon, 09 Jul 2012 18:57:40 GMT
Author: janstey
Date: Mon Jul  9 18:57:40 2012
New Revision: 1359337

URL: http://svn.apache.org/viewvc?rev=1359337&view=rev
Log:
SMX4NMR-294 - display helpful message when service unavailable

Modified:
    servicemix/smx4/nmr/trunk/nmr/osgi/src/main/java/org/apache/servicemix/nmr/osgi/OsgiServiceRegistryTracker.java

Modified: servicemix/smx4/nmr/trunk/nmr/osgi/src/main/java/org/apache/servicemix/nmr/osgi/OsgiServiceRegistryTracker.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/osgi/src/main/java/org/apache/servicemix/nmr/osgi/OsgiServiceRegistryTracker.java?rev=1359337&r1=1359336&r2=1359337&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/osgi/src/main/java/org/apache/servicemix/nmr/osgi/OsgiServiceRegistryTracker.java
(original)
+++ servicemix/smx4/nmr/trunk/nmr/osgi/src/main/java/org/apache/servicemix/nmr/osgi/OsgiServiceRegistryTracker.java
Mon Jul  9 18:57:40 2012
@@ -20,11 +20,14 @@ import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import org.apache.servicemix.nmr.api.ServiceMixException;
 import org.apache.servicemix.nmr.api.service.ServiceRegistry;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A simple spring factory bean that will create an OSGi service tracker and notify the configured
registry
@@ -37,6 +40,8 @@ public class OsgiServiceRegistryTracker<
     private ServiceRegistry<T> registry;
     private Class clazz;
     private ServiceTracker tracker;
+    
+    private final Logger logger = LoggerFactory.getLogger(getClass());
 
     public BundleContext getBundleContext() {
         return bundleContext;
@@ -74,8 +79,12 @@ public class OsgiServiceRegistryTracker<
     @SuppressWarnings("unchecked")
     public Object addingService(ServiceReference reference) {
         T service = (T) bundleContext.getService(reference);
-        Map properties = getServicePropertiesSnapshotAsMap(reference);
-        registry.register(service, properties);
+    	if (service == null) {
+            logger.warn("No service for serviceReference " + reference + " found.");    
      
+    	} else {    		
+            Map properties = getServicePropertiesSnapshotAsMap(reference);
+            registry.register(service, properties);
+    	}
         return service;
     }
 



Mime
View raw message