Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 1 | /** |
| 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 Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 17 | package net.floodlightcontroller.core; |
| 18 | |
| 19 | import java.util.ArrayList; |
| 20 | import java.util.Collection; |
| 21 | import java.util.HashMap; |
| 22 | import java.util.Map; |
| 23 | |
| 24 | import net.floodlightcontroller.core.internal.Controller; |
| 25 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 26 | import net.floodlightcontroller.core.module.FloodlightModuleException; |
| 27 | import net.floodlightcontroller.core.module.IFloodlightModule; |
| 28 | import net.floodlightcontroller.core.module.IFloodlightService; |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 29 | import net.floodlightcontroller.debugcounter.IDebugCounterService; |
| 30 | import net.floodlightcontroller.debugevent.IDebugEventService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 31 | import net.floodlightcontroller.restserver.IRestApiService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 32 | import net.floodlightcontroller.threadpool.IThreadPoolService; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 33 | import net.onrc.onos.core.linkdiscovery.ILinkDiscoveryService; |
Jonathan Hart | deda0ba | 2014-04-03 11:14:12 -0700 | [diff] [blame] | 34 | import net.onrc.onos.core.registry.IControllerRegistryService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 35 | |
| 36 | public class FloodlightProvider implements IFloodlightModule { |
| 37 | Controller controller; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 38 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 39 | @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'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 49 | IFloodlightService> getServiceImpls() { |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 50 | controller = new Controller(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 51 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 52 | Map<Class<? extends IFloodlightService>, |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 53 | IFloodlightService> m = |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 54 | new HashMap<Class<? extends IFloodlightService>, |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 55 | IFloodlightService>(); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 56 | 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'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 63 | new ArrayList<Class<? extends IFloodlightService>>(4); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 64 | dependencies.add(IRestApiService.class); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 65 | dependencies.add(IDebugCounterService.class); |
| 66 | dependencies.add(IDebugEventService.class); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 67 | dependencies.add(IThreadPoolService.class); |
| 68 | return dependencies; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public void init(FloodlightModuleContext context) throws FloodlightModuleException { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 73 | 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 Hart | c2e95ee | 2013-02-22 15:25:11 -0800 | [diff] [blame] | 86 | |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 87 | controller.init(context.getConfigParams(this)); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | @Override |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 91 | public void startUp(FloodlightModuleContext context) |
| 92 | throws FloodlightModuleException { |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 93 | controller.startupComponents(); |
| 94 | } |
| 95 | } |