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; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 14 | import net.floodlightcontroller.restserver.IRestApiService; |
| 15 | import net.floodlightcontroller.storage.IStorageSourceService; |
| 16 | import net.floodlightcontroller.threadpool.IThreadPoolService; |
Jonathan Hart | 8a5d097 | 2013-12-04 10:02:44 -0800 | [diff] [blame] | 17 | import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService; |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 18 | import net.onrc.onos.registry.controller.IControllerRegistryService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 19 | |
| 20 | public class FloodlightProvider implements IFloodlightModule { |
| 21 | Controller controller; |
| 22 | |
| 23 | @Override |
| 24 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
| 25 | Collection<Class<? extends IFloodlightService>> services = |
| 26 | new ArrayList<Class<? extends IFloodlightService>>(1); |
| 27 | services.add(IFloodlightProviderService.class); |
| 28 | return services; |
| 29 | } |
| 30 | |
| 31 | @Override |
| 32 | public Map<Class<? extends IFloodlightService>, |
| 33 | IFloodlightService> getServiceImpls() { |
| 34 | controller = new Controller(); |
| 35 | |
| 36 | Map<Class<? extends IFloodlightService>, |
| 37 | IFloodlightService> m = |
| 38 | new HashMap<Class<? extends IFloodlightService>, |
| 39 | IFloodlightService>(); |
| 40 | m.put(IFloodlightProviderService.class, controller); |
| 41 | return m; |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { |
| 46 | Collection<Class<? extends IFloodlightService>> dependencies = |
| 47 | new ArrayList<Class<? extends IFloodlightService>>(4); |
| 48 | dependencies.add(IStorageSourceService.class); |
mininet | 73e7fb7 | 2013-12-03 14:25:53 -0800 | [diff] [blame] | 49 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 50 | dependencies.add(IRestApiService.class); |
| 51 | dependencies.add(ICounterStoreService.class); |
| 52 | dependencies.add(IThreadPoolService.class); |
HIGUCHI Yuta | 09330f0 | 2013-06-14 13:31:07 -0700 | [diff] [blame] | 53 | // Following added by ONOS |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 54 | dependencies.add(IControllerRegistryService.class); |
Jonathan Hart | 8a5d097 | 2013-12-04 10:02:44 -0800 | [diff] [blame] | 55 | dependencies.add(ILinkDiscoveryService.class); |
Jonathan Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 56 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 57 | return dependencies; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public void init(FloodlightModuleContext context) throws FloodlightModuleException { |
| 62 | controller.setStorageSourceService( |
| 63 | context.getServiceImpl(IStorageSourceService.class)); |
mininet | 73e7fb7 | 2013-12-03 14:25:53 -0800 | [diff] [blame] | 64 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 65 | controller.setCounterStore( |
| 66 | context.getServiceImpl(ICounterStoreService.class)); |
| 67 | controller.setRestApiService( |
| 68 | context.getServiceImpl(IRestApiService.class)); |
| 69 | controller.setThreadPoolService( |
| 70 | context.getServiceImpl(IThreadPoolService.class)); |
HIGUCHI Yuta | 09330f0 | 2013-06-14 13:31:07 -0700 | [diff] [blame] | 71 | // Following added by ONOS |
Jonathan Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 72 | controller.setMastershipService( |
| 73 | context.getServiceImpl(IControllerRegistryService.class)); |
Jonathan Hart | 8a5d097 | 2013-12-04 10:02:44 -0800 | [diff] [blame] | 74 | controller.setLinkDiscoveryService( |
| 75 | context.getServiceImpl(ILinkDiscoveryService.class)); |
Jonathan Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 76 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 77 | controller.init(context.getConfigParams(this)); |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public void startUp(FloodlightModuleContext context) { |
| 82 | controller.startupComponents(); |
| 83 | } |
| 84 | } |