Merge "Change target to ${project.build.target} in a bunch of pom file. Add some...
[controller.git] / opendaylight / md-sal / statistics-manager / src / main / java / org / opendaylight / controller / md / statistics / manager / StatisticsManagerActivator.java
1 /*
2  * Copyright IBM Corporation, 2013.  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
9 package org.opendaylight.controller.md.statistics.manager;
10
11 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
13 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
14 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
15 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
16 import org.osgi.framework.BundleContext;
17
18 public class StatisticsManagerActivator extends AbstractBindingAwareProvider {
19
20     private static ProviderContext pSession;
21     
22     private static StatisticsProvider statsProvider = new StatisticsProvider();
23    
24     @Override
25     public void onSessionInitiated(ProviderContext session) {
26         
27         pSession = session;
28         DataProviderService dps = session.<DataProviderService>getSALService(DataProviderService.class);
29         StatisticsManagerActivator.statsProvider.setDataService(dps);
30         DataBrokerService dbs = session.<DataBrokerService>getSALService(DataBrokerService.class);
31         StatisticsManagerActivator.statsProvider.setDataBrokerService(dbs);
32         NotificationProviderService nps = session.<NotificationProviderService>getSALService(NotificationProviderService.class);
33         StatisticsManagerActivator.statsProvider.setNotificationService(nps);
34         StatisticsManagerActivator.statsProvider.start();
35
36     }
37     
38     @Override
39     protected void stopImpl(BundleContext context) {
40         StatisticsManagerActivator.statsProvider.close();
41     }
42     
43     public static ProviderContext getProviderContext(){
44         return pSession;
45     }
46
47 }