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.netconf.monitoring.osgi;
10 import java.util.Collections;
12 import org.opendaylight.controller.netconf.api.Capability;
13 import org.opendaylight.controller.netconf.api.monitoring.CapabilityListener;
14 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
15 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
16 import org.osgi.framework.BundleActivator;
17 import org.osgi.framework.BundleContext;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class NetconfMonitoringActivator implements BundleActivator {
23 private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringActivator.class);
25 private NetconfMonitoringServiceTracker monitor;
28 public void start(final BundleContext context) {
29 monitor = new NetconfMonitoringServiceTracker(context);
34 public void stop(final BundleContext context) {
38 } catch (final Exception e) {
39 LOG.warn("Ignoring exception while closing {}", monitor, e);
44 public static class NetconfMonitoringOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
46 private final NetconfMonitoringOperationService operationService;
48 private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
50 public void close() throws Exception {
55 public NetconfMonitoringOperationServiceFactory(final NetconfMonitoringOperationService operationService) {
56 this.operationService = operationService;
60 public NetconfOperationService createService(final String netconfSessionIdForReporting) {
61 return operationService;
65 public Set<Capability> getCapabilities() {
66 return Collections.emptySet();
70 public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
71 return AUTO_CLOSEABLE;
75 public void close() {}