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