Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.core.module; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.Collection; |
| 5 | import java.util.HashMap; |
| 6 | import java.util.List; |
| 7 | import java.util.Map; |
| 8 | |
| 9 | import net.floodlightcontroller.core.IFloodlightProviderService; |
| 10 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 11 | import net.floodlightcontroller.core.module.FloodlightModuleException; |
| 12 | import net.floodlightcontroller.core.module.IFloodlightModule; |
| 13 | import net.floodlightcontroller.core.module.IFloodlightService; |
Jonathan Hart | a18e479 | 2013-10-31 10:10:54 -0700 | [diff] [blame^] | 14 | import net.floodlightcontroller.devicemanager.IDeviceService; |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 15 | import net.floodlightcontroller.restserver.IRestApiService; |
| 16 | import net.floodlightcontroller.topology.ITopologyService; |
Jonathan Hart | ebba1e1 | 2013-10-29 11:37:02 -0700 | [diff] [blame] | 17 | import net.onrc.onos.ofcontroller.core.config.DefaultConfiguration; |
| 18 | import net.onrc.onos.ofcontroller.core.config.IConfigInfoService; |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 19 | import net.onrc.onos.ofcontroller.proxyarp.IProxyArpService; |
| 20 | import net.onrc.onos.ofcontroller.proxyarp.ProxyArpManager; |
| 21 | |
Jonathan Hart | ebba1e1 | 2013-10-29 11:37:02 -0700 | [diff] [blame] | 22 | public class OnosModuleLoader implements IFloodlightModule { |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 23 | private IFloodlightProviderService floodlightProvider; |
| 24 | private ITopologyService topology; |
Jonathan Hart | a18e479 | 2013-10-31 10:10:54 -0700 | [diff] [blame^] | 25 | private IDeviceService deviceService; |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 26 | private IConfigInfoService config; |
| 27 | private IRestApiService restApi; |
| 28 | |
| 29 | private ProxyArpManager arpManager; |
| 30 | |
Jonathan Hart | ebba1e1 | 2013-10-29 11:37:02 -0700 | [diff] [blame] | 31 | public OnosModuleLoader() { |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 32 | arpManager = new ProxyArpManager(); |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
| 37 | List<Class<? extends IFloodlightService>> services = |
| 38 | new ArrayList<Class<? extends IFloodlightService>>(); |
| 39 | services.add(IProxyArpService.class); |
| 40 | return services; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() { |
| 45 | Map<Class<? extends IFloodlightService>, IFloodlightService> impls = |
| 46 | new HashMap<Class<? extends IFloodlightService>, IFloodlightService>(); |
| 47 | impls.put(IProxyArpService.class, arpManager); |
| 48 | return impls; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { |
| 53 | List<Class<? extends IFloodlightService>> dependencies = |
| 54 | new ArrayList<Class<? extends IFloodlightService>>(); |
| 55 | dependencies.add(IFloodlightProviderService.class); |
| 56 | dependencies.add(ITopologyService.class); |
Jonathan Hart | a18e479 | 2013-10-31 10:10:54 -0700 | [diff] [blame^] | 57 | dependencies.add(IDeviceService.class); |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 58 | //dependencies.add(IConfigInfoService.class); |
| 59 | dependencies.add(IRestApiService.class); |
| 60 | return dependencies; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public void init(FloodlightModuleContext context) |
| 65 | throws FloodlightModuleException { |
| 66 | floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class); |
| 67 | topology = context.getServiceImpl(ITopologyService.class); |
Jonathan Hart | a18e479 | 2013-10-31 10:10:54 -0700 | [diff] [blame^] | 68 | deviceService = context.getServiceImpl(IDeviceService.class); |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 69 | restApi = context.getServiceImpl(IRestApiService.class); |
| 70 | |
| 71 | //This could be null because it's not mandatory to have an |
| 72 | //IConfigInfoService loaded. |
| 73 | config = context.getServiceImpl(IConfigInfoService.class); |
Jonathan Hart | ebba1e1 | 2013-10-29 11:37:02 -0700 | [diff] [blame] | 74 | if (config == null) { |
| 75 | config = new DefaultConfiguration(); |
| 76 | } |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 77 | |
Jonathan Hart | a18e479 | 2013-10-31 10:10:54 -0700 | [diff] [blame^] | 78 | arpManager.init(floodlightProvider, topology, deviceService, config, restApi); |
Jonathan Hart | a888764 | 2013-10-28 13:46:54 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public void startUp(FloodlightModuleContext context) { |
| 83 | arpManager.startUp(); |
| 84 | } |
| 85 | |
| 86 | } |