blob: f8b196b23e74a7fefa15e507a8a5b81c23a64ce3 [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.
9 *
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>
17 *
18 * @author alexreimers
19 */
20public interface IFloodlightModule {
21
22 /**
23 * Return the list of interfaces that this module implements.
24 * All interfaces must inherit IFloodlightService
25 * @return
26 */
27
28 public Collection<Class<? extends IFloodlightService>> getModuleServices();
29
30 /**
31 * Instantiate (as needed) and return objects that implement each
32 * of the services exported by this module. The map returned maps
33 * the implemented service to the object. The object could be the
34 * same object or different objects for different exported services.
35 * @return The map from service interface class to service implementation
36 */
37 public Map<Class<? extends IFloodlightService>,
38 IFloodlightService> getServiceImpls();
39
40 /**
41 * Get a list of Modules that this module depends on. The module system
42 * will ensure that each these dependencies is resolved before the
43 * subsequent calls to init().
44 * @return The Collection of IFloodlightServices that this module depends
45 * on.
46 */
47
48 public Collection<Class<? extends IFloodlightService>> getModuleDependencies();
49
50 /**
51 * This is a hook for each module to do its <em>internal</em> initialization,
52 * e.g., call setService(context.getService("Service"))
53 *
54 * All module dependencies are resolved when this is called, but not every module
55 * is initialized.
56 *
57 * @param context
58 * @throws FloodlightModuleException
59 */
60
61 void init(FloodlightModuleContext context) throws FloodlightModuleException;
62
63 /**
64 * This is a hook for each module to do its <em>external</em> initializations,
65 * e.g., register for callbacks or query for state in other modules
66 *
67 * It is expected that this function will not block and that modules that want
68 * non-event driven CPU will spawn their own threads.
69 *
70 * @param context
71 */
72
73 void startUp(FloodlightModuleContext context);
74}