Skip to content
Snippets Groups Projects
Commit bcc62313 authored by Volkan Yazıcı's avatar Volkan Yazıcı
Browse files

Add an alternative getConfigParams() to access config via class references.

parent f8a51af7
No related branches found
No related tags found
No related merge requests found
......@@ -80,18 +80,23 @@ public class FloodlightModuleContext implements IFloodlightModuleContext {
*/
@Override
public Map<String, String> getConfigParams(IFloodlightModule module) {
Map<String, String> retMap = configParams.get(module.getClass());
return getConfigParams(module.getClass());
}
@Override
public Map<String, String> getConfigParams(Class<? extends IFloodlightModule> moduleClass) {
Map<String, String> retMap = configParams.get(moduleClass);
if (retMap == null) {
// Return an empty map if none exists so the module does not
// need to null check the map
retMap = new HashMap<String, String>();
configParams.put(module.getClass(), retMap);
configParams.put(moduleClass, retMap);
}
// also add any configuration parameters for superclasses, but
// only if more specific configuration does not override it
for (Class<? extends IFloodlightModule> c : configParams.keySet()) {
if (c.isInstance(module)) {
if (c.equals(moduleClass)) {
for (Map.Entry<String, String> ent : configParams.get(c).entrySet()) {
if (!retMap.containsKey(ent.getKey())) {
retMap.put(ent.getKey(), ent.getValue());
......
......@@ -41,7 +41,14 @@ public interface IFloodlightModuleContext {
* @return All Floodlight modules that are going to be loaded
*/
public Collection<IFloodlightModule> getAllModules();
/**
* Gets module specific configuration parameters.
* @param moduleClass The module class to get the configuration parameters for
* @return A key, value map of the configuration options
*/
public Map<String, String> getConfigParams(Class<? extends IFloodlightModule> moduleClass);
/**
* Gets module specific configuration parameters.
* @param module The module to get the configuration parameters for
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment