Merge "Turned down some logging from INFO to DEBUG in StatsAdapter"
authorGiovanni Meo <gmeo@cisco.com>
Sun, 26 Jan 2014 14:53:55 +0000 (14:53 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Sun, 26 Jan 2014 14:53:55 +0000 (14:53 +0000)
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java

index cef37db684fc6717d28db0ba4f25339a15136fce..aadf2fcc8dfdeb730877e40392bc04ae6505ce0e 100644 (file)
@@ -9,6 +9,7 @@
  */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
+import java.util.Hashtable;
 import java.util.Map.Entry;
 import java.util.Set;
 
@@ -26,6 +27,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
@@ -72,6 +74,7 @@ public final class RuntimeMappingModule extends
         RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
         service.setPool(SingletonHolder.CLASS_POOL);
         service.init();
+        bundleContext.registerService(SchemaServiceListener.class, service, new Hashtable<String,String>());
         return service;
     }
 
@@ -80,7 +83,12 @@ public final class RuntimeMappingModule extends
         if(serviceRef == null) {
             return null;
         }
-        return new RuntimeGeneratedMappingServiceProxy(getBundleContext(),serviceRef);
+
+        BindingIndependentMappingService delegate = bundleContext.getService(serviceRef);
+        if (delegate == null) {
+            return null;
+        }
+        return new RuntimeGeneratedMappingServiceProxy(getBundleContext(),serviceRef,delegate);
     }
 
     private BundleContext getBundleContext() {
@@ -101,10 +109,11 @@ public final class RuntimeMappingModule extends
         private BundleContext bundleContext;
 
         public RuntimeGeneratedMappingServiceProxy(BundleContext bundleContext,
-                ServiceReference<BindingIndependentMappingService> serviceRef) {
-            this.bundleContext = bundleContext;
-            this.reference = serviceRef;
-            this.delegate = bundleContext.getService(serviceRef);
+                ServiceReference<BindingIndependentMappingService> serviceRef,
+                BindingIndependentMappingService delegate) {
+            this.bundleContext = Preconditions.checkNotNull(bundleContext);
+            this.reference = Preconditions.checkNotNull(serviceRef);
+            this.delegate = Preconditions.checkNotNull(delegate);
         }
 
         public CodecRegistry getCodecRegistry() {