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