2 * Copyright (c) 2013 Cisco Systems, Inc. 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.config.manager.impl.osgi;
10 import org.opendaylight.controller.config.api.jmx.CommitStatus;
11 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
12 import org.opendaylight.controller.config.spi.ModuleFactory;
13 import org.osgi.framework.BundleContext;
14 import org.osgi.framework.ServiceReference;
15 import org.osgi.util.tracker.ServiceTrackerCustomizer;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import javax.management.ObjectName;
22 * Every time factory is added or removed, blank transaction is triggered to handle
23 * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory)}
26 public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<ModuleFactory, Object> {
27 private static final Logger logger = LoggerFactory.getLogger(BlankTransactionServiceTracker.class);
29 private final ConfigRegistryImpl configRegistry;
31 public BlankTransactionServiceTracker(ConfigRegistryImpl configRegistry) {
32 this.configRegistry = configRegistry;
36 public Object addingService(ServiceReference<ModuleFactory> moduleFactoryServiceReference) {
41 private void blankTransaction() {
43 ObjectName tx = configRegistry.beginConfig();
44 CommitStatus commitStatus = configRegistry.commitConfig(tx);
45 logger.debug("Committed blank transaction with status {}", commitStatus);
49 public void modifiedService(ServiceReference<ModuleFactory> moduleFactoryServiceReference, Object o) {
54 public void removedService(ServiceReference<ModuleFactory> moduleFactoryServiceReference, Object o) {