+ class InnerCustomizer implements ServiceTrackerCustomizer<NetconfOperationServiceFactory, NetconfOperationServiceFactory> {
+ private final List<ConfigSnapshotHolder> configs;
+ private final PersisterAggregator persisterAggregator;
+ private final long maxWaitForCapabilitiesMillis, conflictingVersionTimeoutMillis;
+
+
+ InnerCustomizer(List<ConfigSnapshotHolder> configs, long maxWaitForCapabilitiesMillis, long conflictingVersionTimeoutMillis,
+ PersisterAggregator persisterAggregator) {
+ this.configs = configs;
+ this.maxWaitForCapabilitiesMillis = maxWaitForCapabilitiesMillis;
+ this.conflictingVersionTimeoutMillis = conflictingVersionTimeoutMillis;
+ this.persisterAggregator = persisterAggregator;
+ }
+
+ @Override
+ public NetconfOperationServiceFactory addingService(ServiceReference<NetconfOperationServiceFactory> reference) {
+ logger.trace("Got InnerCustomizer.addingService {}", reference);
+ NetconfOperationServiceFactory service = reference.getBundle().getBundleContext().getService(reference);
+
+ logger.debug("Creating new job queue");
+
+ final ConfigPusherImpl configPusher = new ConfigPusherImpl(service, maxWaitForCapabilitiesMillis, conflictingVersionTimeoutMillis);
+ logger.debug("Configuration Persister got {}", service);
+ logger.debug("Context was {}", context);
+ logger.debug("Registration was {}", registration);
+
+ final Thread pushingThread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if(configs != null && !configs.isEmpty()) {
+ configPusher.pushConfigs(configs);
+ }
+ if(context != null) {
+ registration = context.registerService(ConfigPusher.class.getName(), configPusher, null);
+ configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator);
+ } else {
+ logger.warn("Unable to process configs as BundleContext is null");
+ }
+ } catch (InterruptedException e) {
+ logger.info("ConfigPusher thread stopped",e);
+ }
+ logger.info("Configuration Persister initialization completed.");
+ }
+ }, "config-pusher");
+ synchronized (autoCloseables) {
+ autoCloseables.add(new AutoCloseable() {
+ @Override
+ public void close() {
+ pushingThread.interrupt();
+ }
+ });
+ }
+ pushingThread.start();
+ return service;