Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.core.module; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Map; |
| 5 | |
| 6 | |
| 7 | /** |
| 8 | * Defines an interface for loadable Floodlight modules. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 9 | * <p/> |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 10 | * At a high level, these functions are called in the following order: |
| 11 | * <ol> |
| 12 | * <li> getServices() : what services does this module provide |
| 13 | * <li> getDependencies() : list the dependencies |
| 14 | * <li> init() : internal initializations (don't touch other modules) |
| 15 | * <li> startUp() : external initializations (<em>do</em> touch other modules) |
| 16 | * </ol> |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 17 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 18 | * @author alexreimers |
| 19 | */ |
| 20 | public interface IFloodlightModule { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Return the list of interfaces that this module implements. |
| 24 | * All interfaces must inherit IFloodlightService |
| 25 | * |
Jonathan Hart | 99ff20a | 2014-06-15 16:53:00 -0700 | [diff] [blame] | 26 | * @return a list of class objects of services the module implements |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | public Collection<Class<? extends IFloodlightService>> getModuleServices(); |
| 30 | |
| 31 | /** |
| 32 | * Instantiate (as needed) and return objects that implement each |
| 33 | * of the services exported by this module. The map returned maps |
| 34 | * the implemented service to the object. The object could be the |
| 35 | * same object or different objects for different exported services. |
| 36 | * |
| 37 | * @return The map from service interface class to service implementation |
| 38 | */ |
| 39 | public Map<Class<? extends IFloodlightService>, |
| 40 | IFloodlightService> getServiceImpls(); |
| 41 | |
| 42 | /** |
| 43 | * Get a list of Modules that this module depends on. The module system |
| 44 | * will ensure that each these dependencies is resolved before the |
| 45 | * subsequent calls to init(). |
| 46 | * |
| 47 | * @return The Collection of IFloodlightServices that this module depends |
| 48 | * on. |
| 49 | */ |
| 50 | |
| 51 | public Collection<Class<? extends IFloodlightService>> getModuleDependencies(); |
| 52 | |
| 53 | /** |
| 54 | * This is a hook for each module to do its <em>internal</em> initialization, |
| 55 | * e.g., call setService(context.getService("Service")) |
| 56 | * <p/> |
| 57 | * All module dependencies are resolved when this is called, but not every module |
| 58 | * is initialized. |
| 59 | * |
| 60 | * @param context |
| 61 | * @throws FloodlightModuleException |
| 62 | */ |
| 63 | |
| 64 | void init(FloodlightModuleContext context) throws FloodlightModuleException; |
| 65 | |
| 66 | /** |
| 67 | * This is a hook for each module to do its <em>external</em> initializations, |
| 68 | * e.g., register for callbacks or query for state in other modules |
| 69 | * <p/> |
| 70 | * It is expected that this function will not block and that modules that want |
| 71 | * non-event driven CPU will spawn their own threads. |
| 72 | * |
| 73 | * @param context |
| 74 | */ |
| 75 | |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 76 | void startUp(FloodlightModuleContext context)throws FloodlightModuleException; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 77 | } |