Merge "Bug 453 - sal-rest-connector doesn't provide stream discovery feature"
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / osgi / BindingIndependentMappingServiceTracker.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.config.manager.impl.osgi;
9
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;
17
18 public class BindingIndependentMappingServiceTracker implements ServiceTrackerCustomizer<BindingIndependentMappingService, BindingIndependentMappingService> {
19     private static final Logger logger = LoggerFactory.getLogger(BindingIndependentMappingServiceTracker.class);
20
21     private final ConfigManagerActivator activator;
22     private final BundleContext ctx;
23     private BindingIndependentMappingService service;
24
25     public BindingIndependentMappingServiceTracker(BundleContext context, ConfigManagerActivator activator) {
26         this.ctx = context;
27         this.activator = activator;
28     }
29
30     @Override
31     public synchronized BindingIndependentMappingService addingService(
32             ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference) {
33
34         if (service != null) {
35             // FIXME
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));
40             return null;
41         }
42
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);
48         return service;
49     }
50
51     @Override
52     public void modifiedService(ServiceReference <BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService o) {
53         // TODO crash
54     }
55
56     @Override
57     public void removedService(ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService o) {
58         // TODO crash
59     }
60 }