/** * Sets up all modules and their dependencies. * @param modules The list of modules that the user wants to load. * @param mockedServices The list of services that will be mocked. Any * module that provides this service will not be loaded. */ public void setupModules(Collection<Class<? extends IFloodlightModule>> modules, Collection<IFloodlightService> mockedServices) throws FloodlightModuleException { addDefaultModules(modules); Collection<String> modulesAsString = new ArrayList<String>(); for (Class<? extends IFloodlightModule> m : modules) { modulesAsString.add(m.getCanonicalName()); } fmc = loadModulesFromList(modulesAsString, null, mockedServices); }
/** * Gets the inited/started instance of a module from the context. * @param ifl The name if the module to get, i.e. "LearningSwitch.class". * @return The inited/started instance of the module. */ public IFloodlightModule getModuleByName(Class<? extends IFloodlightModule> ifl) { Collection<IFloodlightModule> modules = fmc.getAllModules(); for (IFloodlightModule m : modules) { if (ifl.getCanonicalName().equals(m.getClass().getCanonicalName())) { return m; } } return null; }
/** * Gets an inited/started instance of a service from the context. * @param ifs The name of the service to get, i.e. "ITopologyService.class". * @return The inited/started instance of the service from teh context. */ public IFloodlightService getModuleByService(Class<? extends IFloodlightService> ifs) { Collection<IFloodlightModule> modules = fmc.getAllModules(); for (IFloodlightModule m : modules) { Collection<Class<? extends IFloodlightService>> mServs = m.getModuleServices(); if (mServs == null) continue; for (Class<? extends IFloodlightService> mServClass : mServs) { if (mServClass.getCanonicalName().equals(ifs.getCanonicalName())) { assert(m instanceof IFloodlightService); return (IFloodlightService)m; } } } return null; }
/** * Sets up all modules and their dependencies. * @param modules The list of modules that the user wants to load. * @param mockedServices The list of services that will be mocked. Any * module that provides this service will not be loaded. */ public void setupModules(Collection<Class<? extends IFloodlightModule>> modules, Collection<IFloodlightService> mockedServices) { addDefaultModules(modules); Collection<String> modulesAsString = new ArrayList<String>(); for (Class<? extends IFloodlightModule> m : modules) { modulesAsString.add(m.getCanonicalName()); } try { fmc = loadModulesFromList(modulesAsString, null, mockedServices); } catch (FloodlightModuleException e) { log.error(e.getMessage()); } }