blob: f3d0da5965253f621005c8e442412d3dd8fb93af [file] [log] [blame]
Jonathan Harta8887642013-10-28 13:46:54 -07001package net.onrc.onos.ofcontroller.core.module;
2
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.HashMap;
6import java.util.List;
7import java.util.Map;
8
9import net.floodlightcontroller.core.IFloodlightProviderService;
10import net.floodlightcontroller.core.module.FloodlightModuleContext;
11import net.floodlightcontroller.core.module.FloodlightModuleException;
12import net.floodlightcontroller.core.module.IFloodlightModule;
13import net.floodlightcontroller.core.module.IFloodlightService;
Jonathan Harta18e4792013-10-31 10:10:54 -070014import net.floodlightcontroller.devicemanager.IDeviceService;
Jonathan Harta8887642013-10-28 13:46:54 -070015import net.floodlightcontroller.restserver.IRestApiService;
16import net.floodlightcontroller.topology.ITopologyService;
Jonathan Hartebba1e12013-10-29 11:37:02 -070017import net.onrc.onos.ofcontroller.core.config.DefaultConfiguration;
18import net.onrc.onos.ofcontroller.core.config.IConfigInfoService;
Jonathan Hart1caaa932013-11-04 15:28:28 -080019import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
20import net.onrc.onos.ofcontroller.forwarding.Forwarding;
Jonathan Harta8887642013-10-28 13:46:54 -070021import net.onrc.onos.ofcontroller.proxyarp.IProxyArpService;
22import net.onrc.onos.ofcontroller.proxyarp.ProxyArpManager;
23
Jonathan Hartebba1e12013-10-29 11:37:02 -070024public class OnosModuleLoader implements IFloodlightModule {
Jonathan Harta8887642013-10-28 13:46:54 -070025 private IFloodlightProviderService floodlightProvider;
26 private ITopologyService topology;
Jonathan Harta18e4792013-10-31 10:10:54 -070027 private IDeviceService deviceService;
Jonathan Harta8887642013-10-28 13:46:54 -070028 private IConfigInfoService config;
29 private IRestApiService restApi;
Jonathan Hart1caaa932013-11-04 15:28:28 -080030 private IFlowService flowService;
Jonathan Harta8887642013-10-28 13:46:54 -070031
32 private ProxyArpManager arpManager;
Jonathan Hart1caaa932013-11-04 15:28:28 -080033 private Forwarding forwarding;
Jonathan Harta8887642013-10-28 13:46:54 -070034
Jonathan Hartebba1e12013-10-29 11:37:02 -070035 public OnosModuleLoader() {
Jonathan Harta8887642013-10-28 13:46:54 -070036 arpManager = new ProxyArpManager();
Jonathan Hart1caaa932013-11-04 15:28:28 -080037 forwarding = new Forwarding();
Jonathan Harta8887642013-10-28 13:46:54 -070038 }
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 Harta18e4792013-10-31 10:10:54 -070062 dependencies.add(IDeviceService.class);
Jonathan Harta8887642013-10-28 13:46:54 -070063 //dependencies.add(IConfigInfoService.class);
64 dependencies.add(IRestApiService.class);
Jonathan Hart1caaa932013-11-04 15:28:28 -080065 dependencies.add(IFlowService.class);
Jonathan Harta8887642013-10-28 13:46:54 -070066 return dependencies;
67 }
68
69 @Override
70 public void init(FloodlightModuleContext context)
71 throws FloodlightModuleException {
72 floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
73 topology = context.getServiceImpl(ITopologyService.class);
Jonathan Harta18e4792013-10-31 10:10:54 -070074 deviceService = context.getServiceImpl(IDeviceService.class);
Jonathan Harta8887642013-10-28 13:46:54 -070075 restApi = context.getServiceImpl(IRestApiService.class);
Jonathan Hart1caaa932013-11-04 15:28:28 -080076 flowService = context.getServiceImpl(IFlowService.class);
Jonathan Harta8887642013-10-28 13:46:54 -070077
78 //This could be null because it's not mandatory to have an
79 //IConfigInfoService loaded.
80 config = context.getServiceImpl(IConfigInfoService.class);
Jonathan Hartebba1e12013-10-29 11:37:02 -070081 if (config == null) {
82 config = new DefaultConfiguration();
83 }
Jonathan Harta8887642013-10-28 13:46:54 -070084
Jonathan Harta18e4792013-10-31 10:10:54 -070085 arpManager.init(floodlightProvider, topology, deviceService, config, restApi);
Jonathan Hart1caaa932013-11-04 15:28:28 -080086 forwarding.init(floodlightProvider, flowService);
Jonathan Harta8887642013-10-28 13:46:54 -070087 }
88
89 @Override
90 public void startUp(FloodlightModuleContext context) {
91 arpManager.startUp();
Jonathan Hart1caaa932013-11-04 15:28:28 -080092 forwarding.startUp();
Jonathan Harta8887642013-10-28 13:46:54 -070093 }
94
95}