X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDatastoreContextConfigAdminOverlay.java;h=abf07ecb40ea94e01ff965eaaa370bc256f24793;hp=2688d0195df662f004a4d4738bf16330387b194f;hb=28e9832cc97a345d5ceb69262784e5c8fef77e37;hpb=412db94945c5db5d2da918f5e23bd3abcecc4d10 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContextConfigAdminOverlay.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContextConfigAdminOverlay.java index 2688d0195d..abf07ecb40 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContextConfigAdminOverlay.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContextConfigAdminOverlay.java @@ -28,8 +28,8 @@ import org.slf4j.LoggerFactory; public class DatastoreContextConfigAdminOverlay implements AutoCloseable { public static final String CONFIG_ID = "org.opendaylight.controller.cluster.datastore"; - public static interface Listener { - void onDatastoreContextUpdated(DatastoreContext context); + public interface Listener { + void onDatastoreContextUpdated(DatastoreContextFactory contextFactory); } private static final Logger LOG = LoggerFactory.getLogger(DatastoreContextConfigAdminOverlay.class); @@ -46,7 +46,7 @@ public class DatastoreContextConfigAdminOverlay implements AutoCloseable { ServiceReference configAdminServiceReference = bundleContext.getServiceReference(ConfigurationAdmin.class); - if(configAdminServiceReference == null) { + if (configAdminServiceReference == null) { LOG.warn("No ConfigurationAdmin service found"); } else { overlaySettings(configAdminServiceReference); @@ -60,19 +60,20 @@ public class DatastoreContextConfigAdminOverlay implements AutoCloseable { this.listener = listener; } + @SuppressWarnings("checkstyle:IllegalCatch") private void overlaySettings(ServiceReference configAdminServiceReference) { try { ConfigurationAdmin configAdmin = bundleContext.getService(configAdminServiceReference); Configuration config = configAdmin.getConfiguration(CONFIG_ID); - if(config != null) { + if (config != null) { Dictionary properties = config.getProperties(); LOG.debug("Overlaying settings: {}", properties); - if(introspector.update(properties)) { - if(listener != null) { - listener.onDatastoreContextUpdated(introspector.getContext()); + if (introspector.update(properties)) { + if (listener != null) { + listener.onDatastoreContextUpdated(introspector.newContextFactory()); } } } else { @@ -80,7 +81,7 @@ public class DatastoreContextConfigAdminOverlay implements AutoCloseable { } } catch (IOException e) { LOG.error("Error obtaining Configuration for pid {}", CONFIG_ID, e); - } catch(IllegalStateException e) { + } catch (IllegalStateException e) { // Ignore - indicates the bundleContext has been closed. } finally { try { @@ -95,7 +96,7 @@ public class DatastoreContextConfigAdminOverlay implements AutoCloseable { public void close() { listener = null; - if(configListenerServiceRef != null) { + if (configListenerServiceRef != null) { configListenerServiceRef.unregister(); } } @@ -103,7 +104,7 @@ public class DatastoreContextConfigAdminOverlay implements AutoCloseable { private class DatastoreConfigurationListener implements ConfigurationListener { @Override public void configurationEvent(ConfigurationEvent event) { - if(CONFIG_ID.equals(event.getPid()) && event.getType() == ConfigurationEvent.CM_UPDATED) { + if (CONFIG_ID.equals(event.getPid()) && event.getType() == ConfigurationEvent.CM_UPDATED) { LOG.debug("configurationEvent: config {} was updated", CONFIG_ID); overlaySettings(event.getReference()); }