Fix checkstyle warnings in netconf-monitoring.
[controller.git] / opendaylight / netconf / netconf-monitoring / src / main / java / org / opendaylight / controller / netconf / monitoring / osgi / NetconfMonitoringActivator.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.netconf.monitoring.osgi;
9
10 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
11 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
12 import org.osgi.framework.BundleActivator;
13 import org.osgi.framework.BundleContext;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 public class NetconfMonitoringActivator implements BundleActivator {
18
19     private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringActivator.class);
20
21     private NetconfMonitoringServiceTracker monitor;
22
23     @Override
24     public void start(final BundleContext context)  {
25         monitor = new NetconfMonitoringServiceTracker(context);
26         monitor.open();
27     }
28
29     @Override
30     public void stop(final BundleContext context) {
31         if(monitor!=null) {
32             try {
33                 monitor.close();
34             } catch (Exception e) {
35                 LOG.warn("Ignoring exception while closing {}", monitor, e);
36             }
37         }
38     }
39
40     public static class NetconfMonitoringOperationServiceFactory implements NetconfOperationServiceFactory {
41         private final NetconfMonitoringOperationService operationService;
42
43         public NetconfMonitoringOperationServiceFactory(NetconfMonitoringOperationService operationService) {
44             this.operationService = operationService;
45         }
46
47         @Override
48         public NetconfOperationService createService(String netconfSessionIdForReporting) {
49             return operationService;
50         }
51     }
52 }