Adjust to yangtools-2.0.0 changes
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / osgi / mapping / RefreshingSCPModuleInfoRegistry.java
index fcde347881b41df99f32e5e94e23b5a548cc8fe0..d59232cf08de0904b55f75009756124d2117d5c0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -20,15 +20,12 @@ import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
- * Update SchemaContext service in Service Registry each time new YangModuleInfo is added or removed.
+ * Update SchemaContext service in Service Registry each time new YangModuleInfo
+ * is added or removed.
  */
 public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, AutoCloseable {
-    private static final Logger LOG = LoggerFactory.getLogger(RefreshingSCPModuleInfoRegistry.class);
-
     private final ModuleInfoRegistry moduleInfoRegistry;
     private final SchemaContextProvider schemaContextProvider;
     private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
@@ -38,39 +35,35 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto
     private volatile ServiceRegistration<SchemaContextProvider> osgiReg;
 
     public RefreshingSCPModuleInfoRegistry(final ModuleInfoRegistry moduleInfoRegistry,
-        final SchemaContextProvider schemaContextProvider, final ClassLoadingStrategy classLoadingStrat,
-        final SchemaSourceProvider<YangTextSchemaSource> sourceProvider, final BindingContextProvider bindingContextProvider,
-        final BundleContext bundleContext) {
+            final SchemaContextProvider schemaContextProvider, final ClassLoadingStrategy classLoadingStrat,
+            final SchemaSourceProvider<YangTextSchemaSource> sourceProvider,
+            final BindingContextProvider bindingContextProvider, final BundleContext bundleContext) {
 
         this.moduleInfoRegistry = moduleInfoRegistry;
         this.schemaContextProvider = schemaContextProvider;
         this.classLoadingStrat = classLoadingStrat;
         this.sourceProvider = sourceProvider;
         this.bindingContextProvider = bindingContextProvider;
-        this.osgiReg = bundleContext
-            .registerService(SchemaContextProvider.class, schemaContextProvider, new Hashtable<String, String>());
+        this.osgiReg = bundleContext.registerService(SchemaContextProvider.class, schemaContextProvider,
+                new Hashtable<String, String>());
     }
 
     public synchronized void updateService() {
         if (this.osgiReg != null) {
-            try {
-                this.bindingContextProvider.update(this.classLoadingStrat, this.schemaContextProvider);
-
-                final Dictionary<String, Object> props = new Hashtable<>();
-                props.put(BindingRuntimeContext.class.getName(), this.bindingContextProvider.getBindingContext());
-                props.put(SchemaSourceProvider.class.getName(), this.sourceProvider);
-                // send modifiedService event
-                this.osgiReg.setProperties(props);
-            } catch (final RuntimeException e) {
-                // The ModuleInfoBackedContext throws a RuntimeException if it can't create the schema context.
-                LOG.warn("Error updating the BindingContextProvider", e);
-            }
+            this.bindingContextProvider.update(this.classLoadingStrat, this.schemaContextProvider);
+
+            final Dictionary<String, Object> props = new Hashtable<>();
+            props.put(BindingRuntimeContext.class.getName(), this.bindingContextProvider.getBindingContext());
+            props.put(SchemaSourceProvider.class.getName(), this.sourceProvider);
+            // send modifiedService event
+            this.osgiReg.setProperties(props);
         }
     }
 
     @Override
     public ObjectRegistration<YangModuleInfo> registerModuleInfo(final YangModuleInfo yangModuleInfo) {
-        final ObjectRegistration<YangModuleInfo> yangModuleInfoObjectRegistration = this.moduleInfoRegistry.registerModuleInfo(yangModuleInfo);
+        final ObjectRegistration<YangModuleInfo> yangModuleInfoObjectRegistration = this.moduleInfoRegistry
+                .registerModuleInfo(yangModuleInfo);
         return new ObjectRegistrationWrapper(yangModuleInfoObjectRegistration);
     }
 
@@ -86,7 +79,7 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto
     private class ObjectRegistrationWrapper implements ObjectRegistration<YangModuleInfo> {
         private final ObjectRegistration<YangModuleInfo> inner;
 
-        private ObjectRegistrationWrapper(final ObjectRegistration<YangModuleInfo> inner) {
+        ObjectRegistrationWrapper(final ObjectRegistration<YangModuleInfo> inner) {
             this.inner = inner;
         }
 
@@ -96,7 +89,7 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto
         }
 
         @Override
-        public void close() throws Exception {
+        public void close() {
             this.inner.close();
             // send modify event when a bundle disappears
             updateService();