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