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.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
11 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
12 import org.osgi.framework.BundleContext;
13 import org.osgi.framework.ServiceReference;
14 import org.osgi.util.tracker.ServiceTrackerCustomizer;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * Every time factory is added or removed, blank transaction is triggered to handle
20 * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory, org.osgi.framework.BundleContext)}
23 public class BindingIndependentMappingServiceTracker implements ServiceTrackerCustomizer<BindingIndependentMappingService, BindingIndependentMappingService> {
24 private static final Logger logger = LoggerFactory.getLogger(BindingIndependentMappingServiceTracker.class);
26 private final ConfigManagerActivator activator;
27 private final BundleContext ctx;
28 private BindingIndependentMappingService service;
30 public BindingIndependentMappingServiceTracker(BundleContext context, ConfigManagerActivator activator) {
32 this.activator = activator;
36 public synchronized BindingIndependentMappingService addingService(
37 ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference) {
39 if (service != null) {
41 // Second registration appears from
42 // org.opendaylight.controller.config.yang.md.sal.binding.impl.RuntimeMappingModule
43 logger.debug("BindingIndependentMappingService was already added as {}" + " now added as {}",
44 service, ctx.getService(moduleFactoryServiceReference));
48 BindingIndependentMappingService service = ctx.getService(moduleFactoryServiceReference);
49 this.service = service;
50 CodecRegistry codecRegistry = service.getCodecRegistry();
51 logger.warn("Codec registry acquired {}", codecRegistry);
52 activator.initConfigManager(ctx, codecRegistry);
57 public void modifiedService(ServiceReference <BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService o) {
62 public void removedService(ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService o) {