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; |
| 18 | |
| 19 | public class FloodlightProvider implements IFloodlightModule { |
| 20 | Controller controller; |
| 21 | |
| 22 | @Override |
| 23 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
| 24 | Collection<Class<? extends IFloodlightService>> services = |
| 25 | new ArrayList<Class<? extends IFloodlightService>>(1); |
| 26 | services.add(IFloodlightProviderService.class); |
| 27 | return services; |
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public Map<Class<? extends IFloodlightService>, |
| 32 | IFloodlightService> getServiceImpls() { |
| 33 | controller = new Controller(); |
| 34 | |
| 35 | Map<Class<? extends IFloodlightService>, |
| 36 | IFloodlightService> m = |
| 37 | new HashMap<Class<? extends IFloodlightService>, |
| 38 | IFloodlightService>(); |
| 39 | m.put(IFloodlightProviderService.class, controller); |
| 40 | return m; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { |
| 45 | Collection<Class<? extends IFloodlightService>> dependencies = |
| 46 | new ArrayList<Class<? extends IFloodlightService>>(4); |
| 47 | dependencies.add(IStorageSourceService.class); |
| 48 | dependencies.add(IPktInProcessingTimeService.class); |
| 49 | dependencies.add(IRestApiService.class); |
| 50 | dependencies.add(ICounterStoreService.class); |
| 51 | dependencies.add(IThreadPoolService.class); |
| 52 | return dependencies; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public void init(FloodlightModuleContext context) throws FloodlightModuleException { |
| 57 | controller.setStorageSourceService( |
| 58 | context.getServiceImpl(IStorageSourceService.class)); |
| 59 | controller.setPktInProcessingService( |
| 60 | context.getServiceImpl(IPktInProcessingTimeService.class)); |
| 61 | controller.setCounterStore( |
| 62 | context.getServiceImpl(ICounterStoreService.class)); |
| 63 | controller.setRestApiService( |
| 64 | context.getServiceImpl(IRestApiService.class)); |
| 65 | controller.setThreadPoolService( |
| 66 | context.getServiceImpl(IThreadPoolService.class)); |
| 67 | controller.init(context.getConfigParams(this)); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void startUp(FloodlightModuleContext context) { |
| 72 | controller.startupComponents(); |
| 73 | } |
| 74 | } |