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; |
| 13 | import net.floodlightcontroller.counter.ICounterStoreService; |
| 14 | import net.floodlightcontroller.perfmon.IPktInProcessingTimeService; |
| 15 | import net.floodlightcontroller.restserver.IRestApiService; |
| 16 | import net.floodlightcontroller.storage.IStorageSourceService; |
| 17 | import net.floodlightcontroller.threadpool.IThreadPoolService; |
HIGUCHI Yuta | 2051490 | 2013-06-12 11:24:16 -0700 | [diff] [blame] | 18 | import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService; |
HIGUCHI Yuta | edf81d7 | 2013-06-12 12:06:57 -0700 | [diff] [blame] | 19 | import net.onrc.onos.ofcontroller.flowcache.IFlowService; |
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); |
HIGUCHI Yuta | 09330f0 | 2013-06-14 13:31:07 -0700 | [diff] [blame^] | 55 | // Following added by ONOS |
Pavlin Radoslavov | 19b0e12 | 2013-02-21 18:47:38 -0800 | [diff] [blame] | 56 | dependencies.add(IFlowService.class); |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 57 | dependencies.add(ITopoRouteService.class); |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 58 | dependencies.add(IControllerRegistryService.class); |
Jonathan Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 59 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 60 | return dependencies; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public void init(FloodlightModuleContext context) throws FloodlightModuleException { |
| 65 | controller.setStorageSourceService( |
| 66 | context.getServiceImpl(IStorageSourceService.class)); |
| 67 | controller.setPktInProcessingService( |
| 68 | context.getServiceImpl(IPktInProcessingTimeService.class)); |
| 69 | controller.setCounterStore( |
| 70 | context.getServiceImpl(ICounterStoreService.class)); |
| 71 | controller.setRestApiService( |
| 72 | context.getServiceImpl(IRestApiService.class)); |
| 73 | controller.setThreadPoolService( |
| 74 | context.getServiceImpl(IThreadPoolService.class)); |
HIGUCHI Yuta | 09330f0 | 2013-06-14 13:31:07 -0700 | [diff] [blame^] | 75 | // Following added by ONOS |
Pavlin Radoslavov | 19b0e12 | 2013-02-21 18:47:38 -0800 | [diff] [blame] | 76 | controller.setFlowService(context.getServiceImpl(IFlowService.class)); |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 77 | controller.setTopoRouteService(context.getServiceImpl(ITopoRouteService.class)); |
Jonathan Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 78 | controller.setMastershipService( |
| 79 | context.getServiceImpl(IControllerRegistryService.class)); |
| 80 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 81 | controller.init(context.getConfigParams(this)); |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public void startUp(FloodlightModuleContext context) { |
| 86 | controller.startupComponents(); |
| 87 | } |
| 88 | } |