Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.core; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.Collection; |
| 5 | import java.util.HashMap; |
| 6 | import java.util.Map; |
| 7 | |
| 8 | import net.floodlightcontroller.core.internal.Controller; |
| 9 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 10 | import net.floodlightcontroller.core.module.FloodlightModuleException; |
| 11 | import net.floodlightcontroller.core.module.IFloodlightModule; |
| 12 | import net.floodlightcontroller.core.module.IFloodlightService; |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 13 | import net.floodlightcontroller.core.INetMapTopologyService.ITopoRouteService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 14 | import net.floodlightcontroller.counter.ICounterStoreService; |
Pavlin Radoslavov | 19b0e12 | 2013-02-21 18:47:38 -0800 | [diff] [blame] | 15 | import net.floodlightcontroller.flowcache.IFlowService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 16 | import net.floodlightcontroller.perfmon.IPktInProcessingTimeService; |
| 17 | import net.floodlightcontroller.restserver.IRestApiService; |
| 18 | import net.floodlightcontroller.storage.IStorageSourceService; |
| 19 | import net.floodlightcontroller.threadpool.IThreadPoolService; |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 20 | import net.onrc.onos.registry.controller.IControllerRegistryService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 21 | |
| 22 | public class FloodlightProvider implements IFloodlightModule { |
| 23 | Controller controller; |
| 24 | |
| 25 | @Override |
| 26 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
| 27 | Collection<Class<? extends IFloodlightService>> services = |
| 28 | new ArrayList<Class<? extends IFloodlightService>>(1); |
| 29 | services.add(IFloodlightProviderService.class); |
| 30 | return services; |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public Map<Class<? extends IFloodlightService>, |
| 35 | IFloodlightService> getServiceImpls() { |
| 36 | controller = new Controller(); |
| 37 | |
| 38 | Map<Class<? extends IFloodlightService>, |
| 39 | IFloodlightService> m = |
| 40 | new HashMap<Class<? extends IFloodlightService>, |
| 41 | IFloodlightService>(); |
| 42 | m.put(IFloodlightProviderService.class, controller); |
| 43 | return m; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { |
| 48 | Collection<Class<? extends IFloodlightService>> dependencies = |
| 49 | new ArrayList<Class<? extends IFloodlightService>>(4); |
| 50 | dependencies.add(IStorageSourceService.class); |
| 51 | dependencies.add(IPktInProcessingTimeService.class); |
| 52 | dependencies.add(IRestApiService.class); |
| 53 | dependencies.add(ICounterStoreService.class); |
| 54 | dependencies.add(IThreadPoolService.class); |
Pavlin Radoslavov | 19b0e12 | 2013-02-21 18:47:38 -0800 | [diff] [blame] | 55 | dependencies.add(IFlowService.class); |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 56 | dependencies.add(ITopoRouteService.class); |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 57 | dependencies.add(IControllerRegistryService.class); |
Jonathan Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 58 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 59 | return dependencies; |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public void init(FloodlightModuleContext context) throws FloodlightModuleException { |
| 64 | controller.setStorageSourceService( |
| 65 | context.getServiceImpl(IStorageSourceService.class)); |
| 66 | controller.setPktInProcessingService( |
| 67 | context.getServiceImpl(IPktInProcessingTimeService.class)); |
| 68 | controller.setCounterStore( |
| 69 | context.getServiceImpl(ICounterStoreService.class)); |
| 70 | controller.setRestApiService( |
| 71 | context.getServiceImpl(IRestApiService.class)); |
| 72 | controller.setThreadPoolService( |
| 73 | context.getServiceImpl(IThreadPoolService.class)); |
Pavlin Radoslavov | 19b0e12 | 2013-02-21 18:47:38 -0800 | [diff] [blame] | 74 | controller.setFlowService(context.getServiceImpl(IFlowService.class)); |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 75 | controller.setTopoRouteService(context.getServiceImpl(ITopoRouteService.class)); |
Jonathan Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 76 | controller.setMastershipService( |
| 77 | context.getServiceImpl(IControllerRegistryService.class)); |
| 78 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 79 | controller.init(context.getConfigParams(this)); |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public void startUp(FloodlightModuleContext context) { |
| 84 | controller.startupComponents(); |
| 85 | } |
| 86 | } |