blob: 5dbdb3e9109810c017478864a8673f1d7d01e43c [file] [log] [blame]
Brian O'Connorc67f9fa2014-08-07 18:17:46 -07001/**
2 * Copyright 2013, Big Switch Networks, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 * not use this file except in compliance with the License. You may obtain
6 * a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 **/
16
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080017package net.floodlightcontroller.core;
18
19import java.util.ArrayList;
20import java.util.Collection;
21import java.util.HashMap;
22import java.util.Map;
23
24import net.floodlightcontroller.core.internal.Controller;
25import net.floodlightcontroller.core.module.FloodlightModuleContext;
26import net.floodlightcontroller.core.module.FloodlightModuleException;
27import net.floodlightcontroller.core.module.IFloodlightModule;
28import net.floodlightcontroller.core.module.IFloodlightService;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070029import net.floodlightcontroller.debugcounter.IDebugCounterService;
30import net.floodlightcontroller.debugevent.IDebugEventService;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080031import net.floodlightcontroller.restserver.IRestApiService;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080032import net.floodlightcontroller.threadpool.IThreadPoolService;
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070033import net.onrc.onos.core.configmanager.INetworkConfigService;
Jonathan Hart23701d12014-04-03 10:45:48 -070034import net.onrc.onos.core.linkdiscovery.ILinkDiscoveryService;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070035import net.onrc.onos.core.registry.IControllerRegistryService;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080036
37public class FloodlightProvider implements IFloodlightModule {
38 Controller controller;
Ray Milkey269ffb92014-04-03 14:43:30 -070039
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080040 @Override
41 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
42 Collection<Class<? extends IFloodlightService>> services =
43 new ArrayList<Class<? extends IFloodlightService>>(1);
44 services.add(IFloodlightProviderService.class);
45 return services;
46 }
47
48 @Override
49 public Map<Class<? extends IFloodlightService>,
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070050 IFloodlightService> getServiceImpls() {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080051 controller = new Controller();
Ray Milkey269ffb92014-04-03 14:43:30 -070052
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080053 Map<Class<? extends IFloodlightService>,
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070054 IFloodlightService> m =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080055 new HashMap<Class<? extends IFloodlightService>,
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070056 IFloodlightService>();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080057 m.put(IFloodlightProviderService.class, controller);
58 return m;
59 }
60
61 @Override
62 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
63 Collection<Class<? extends IFloodlightService>> dependencies =
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070064 new ArrayList<Class<? extends IFloodlightService>>(4);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080065 dependencies.add(IRestApiService.class);
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070066 dependencies.add(IDebugCounterService.class);
67 dependencies.add(IDebugEventService.class);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080068 dependencies.add(IThreadPoolService.class);
69 return dependencies;
70 }
71
72 @Override
73 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070074 controller.setDebugCounter(
75 context.getServiceImpl(IDebugCounterService.class));
76 controller.setDebugEvent(
77 context.getServiceImpl(IDebugEventService.class));
78 controller.setRestApiService(
79 context.getServiceImpl(IRestApiService.class));
80 controller.setThreadPoolService(
81 context.getServiceImpl(IThreadPoolService.class));
82 // Following added by ONOS
83 controller.setMastershipService(
84 context.getServiceImpl(IControllerRegistryService.class));
85 controller.setLinkDiscoveryService(
86 context.getServiceImpl(ILinkDiscoveryService.class));
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070087 controller.setNetworkConfigService(
88 context.getServiceImpl(INetworkConfigService.class));
Jonathan Hartc2e95ee2013-02-22 15:25:11 -080089
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070090 controller.init(context.getConfigParams(this));
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080091 }
92
93 @Override
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070094 public void startUp(FloodlightModuleContext context)
95 throws FloodlightModuleException {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080096 controller.startupComponents();
97 }
98}