Floodlight 的 Main 解析图
需要理解的概念
模块(Module)
Module 是指继承了 IFloodlightModule 接口的类
IFloodlightModule的相关注释
Defines an interface for loadable Floodlight modules.
At a high level, these functions are called in the following order:
getModuleServices() : 获得模块实现的服务列表
getServiceImpls(); 实例化并返回:服务实现类-实现此服务的对象 映射
getModuleDependencies() : 获得模块依赖的列表
init() : internal initializations (<em>don't</em> touch other modules)
startUp() : external initializations (<em>do</em> touch other modules)
所有可加载的模块都有这几种方法,在接下来的加载模块时需要使用到。
每个具体的模块都会重写这几个函数,下面举个 FloodlightProvider 的例子。
getModuleServices()
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Collection<Class<? extends IFloodlightService>> services =
new ArrayList<Class<? extends IFloodlightService>>(1);
services.add(IFloodlightProviderService.class);
return services;
}
获得 FloodlightProvider 的服务 IFloodlightProviderService
getServiceImple()
@Override
public Map<Class<? extends IFloodlightService>,
IFloodlightService> getServiceImpls() {
controller = new Controller();
Map<Class<? extends IFloodlightService>,
IFloodlightService> m =
new HashMap<Class<? extends IFloodlightService>,
IFloodlightService>();
m.put(IFloodlightProviderService.class, cont