MD-SAL Statistics Manager - Implement request and notifications and minor modificatio...
[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  * TODO: Handle multipart messages with following flag true 
10  * OFPMPF_REPLY_MORE = 1 << 0
11  * Better accumulate all the messages and update local cache 
12  * and configurational data store
13  */
14 package org.opendaylight.controller.md.statistics.manager;
15
16 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
18 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
19 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
20 import org.osgi.framework.BundleContext;
21
22 public class StatisticsManagerActivator extends AbstractBindingAwareProvider {
23
24     private static ProviderContext pSession;
25     
26     private static StatisticsProvider statsProvider = new StatisticsProvider();
27    
28     @Override
29     public void onSessionInitiated(ProviderContext session) {
30         
31         DataProviderService dps = session.<DataProviderService>getSALService(DataProviderService.class);
32         StatisticsManagerActivator.statsProvider.setDataService(dps);
33         NotificationProviderService nps = session.<NotificationProviderService>getSALService(NotificationProviderService.class);
34         StatisticsManagerActivator.statsProvider.setNotificationService(nps);
35         StatisticsManagerActivator.statsProvider.start();
36
37     }
38     
39     @Override
40     protected void stopImpl(BundleContext context) {
41         StatisticsManagerActivator.statsProvider.close();
42     }
43     
44     public static ProviderContext getProviderContext(){
45         return pSession;
46     }
47
48 }