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
9 package org.opendaylight.controller.netconf.monitoring.osgi;
11 import java.util.Collections;
13 import org.opendaylight.controller.netconf.api.Capability;
14 import org.opendaylight.controller.netconf.api.monitoring.CapabilityListener;
15 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
16 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
17 import org.osgi.framework.BundleActivator;
18 import org.osgi.framework.BundleContext;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class NetconfMonitoringActivator implements BundleActivator {
24 private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringActivator.class);
26 private NetconfMonitoringServiceTracker monitor;
29 public void start(final BundleContext context) {
30 monitor = new NetconfMonitoringServiceTracker(context);
35 public void stop(final BundleContext context) {
39 } catch (final Exception e) {
40 LOG.warn("Ignoring exception while closing {}", monitor, e);
45 public static class NetconfMonitoringOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
47 private final NetconfMonitoringOperationService operationService;
49 private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
51 public void close() throws Exception {
56 public NetconfMonitoringOperationServiceFactory(final NetconfMonitoringOperationService operationService) {
57 this.operationService = operationService;
61 public NetconfOperationService createService(final String netconfSessionIdForReporting) {
62 return operationService;
66 public Set<Capability> getCapabilities() {
67 return Collections.emptySet();
71 public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
72 return AUTO_CLOSEABLE;
76 public void close() {}