2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
15 * Update DatastoreContext settings on invoke update method.
18 public class DatastoreContextPropertiesUpdater implements AutoCloseable {
20 public interface Listener {
21 void onDatastoreContextUpdated(DatastoreContextFactory contextFactory);
24 private static final Logger LOG = LoggerFactory.getLogger(DatastoreContextPropertiesUpdater.class);
26 private final DatastoreContextIntrospector introspector;
27 private Listener listener;
30 * Base init of updater for DatastoreContext settings with base properties.
33 * - introspection on DatastoreContext
37 public DatastoreContextPropertiesUpdater(final DatastoreContextIntrospector introspector,
38 final Map<String, Object> props) {
39 this.introspector = introspector;
43 public void setListener(final Listener listener) {
44 this.listener = listener;
47 public void update(final Map<String, Object> properties) {
48 LOG.debug("Overlaying settings: {}", properties);
50 if (introspector.update(properties) && listener != null) {
51 listener.onDatastoreContextUpdated(introspector.newContextFactory());