blob: ec08db1c20d57655e5b806b3642f97baec0c3c1a [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.core.module;
2
3import java.util.Collection;
4import java.util.Map;
5
6
7/**
8 * Defines an interface for loadable Floodlight modules.
Ray Milkey269ffb92014-04-03 14:43:30 -07009 * <p/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080010 * 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 Milkey269ffb92014-04-03 14:43:30 -070017 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080018 * @author alexreimers
19 */
20public interface IFloodlightModule {
Ray Milkey269ffb92014-04-03 14:43:30 -070021
22 /**
23 * Return the list of interfaces that this module implements.
24 * All interfaces must inherit IFloodlightService
25 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -070026 * @return a list of class objects of services the module implements
Ray Milkey269ffb92014-04-03 14:43:30 -070027 */
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'Connorc67f9fa2014-08-07 18:17:46 -070076 void startUp(FloodlightModuleContext context)throws FloodlightModuleException;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080077}