blob: 0ee290430a1fb7669b2d1a438b3ebf5e9a36ab69 [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;
Jonathan Hart23701d12014-04-03 10:45:48 -070033import net.onrc.onos.core.linkdiscovery.ILinkDiscoveryService;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070034import net.onrc.onos.core.registry.IControllerRegistryService;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080035
36public class FloodlightProvider implements IFloodlightModule {
37 Controller controller;
Ray Milkey269ffb92014-04-03 14:43:30 -070038
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080039 @Override
40 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
41 Collection<Class<? extends IFloodlightService>> services =
42 new ArrayList<Class<? extends IFloodlightService>>(1);
43 services.add(IFloodlightProviderService.class);
44 return services;
45 }
46
47 @Override
48 public Map<Class<? extends IFloodlightService>,
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070049 IFloodlightService> getServiceImpls() {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080050 controller = new Controller();
Ray Milkey269ffb92014-04-03 14:43:30 -070051
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080052 Map<Class<? extends IFloodlightService>,
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070053 IFloodlightService> m =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080054 new HashMap<Class<? extends IFloodlightService>,
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070055 IFloodlightService>();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080056 m.put(IFloodlightProviderService.class, controller);
57 return m;
58 }
59
60 @Override
61 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
62 Collection<Class<? extends IFloodlightService>> dependencies =
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070063 new ArrayList<Class<? extends IFloodlightService>>(4);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080064 dependencies.add(IRestApiService.class);
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070065 dependencies.add(IDebugCounterService.class);
66 dependencies.add(IDebugEventService.class);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080067 dependencies.add(IThreadPoolService.class);
68 return dependencies;
69 }
70
71 @Override
72 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070073 controller.setDebugCounter(
74 context.getServiceImpl(IDebugCounterService.class));
75 controller.setDebugEvent(
76 context.getServiceImpl(IDebugEventService.class));
77 controller.setRestApiService(
78 context.getServiceImpl(IRestApiService.class));
79 controller.setThreadPoolService(
80 context.getServiceImpl(IThreadPoolService.class));
81 // Following added by ONOS
82 controller.setMastershipService(
83 context.getServiceImpl(IControllerRegistryService.class));
84 controller.setLinkDiscoveryService(
85 context.getServiceImpl(ILinkDiscoveryService.class));
Jonathan Hartc2e95ee2013-02-22 15:25:11 -080086
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070087 controller.init(context.getConfigParams(this));
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080088 }
89
90 @Override
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070091 public void startUp(FloodlightModuleContext context)
92 throws FloodlightModuleException {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080093 controller.startupComponents();
94 }
95}