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;
18 public class BindingIndependentMappingServiceTracker implements ServiceTrackerCustomizer<BindingIndependentMappingService, BindingIndependentMappingService> {
19 private static final Logger logger = LoggerFactory.getLogger(BindingIndependentMappingServiceTracker.class);
21 private final ConfigManagerActivator activator;
22 private final BundleContext ctx;
23 private BindingIndependentMappingService service;
25 public BindingIndependentMappingServiceTracker(BundleContext context, ConfigManagerActivator activator) {
27 this.activator = activator;
31 public synchronized BindingIndependentMappingService addingService(
32 ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference) {
34 if (service != null) {
36 // Second registration appears from
37 // org.opendaylight.controller.config.yang.md.sal.binding.impl.RuntimeMappingModule
38 logger.debug("BindingIndependentMappingService was already added as {}" + " now added as {}",
39 service, ctx.getService(moduleFactoryServiceReference));
43 BindingIndependentMappingService service = ctx.getService(moduleFactoryServiceReference);
44 this.service = service;
45 CodecRegistry codecRegistry = service.getCodecRegistry();
46 logger.debug("Codec registry acquired {}", codecRegistry);
47 activator.initConfigManager(ctx, codecRegistry);
52 public void modifiedService(ServiceReference <BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService o) {
57 public void removedService(ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService o) {