blob: 41838779d27f702a171e24735c59bd523a960ea7 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.core;
2
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.HashMap;
6import java.util.Map;
7
8import net.floodlightcontroller.core.internal.Controller;
9import net.floodlightcontroller.core.module.FloodlightModuleContext;
10import net.floodlightcontroller.core.module.FloodlightModuleException;
11import net.floodlightcontroller.core.module.IFloodlightModule;
12import net.floodlightcontroller.core.module.IFloodlightService;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080013import net.floodlightcontroller.restserver.IRestApiService;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080014import net.floodlightcontroller.threadpool.IThreadPoolService;
Jonathan Hart23701d12014-04-03 10:45:48 -070015import net.onrc.onos.core.linkdiscovery.ILinkDiscoveryService;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070016import net.onrc.onos.core.registry.IControllerRegistryService;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080017
18public class FloodlightProvider implements IFloodlightModule {
19 Controller controller;
Ray Milkey269ffb92014-04-03 14:43:30 -070020
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080021 @Override
22 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
23 Collection<Class<? extends IFloodlightService>> services =
24 new ArrayList<Class<? extends IFloodlightService>>(1);
25 services.add(IFloodlightProviderService.class);
26 return services;
27 }
28
29 @Override
30 public Map<Class<? extends IFloodlightService>,
Ray Milkey269ffb92014-04-03 14:43:30 -070031 IFloodlightService> getServiceImpls() {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080032 controller = new Controller();
Ray Milkey269ffb92014-04-03 14:43:30 -070033
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080034 Map<Class<? extends IFloodlightService>,
Ray Milkey269ffb92014-04-03 14:43:30 -070035 IFloodlightService> m =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080036 new HashMap<Class<? extends IFloodlightService>,
Ray Milkey269ffb92014-04-03 14:43:30 -070037 IFloodlightService>();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080038 m.put(IFloodlightProviderService.class, controller);
39 return m;
40 }
41
42 @Override
43 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
44 Collection<Class<? extends IFloodlightService>> dependencies =
Ray Milkey269ffb92014-04-03 14:43:30 -070045 new ArrayList<Class<? extends IFloodlightService>>(4);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080046 dependencies.add(IRestApiService.class);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080047 dependencies.add(IThreadPoolService.class);
HIGUCHI Yuta09330f02013-06-14 13:31:07 -070048 // Following added by ONOS
Pavlin Radoslavovc35229e2014-02-06 16:19:37 -080049 // dependencies.add(IControllerRegistryService.class);
50 // dependencies.add(ILinkDiscoveryService.class);
Jonathan Hartc2e95ee2013-02-22 15:25:11 -080051
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080052 return dependencies;
53 }
54
55 @Override
56 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
Ray Milkey269ffb92014-04-03 14:43:30 -070057 controller.setRestApiService(
58 context.getServiceImpl(IRestApiService.class));
59 controller.setThreadPoolService(
60 context.getServiceImpl(IThreadPoolService.class));
61 // Following added by ONOS
62 controller.setMastershipService(
63 context.getServiceImpl(IControllerRegistryService.class));
64 controller.setLinkDiscoveryService(
65 context.getServiceImpl(ILinkDiscoveryService.class));
Jonathan Hartc2e95ee2013-02-22 15:25:11 -080066
Ray Milkey269ffb92014-04-03 14:43:30 -070067 controller.init(context.getConfigParams(this));
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080068 }
69
70 @Override
71 public void startUp(FloodlightModuleContext context) {
72 controller.startupComponents();
73 }
74}