Fix checkstyle whitespace issues - WHITESPACE ONLY

Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleContext.java b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleContext.java
index 0cbae32..5b311a1 100644
--- a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleContext.java
+++ b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleContext.java
@@ -6,99 +6,103 @@
 
 /**
  * The service registry for an IFloodlightProvider.
+ *
  * @author alexreimers
  */
 public class FloodlightModuleContext implements IFloodlightModuleContext {
-	protected Map<Class<? extends IFloodlightService>, IFloodlightService> serviceMap;
-	protected Map<Class<? extends IFloodlightModule>, Map<String, String>> configParams;
-	protected Collection<IFloodlightModule> moduleSet;
-	
-	/**
-	 * Creates the ModuleContext for use with this IFloodlightProvider.
-	 * This will be used as a module registry for all IFloodlightModule(s).
-	 */
-	public FloodlightModuleContext() {
-		serviceMap = 
-		        new HashMap<Class<? extends IFloodlightService>,
-		                              IFloodlightService>();
-		configParams =
-		        new HashMap<Class<? extends IFloodlightModule>,
-		                        Map<String, String>>();
-	}
-	
-	/**
-	 * Adds a IFloodlightModule for this Context.
-	 * @param clazz the service class
-	 * @param service The IFloodlightService to add to the registry
-	 */
-	public void addService(Class<? extends IFloodlightService> clazz, 
-	                       IFloodlightService service) {
-		serviceMap.put(clazz, service);
-	}
-	
-	@SuppressWarnings("unchecked")
+    protected Map<Class<? extends IFloodlightService>, IFloodlightService> serviceMap;
+    protected Map<Class<? extends IFloodlightModule>, Map<String, String>> configParams;
+    protected Collection<IFloodlightModule> moduleSet;
+
+    /**
+     * Creates the ModuleContext for use with this IFloodlightProvider.
+     * This will be used as a module registry for all IFloodlightModule(s).
+     */
+    public FloodlightModuleContext() {
+        serviceMap =
+                new HashMap<Class<? extends IFloodlightService>,
+                        IFloodlightService>();
+        configParams =
+                new HashMap<Class<? extends IFloodlightModule>,
+                        Map<String, String>>();
+    }
+
+    /**
+     * Adds a IFloodlightModule for this Context.
+     *
+     * @param clazz   the service class
+     * @param service The IFloodlightService to add to the registry
+     */
+    public void addService(Class<? extends IFloodlightService> clazz,
+                           IFloodlightService service) {
+        serviceMap.put(clazz, service);
+    }
+
+    @SuppressWarnings("unchecked")
     @Override
-	public <T extends IFloodlightService> T getServiceImpl(Class<T> service) {
-	    IFloodlightService s = serviceMap.get(service);
-		return (T)s;
-	}
-	
-	@Override
-	public Collection<Class<? extends IFloodlightService>> getAllServices() {
-	    return serviceMap.keySet();
-	}
-	
-	@Override
-	public Collection<IFloodlightModule> getAllModules() {
-	    return moduleSet;
-	}
-	
-	public void setModuleSet(Collection<IFloodlightModule> modSet) {
-	    this.moduleSet = modSet;
-	}
-	
-	/**
-	 * Gets the configuration parameter map for a module
-	 * @param module The module to get the configuration map for, usually yourself
-	 * @return A map containing all the configuration parameters for the module, may be empty
-	 */
-	@Override
-	public Map<String, String> getConfigParams(IFloodlightModule module) {
-	    Map<String, String> retMap = configParams.get(module.getClass());
-	    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);
-	    }
+    public <T extends IFloodlightService> T getServiceImpl(Class<T> service) {
+        IFloodlightService s = serviceMap.get(service);
+        return (T) s;
+    }
 
-	    // 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)) {
-	            for (Map.Entry<String, String> ent : configParams.get(c).entrySet()) {
-	                if (!retMap.containsKey(ent.getKey())) {
-	                    retMap.put(ent.getKey(), ent.getValue());
-	                }
-	            }
-	        }
-	    }
+    @Override
+    public Collection<Class<? extends IFloodlightService>> getAllServices() {
+        return serviceMap.keySet();
+    }
 
-	    return retMap;
-	}
-	
-	/**
-	 * Adds a configuration parameter for a module
-	 * @param mod The fully qualified module name to add the parameter to
-	 * @param key The configuration parameter key
-	 * @param value The configuration parameter value
-	 */
-	public void addConfigParam(IFloodlightModule mod, String key, String value) {
-	    Map<String, String> moduleParams = configParams.get(mod.getClass());
-	    if (moduleParams == null) {
-	        moduleParams = new HashMap<String, String>();
-	        configParams.put(mod.getClass(), moduleParams);
-	    }
-	    moduleParams.put(key, value);
-	}
- }
+    @Override
+    public Collection<IFloodlightModule> getAllModules() {
+        return moduleSet;
+    }
+
+    public void setModuleSet(Collection<IFloodlightModule> modSet) {
+        this.moduleSet = modSet;
+    }
+
+    /**
+     * Gets the configuration parameter map for a module
+     *
+     * @param module The module to get the configuration map for, usually yourself
+     * @return A map containing all the configuration parameters for the module, may be empty
+     */
+    @Override
+    public Map<String, String> getConfigParams(IFloodlightModule module) {
+        Map<String, String> retMap = configParams.get(module.getClass());
+        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);
+        }
+
+        // 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)) {
+                for (Map.Entry<String, String> ent : configParams.get(c).entrySet()) {
+                    if (!retMap.containsKey(ent.getKey())) {
+                        retMap.put(ent.getKey(), ent.getValue());
+                    }
+                }
+            }
+        }
+
+        return retMap;
+    }
+
+    /**
+     * Adds a configuration parameter for a module
+     *
+     * @param mod   The fully qualified module name to add the parameter to
+     * @param key   The configuration parameter key
+     * @param value The configuration parameter value
+     */
+    public void addConfigParam(IFloodlightModule mod, String key, String value) {
+        Map<String, String> moduleParams = configParams.get(mod.getClass());
+        if (moduleParams == null) {
+            moduleParams = new HashMap<String, String>();
+            configParams.put(mod.getClass(), moduleParams);
+        }
+        moduleParams.put(key, value);
+    }
+}
diff --git a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleException.java b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleException.java
index 20ccc86..8519a3c 100644
--- a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleException.java
+++ b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleException.java
@@ -1,9 +1,9 @@
 package net.floodlightcontroller.core.module;
 
 public class FloodlightModuleException extends Exception {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	public FloodlightModuleException(String error) {
-		super(error);
-	}
+    public FloodlightModuleException(String error) {
+        super(error);
+    }
 }
diff --git a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java
index 5ae7914..6913b1c 100644
--- a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java
+++ b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java
@@ -26,143 +26,145 @@
 
 /**
  * Finds all Floodlight modules in the class path and loads/starts them.
- * @author alexreimers
  *
+ * @author alexreimers
  */
 public class FloodlightModuleLoader {
-    protected final static Logger logger = 
+    protected final static Logger logger =
             LoggerFactory.getLogger(FloodlightModuleLoader.class);
 
     protected static Map<Class<? extends IFloodlightService>,
-                  Collection<IFloodlightModule>> serviceMap;
+            Collection<IFloodlightModule>> serviceMap;
     protected static Map<IFloodlightModule,
-                  Collection<Class<? extends 
-                                   IFloodlightService>>> moduleServiceMap;
+            Collection<Class<? extends
+                    IFloodlightService>>> moduleServiceMap;
     protected static Map<String, IFloodlightModule> moduleNameMap;
     protected static Object lock = new Object();
-    
+
     protected FloodlightModuleContext floodlightModuleContext;
 
     public static final String FLOODLIGHT_MODULES_KEY =
             "floodlight.modules";
-    
-	public FloodlightModuleLoader() {
-	    floodlightModuleContext = new FloodlightModuleContext();
-	}
-	
-	/**
-	 * Finds all IFloodlightModule(s) in the classpath. It creates 3 Maps.
-	 * serviceMap -> Maps a service to a module
-	 * moduleServiceMap -> Maps a module to all the services it provides
-	 * moduleNameMap -> Maps the string name to the module
-	 * @throws FloodlightModuleException If two modules are specified in the configuration
-	 * that provide the same service.
-	 */
-	protected static void findAllModules(Collection<String> mList) throws FloodlightModuleException {
-	    synchronized (lock) {
-	        if (serviceMap != null) return;
-	        serviceMap = 
-	                new HashMap<Class<? extends IFloodlightService>,
-	                            Collection<IFloodlightModule>>();
-	        moduleServiceMap = 
-	                new HashMap<IFloodlightModule,
-	                            Collection<Class<? extends 
-	                                       IFloodlightService>>>();
-	        moduleNameMap = new HashMap<String, IFloodlightModule>();
-	        
-	        // Get all the current modules in the classpath
-	        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-	        ServiceLoader<IFloodlightModule> moduleLoader
-	            = ServiceLoader.load(IFloodlightModule.class, cl);
-	        // Iterate for each module, iterate through and add it's services
-	        Iterator<IFloodlightModule> moduleIter = moduleLoader.iterator();
-	        while (moduleIter.hasNext()) {
-	        	IFloodlightModule m = null;
-	        	try {
-	        		m = moduleIter.next();
-	        	} catch (ServiceConfigurationError sce) {
-	        		logger.debug("Could not find module: {}", sce.getMessage());
-	        		//moduleIter.remove();
-	        		continue;
-	        	}
-	        //}
-	        //for (IFloodlightModule m : moduleLoader) {
-	            if (logger.isDebugEnabled()) {
-	                logger.debug("Found module " + m.getClass().getName());
-	            }
 
-	            // Set up moduleNameMap
-	            moduleNameMap.put(m.getClass().getCanonicalName(), m);
+    public FloodlightModuleLoader() {
+        floodlightModuleContext = new FloodlightModuleContext();
+    }
 
-	            // Set up serviceMap
-	            Collection<Class<? extends IFloodlightService>> servs =
-	                    m.getModuleServices();
-	            if (servs != null) {
-	                moduleServiceMap.put(m, servs);
-	                for (Class<? extends IFloodlightService> s : servs) {
-	                    Collection<IFloodlightModule> mods = 
-	                            serviceMap.get(s);
-	                    if (mods == null) {
-	                        mods = new ArrayList<IFloodlightModule>();
-	                        serviceMap.put(s, mods);
-	                    }
-	                    mods.add(m);
-	                    // Make sure they haven't specified duplicate modules in the config
-	                    int dupInConf = 0;
-	                    for (IFloodlightModule cMod : mods) {
-	                        if (mList.contains(cMod.getClass().getCanonicalName()))
-	                            dupInConf += 1;
-	                    }
-	                    
-	                    if (dupInConf > 1) {
-	                        String duplicateMods = "";
+    /**
+     * Finds all IFloodlightModule(s) in the classpath. It creates 3 Maps.
+     * serviceMap -> Maps a service to a module
+     * moduleServiceMap -> Maps a module to all the services it provides
+     * moduleNameMap -> Maps the string name to the module
+     *
+     * @throws FloodlightModuleException If two modules are specified in the configuration
+     *                                   that provide the same service.
+     */
+    protected static void findAllModules(Collection<String> mList) throws FloodlightModuleException {
+        synchronized (lock) {
+            if (serviceMap != null) return;
+            serviceMap =
+                    new HashMap<Class<? extends IFloodlightService>,
+                            Collection<IFloodlightModule>>();
+            moduleServiceMap =
+                    new HashMap<IFloodlightModule,
+                            Collection<Class<? extends
+                                    IFloodlightService>>>();
+            moduleNameMap = new HashMap<String, IFloodlightModule>();
+
+            // Get all the current modules in the classpath
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            ServiceLoader<IFloodlightModule> moduleLoader
+                    = ServiceLoader.load(IFloodlightModule.class, cl);
+            // Iterate for each module, iterate through and add it's services
+            Iterator<IFloodlightModule> moduleIter = moduleLoader.iterator();
+            while (moduleIter.hasNext()) {
+                IFloodlightModule m = null;
+                try {
+                    m = moduleIter.next();
+                } catch (ServiceConfigurationError sce) {
+                    logger.debug("Could not find module: {}", sce.getMessage());
+                    //moduleIter.remove();
+                    continue;
+                }
+                //}
+                //for (IFloodlightModule m : moduleLoader) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Found module " + m.getClass().getName());
+                }
+
+                // Set up moduleNameMap
+                moduleNameMap.put(m.getClass().getCanonicalName(), m);
+
+                // Set up serviceMap
+                Collection<Class<? extends IFloodlightService>> servs =
+                        m.getModuleServices();
+                if (servs != null) {
+                    moduleServiceMap.put(m, servs);
+                    for (Class<? extends IFloodlightService> s : servs) {
+                        Collection<IFloodlightModule> mods =
+                                serviceMap.get(s);
+                        if (mods == null) {
+                            mods = new ArrayList<IFloodlightModule>();
+                            serviceMap.put(s, mods);
+                        }
+                        mods.add(m);
+                        // Make sure they haven't specified duplicate modules in the config
+                        int dupInConf = 0;
+                        for (IFloodlightModule cMod : mods) {
+                            if (mList.contains(cMod.getClass().getCanonicalName()))
+                                dupInConf += 1;
+                        }
+
+                        if (dupInConf > 1) {
+                            String duplicateMods = "";
                             for (IFloodlightModule mod : mods) {
                                 duplicateMods += mod.getClass().getCanonicalName() + ", ";
                             }
-	                        throw new FloodlightModuleException("ERROR! The configuraiton" +
-	                                " file specifies more than one module that provides the service " +
-	                                s.getCanonicalName() +". Please specify only ONE of the " +
-	                                "following modules in the config file: " + duplicateMods);
-	                    }
-	                }
-	            }
-	        }
-	    }
-	}
-	
-	/**
-	 * Loads the modules from a specified configuration file.
-	 * @param fName The configuration file path
-	 * @return An IFloodlightModuleContext with all the modules to be started
-	 * @throws FloodlightModuleException
-	 */
-	@LogMessageDocs({
-	    @LogMessageDoc(level="INFO",
-	            message="Loading modules from file {file name}",
-	            explanation="The controller is initializing its module " +
-	                    "configuration from the specified properties file"),
-	    @LogMessageDoc(level="INFO",
-	            message="Loading default modules",
-	            explanation="The controller is initializing its module " +
-	                    "configuration to the default configuration"),
-	    @LogMessageDoc(level="ERROR",
-	            message="Could not load module configuration file",
-	            explanation="The controller failed to read the " +
-	            		"module configuration file",
-	            recommendation="Verify that the module configuration is " +
-	            		"present. " + LogMessageDoc.CHECK_CONTROLLER),
-	    @LogMessageDoc(level="ERROR",
-                message="Could not load default modules",
-                explanation="The controller failed to read the default " +
-                        "module configuration",
-                recommendation=LogMessageDoc.CHECK_CONTROLLER)
-	})
-	public IFloodlightModuleContext loadModulesFromConfig(String fName) 
-	        throws FloodlightModuleException {
-	    Properties prop = new Properties();
-	    
-	    File f = new File(fName);
-	    if (f.isFile()) {
+                            throw new FloodlightModuleException("ERROR! The configuraiton" +
+                                    " file specifies more than one module that provides the service " +
+                                    s.getCanonicalName() + ". Please specify only ONE of the " +
+                                    "following modules in the config file: " + duplicateMods);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Loads the modules from a specified configuration file.
+     *
+     * @param fName The configuration file path
+     * @return An IFloodlightModuleContext with all the modules to be started
+     * @throws FloodlightModuleException
+     */
+    @LogMessageDocs({
+            @LogMessageDoc(level = "INFO",
+                    message = "Loading modules from file {file name}",
+                    explanation = "The controller is initializing its module " +
+                            "configuration from the specified properties file"),
+            @LogMessageDoc(level = "INFO",
+                    message = "Loading default modules",
+                    explanation = "The controller is initializing its module " +
+                            "configuration to the default configuration"),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Could not load module configuration file",
+                    explanation = "The controller failed to read the " +
+                            "module configuration file",
+                    recommendation = "Verify that the module configuration is " +
+                            "present. " + LogMessageDoc.CHECK_CONTROLLER),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Could not load default modules",
+                    explanation = "The controller failed to read the default " +
+                            "module configuration",
+                    recommendation = LogMessageDoc.CHECK_CONTROLLER)
+    })
+    public IFloodlightModuleContext loadModulesFromConfig(String fName)
+            throws FloodlightModuleException {
+        Properties prop = new Properties();
+
+        File f = new File(fName);
+        if (f.isFile()) {
             logger.info("Loading modules from file {}", fName);
             try {
                 prop.load(new FileInputStream(fName));
@@ -174,40 +176,41 @@
             logger.error("No configuration file specified");
             System.exit(1);
         }
-        
+
         String moduleList = prop.getProperty(FLOODLIGHT_MODULES_KEY)
-                                .replaceAll("\\s", "");
+                .replaceAll("\\s", "");
         Collection<String> configMods = new ArrayList<String>();
         configMods.addAll(Arrays.asList(moduleList.split(",")));
         return loadModulesFromList(configMods, prop);
-	}
-	
-	/**
-	 * Loads modules (and their dependencies) specified in the list
-	 * @param mList The array of fully qualified module names
-	 * @param ignoreList The list of Floodlight services NOT to 
-	 * load modules for. Used for unit testing.
-	 * @return The ModuleContext containing all the loaded modules
-	 * @throws FloodlightModuleException
-	 */
-	protected IFloodlightModuleContext loadModulesFromList(Collection<String> configMods, Properties prop, 
-			Collection<IFloodlightService> ignoreList) throws FloodlightModuleException {
-		logger.debug("Starting module loader");
-		if (logger.isDebugEnabled() && ignoreList != null)
-			logger.debug("Not loading module services " + ignoreList.toString());
+    }
+
+    /**
+     * Loads modules (and their dependencies) specified in the list
+     *
+     * @param mList      The array of fully qualified module names
+     * @param ignoreList The list of Floodlight services NOT to
+     *                   load modules for. Used for unit testing.
+     * @return The ModuleContext containing all the loaded modules
+     * @throws FloodlightModuleException
+     */
+    protected IFloodlightModuleContext loadModulesFromList(Collection<String> configMods, Properties prop,
+                                                           Collection<IFloodlightService> ignoreList) throws FloodlightModuleException {
+        logger.debug("Starting module loader");
+        if (logger.isDebugEnabled() && ignoreList != null)
+            logger.debug("Not loading module services " + ignoreList.toString());
 
         findAllModules(configMods);
-        
+
         Collection<IFloodlightModule> moduleSet = new ArrayList<IFloodlightModule>();
         Map<Class<? extends IFloodlightService>, IFloodlightModule> moduleMap =
                 new HashMap<Class<? extends IFloodlightService>,
-                            IFloodlightModule>();
+                        IFloodlightModule>();
 
         Queue<String> moduleQ = new LinkedList<String>();
         // Add the explicitly configured modules to the q
         moduleQ.addAll(configMods);
         Set<String> modsVisited = new HashSet<String>();
-        
+
         while (!moduleQ.isEmpty()) {
             String moduleName = moduleQ.remove();
             if (modsVisited.contains(moduleName))
@@ -215,37 +218,37 @@
             modsVisited.add(moduleName);
             IFloodlightModule module = moduleNameMap.get(moduleName);
             if (module == null) {
-                throw new FloodlightModuleException("Module " + 
+                throw new FloodlightModuleException("Module " +
                         moduleName + " not found");
             }
             // If the module provies a service that is in the
             // services ignorelist don't load it.
             if ((ignoreList != null) && (module.getModuleServices() != null)) {
-            	for (IFloodlightService ifs : ignoreList) {
-            		for (Class<?> intsIgnore : ifs.getClass().getInterfaces()) {
-            			//System.out.println(intsIgnore.getName());
-        				// Check that the interface extends IFloodlightService
-        				//if (intsIgnore.isAssignableFrom(IFloodlightService.class)) {
-            			//System.out.println(module.getClass().getName());
-    					if (intsIgnore.isAssignableFrom(module.getClass())) {
-    						// We now ignore loading this module.
-    						logger.debug("Not loading module " + 
-    									 module.getClass().getCanonicalName() +
-    									 " because interface " +
-    									 intsIgnore.getCanonicalName() +
-    									 " is in the ignore list.");
-    						
-    						continue;
-    					}
-        				//}
-            		}
-            	}
+                for (IFloodlightService ifs : ignoreList) {
+                    for (Class<?> intsIgnore : ifs.getClass().getInterfaces()) {
+                        //System.out.println(intsIgnore.getName());
+                        // Check that the interface extends IFloodlightService
+                        //if (intsIgnore.isAssignableFrom(IFloodlightService.class)) {
+                        //System.out.println(module.getClass().getName());
+                        if (intsIgnore.isAssignableFrom(module.getClass())) {
+                            // We now ignore loading this module.
+                            logger.debug("Not loading module " +
+                                    module.getClass().getCanonicalName() +
+                                    " because interface " +
+                                    intsIgnore.getCanonicalName() +
+                                    " is in the ignore list.");
+
+                            continue;
+                        }
+                        //}
+                    }
+                }
             }
-            
+
             // Add the module to be loaded
             addModule(moduleMap, moduleSet, module);
             // Add it's dep's to the queue
-            Collection<Class<? extends IFloodlightService>> deps = 
+            Collection<Class<? extends IFloodlightService>> deps =
                     module.getModuleDependencies();
             if (deps != null) {
                 for (Class<? extends IFloodlightService> c : deps) {
@@ -275,11 +278,11 @@
                                 for (IFloodlightModule mod : mods) {
                                     duplicateMods += mod.getClass().getCanonicalName() + ", ";
                                 }
-                                throw new FloodlightModuleException("ERROR! Found more " + 
-                                    "than one (" + mods.size() + ") IFloodlightModules that provides " +
-                                    "service " + c.toString() + 
-                                    ". Please specify one of the following modules in the config: " + 
-                                    duplicateMods);
+                                throw new FloodlightModuleException("ERROR! Found more " +
+                                        "than one (" + mods.size() + ") IFloodlightModules that provides " +
+                                        "service " + c.toString() +
+                                        ". Please specify one of the following modules in the config: " +
+                                        duplicateMods);
                             }
                         }
                     }
@@ -287,93 +290,95 @@
             }
         }
 
-	//
-	// Reorder the moduleSet to take into account the module dependencies:
-	// If a module depends on the service provided by another module, the
-	// latter should be included before the former.
-	//
-	Collection<IFloodlightModule> orderedModuleSet =
-	    new ArrayList<IFloodlightModule>();
-	while (! moduleSet.isEmpty()) {
-	    //
-	    // Evaluate each module in the unsorted collection: if all its
-	    // dependencies are in the orderedModuleSet, then add it to the
-	    // orderedModuleSet.
-	    //
-	    boolean moduleWasSorted = false;
-	    for (IFloodlightModule module : moduleSet) {
-		Collection<Class<? extends IFloodlightService>> deps =
-		    module.getModuleDependencies();
-		boolean allDepsFound = true;
-		if (deps != null) {
-		    for (Class<? extends IFloodlightService> c : deps) {
-			IFloodlightModule m = moduleMap.get(c);
-			// NOTE: Earlier we checked that the module exists
-			assert(m != null);
-			if (! orderedModuleSet.contains(m)) {
-			    allDepsFound = false;
-			    break;
-			}
-		    }
-		}
+        //
+        // Reorder the moduleSet to take into account the module dependencies:
+        // If a module depends on the service provided by another module, the
+        // latter should be included before the former.
+        //
+        Collection<IFloodlightModule> orderedModuleSet =
+                new ArrayList<IFloodlightModule>();
+        while (!moduleSet.isEmpty()) {
+            //
+            // Evaluate each module in the unsorted collection: if all its
+            // dependencies are in the orderedModuleSet, then add it to the
+            // orderedModuleSet.
+            //
+            boolean moduleWasSorted = false;
+            for (IFloodlightModule module : moduleSet) {
+                Collection<Class<? extends IFloodlightService>> deps =
+                        module.getModuleDependencies();
+                boolean allDepsFound = true;
+                if (deps != null) {
+                    for (Class<? extends IFloodlightService> c : deps) {
+                        IFloodlightModule m = moduleMap.get(c);
+                        // NOTE: Earlier we checked that the module exists
+                        assert (m != null);
+                        if (!orderedModuleSet.contains(m)) {
+                            allDepsFound = false;
+                            break;
+                        }
+                    }
+                }
 
-		// Move the module to the sorted collection
-		if (allDepsFound) {
-		    orderedModuleSet.add(module);
-		    moduleSet.remove(module);
-		    moduleWasSorted = true;
-		    break;
-		}
-	    }
+                // Move the module to the sorted collection
+                if (allDepsFound) {
+                    orderedModuleSet.add(module);
+                    moduleSet.remove(module);
+                    moduleWasSorted = true;
+                    break;
+                }
+            }
 
-	    //
-	    // Test for cyclic depenency:
-	    // If no module was sorted, but there are still unsorted modules
-	    // then there is cyclic dependency.
-	    //
-	    if ((! moduleWasSorted) && (! moduleSet.isEmpty())) {
-		String errorMsg = "";
-		for (IFloodlightModule module : moduleSet) {
-		    if (! errorMsg.isEmpty())
-			errorMsg += ", ";
-		    errorMsg += module.getClass().getName();
-		}
-		errorMsg = "ERROR! Cyclic service dependency/dependencies among the following modules: " + errorMsg;
-		throw new FloodlightModuleException(errorMsg);
-	    }
-	}
-	moduleSet = orderedModuleSet;
+            //
+            // Test for cyclic depenency:
+            // If no module was sorted, but there are still unsorted modules
+            // then there is cyclic dependency.
+            //
+            if ((!moduleWasSorted) && (!moduleSet.isEmpty())) {
+                String errorMsg = "";
+                for (IFloodlightModule module : moduleSet) {
+                    if (!errorMsg.isEmpty())
+                        errorMsg += ", ";
+                    errorMsg += module.getClass().getName();
+                }
+                errorMsg = "ERROR! Cyclic service dependency/dependencies among the following modules: " + errorMsg;
+                throw new FloodlightModuleException(errorMsg);
+            }
+        }
+        moduleSet = orderedModuleSet;
 
         floodlightModuleContext.setModuleSet(moduleSet);
         parseConfigParameters(prop);
         initModules(moduleSet);
         startupModules(moduleSet);
-        
+
         return floodlightModuleContext;
-	}
-	
-	/**
-	 * Loads modules (and their dependencies) specified in the list.
-	 * @param configMods The collection of fully qualified module names to load.
-	 * @param prop The list of properties that are configuration options.
-	 * @return The ModuleContext containing all the loaded modules.
-	 * @throws FloodlightModuleException
-	 */
-	public IFloodlightModuleContext loadModulesFromList(Collection<String> configMods, Properties prop) 
-            throws FloodlightModuleException {
-		return loadModulesFromList(configMods, prop, null);
     }
-	
-	/**
-	 * Add a module to the set of modules to load and register its services
-	 * @param moduleMap the module map
-	 * @param moduleSet the module set
-	 * @param module the module to add
-	 */
-	protected void addModule(Map<Class<? extends IFloodlightService>, 
-                                           IFloodlightModule> moduleMap,
-                            Collection<IFloodlightModule> moduleSet,
-                            IFloodlightModule module) {
+
+    /**
+     * Loads modules (and their dependencies) specified in the list.
+     *
+     * @param configMods The collection of fully qualified module names to load.
+     * @param prop       The list of properties that are configuration options.
+     * @return The ModuleContext containing all the loaded modules.
+     * @throws FloodlightModuleException
+     */
+    public IFloodlightModuleContext loadModulesFromList(Collection<String> configMods, Properties prop)
+            throws FloodlightModuleException {
+        return loadModulesFromList(configMods, prop, null);
+    }
+
+    /**
+     * Add a module to the set of modules to load and register its services
+     *
+     * @param moduleMap the module map
+     * @param moduleSet the module set
+     * @param module    the module to add
+     */
+    protected void addModule(Map<Class<? extends IFloodlightService>,
+            IFloodlightModule> moduleMap,
+                             Collection<IFloodlightModule> moduleSet,
+                             IFloodlightModule module) {
         if (!moduleSet.contains(module)) {
             Collection<Class<? extends IFloodlightService>> servs =
                     moduleServiceMap.get(module);
@@ -383,57 +388,59 @@
             }
             moduleSet.add(module);
         }
-	}
+    }
 
     /**
      * Allocate  service implementations and then init all the modules
+     *
      * @param moduleSet The set of modules to call their init function on
      * @throws FloodlightModuleException If a module can not properly be loaded
      */
-    protected void initModules(Collection<IFloodlightModule> moduleSet) 
-                                           throws FloodlightModuleException {
-        for (IFloodlightModule module : moduleSet) {            
+    protected void initModules(Collection<IFloodlightModule> moduleSet)
+            throws FloodlightModuleException {
+        for (IFloodlightModule module : moduleSet) {
             // Get the module's service instance(s)
-            Map<Class<? extends IFloodlightService>, 
-                IFloodlightService> simpls = module.getServiceImpls();
+            Map<Class<? extends IFloodlightService>,
+                    IFloodlightService> simpls = module.getServiceImpls();
 
             // add its services to the context
             if (simpls != null) {
-                for (Entry<Class<? extends IFloodlightService>, 
+                for (Entry<Class<? extends IFloodlightService>,
                         IFloodlightService> s : simpls.entrySet()) {
                     if (logger.isDebugEnabled()) {
-                        logger.debug("Setting " + s.getValue() + 
-                                     "  as provider for " + 
-                                     s.getKey().getCanonicalName());
+                        logger.debug("Setting " + s.getValue() +
+                                "  as provider for " +
+                                s.getKey().getCanonicalName());
                     }
                     if (floodlightModuleContext.getServiceImpl(s.getKey()) == null) {
                         floodlightModuleContext.addService(s.getKey(),
-                                                           s.getValue());
+                                s.getValue());
                     } else {
                         throw new FloodlightModuleException("Cannot set "
-                                                            + s.getValue()
-                                                            + " as the provider for "
-                                                            + s.getKey().getCanonicalName()
-                                                            + " because "
-                                                            + floodlightModuleContext.getServiceImpl(s.getKey())
-                                                            + " already provides it");
+                                + s.getValue()
+                                + " as the provider for "
+                                + s.getKey().getCanonicalName()
+                                + " because "
+                                + floodlightModuleContext.getServiceImpl(s.getKey())
+                                + " already provides it");
                     }
                 }
             }
         }
-        
+
         for (IFloodlightModule module : moduleSet) {
             // init the module
             if (logger.isDebugEnabled()) {
-                logger.debug("Initializing " + 
-                             module.getClass().getCanonicalName());
+                logger.debug("Initializing " +
+                        module.getClass().getCanonicalName());
             }
             module.init(floodlightModuleContext);
         }
     }
-    
+
     /**
      * Call each loaded module's startup method
+     *
      * @param moduleSet the module set to start up
      */
     protected void startupModules(Collection<IFloodlightModule> moduleSet) {
@@ -444,19 +451,20 @@
             m.startUp(floodlightModuleContext);
         }
     }
-    
+
     /**
      * Parses configuration parameters for each module
+     *
      * @param prop The properties file to use
      */
-    @LogMessageDoc(level="WARN",
-                   message="Module {module} not found or loaded. " +
-                           "Not adding configuration option {key} = {value}",
-                   explanation="Ignoring a configuration parameter for a " +
-                   		"module that is not loaded.")
+    @LogMessageDoc(level = "WARN",
+            message = "Module {module} not found or loaded. " +
+                    "Not adding configuration option {key} = {value}",
+            explanation = "Ignoring a configuration parameter for a " +
+                    "module that is not loaded.")
     protected void parseConfigParameters(Properties prop) {
-    	if (prop == null) return;
-    	
+        if (prop == null) return;
+
         Enumeration<?> e = prop.propertyNames();
         while (e.hasMoreElements()) {
             String key = (String) e.nextElement();
@@ -464,7 +472,7 @@
             if (key.equals(FLOODLIGHT_MODULES_KEY)) {
                 continue;
             }
-            
+
             String configValue = null;
             int lastPeriod = key.lastIndexOf(".");
             String moduleName = key.substring(0, lastPeriod);
@@ -476,12 +484,12 @@
             } else {
                 configValue = prop.getProperty(key);
             }
-            
+
             IFloodlightModule mod = moduleNameMap.get(moduleName);
             if (mod == null) {
                 logger.warn("Module {} not found or loaded. " +
-                		    "Not adding configuration option {} = {}", 
-                            new Object[]{moduleName, configKey, configValue});
+                        "Not adding configuration option {} = {}",
+                        new Object[]{moduleName, configKey, configValue});
             } else {
                 floodlightModuleContext.addConfigParam(mod, configKey, configValue);
             }
diff --git a/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java b/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java
index f8b196b..c616bc0 100644
--- a/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java
+++ b/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java
@@ -6,7 +6,7 @@
 
 /**
  * Defines an interface for loadable Floodlight modules.
- * 
+ * <p/>
  * At a high level, these functions are called in the following order:
  * <ol>
  * <li> getServices() : what services does this module provide
@@ -14,61 +14,64 @@
  * <li> init() : internal initializations (don't touch other modules)
  * <li> startUp() : external initializations (<em>do</em> touch other modules)
  * </ol>
- * 
+ *
  * @author alexreimers
  */
 public interface IFloodlightModule {
-	
-	/**
-	 * Return the list of interfaces that this module implements.
-	 * All interfaces must inherit IFloodlightService
-	 * @return
-	 */
-	
-	public Collection<Class<? extends IFloodlightService>> getModuleServices();
-	
-	/**
-	 * Instantiate (as needed) and return objects that implement each
-	 * of the services exported by this module.  The map returned maps
-	 * the implemented service to the object.  The object could be the
-	 * same object or different objects for different exported services.
-	 * @return The map from service interface class to service implementation
-	 */
-	public Map<Class<? extends IFloodlightService>,
-	           IFloodlightService> getServiceImpls();
-	
-	/**
-	 * Get a list of Modules that this module depends on.  The module system
-	 * will ensure that each these dependencies is resolved before the 
-	 * subsequent calls to init().
-	 * @return The Collection of IFloodlightServices that this module depends
-	 *         on.
-	 */
-	
-	public Collection<Class<? extends IFloodlightService>> getModuleDependencies();
-	
-	/**
-	 * This is a hook for each module to do its <em>internal</em> initialization, 
-	 * e.g., call setService(context.getService("Service"))
-	 * 
-	 * All module dependencies are resolved when this is called, but not every module 
-	 * is initialized.
-	 * 
-	 * @param context
-	 * @throws FloodlightModuleException
-	 */
-	
-	void init(FloodlightModuleContext context) throws FloodlightModuleException;
-	
-	/**
-	 * This is a hook for each module to do its <em>external</em> initializations,
-	 * e.g., register for callbacks or query for state in other modules
-	 * 
-	 * It is expected that this function will not block and that modules that want
-	 * non-event driven CPU will spawn their own threads.
-	 * 
-	 * @param context
-	 */
-	
-	void startUp(FloodlightModuleContext context); 
+
+    /**
+     * Return the list of interfaces that this module implements.
+     * All interfaces must inherit IFloodlightService
+     *
+     * @return
+     */
+
+    public Collection<Class<? extends IFloodlightService>> getModuleServices();
+
+    /**
+     * Instantiate (as needed) and return objects that implement each
+     * of the services exported by this module.  The map returned maps
+     * the implemented service to the object.  The object could be the
+     * same object or different objects for different exported services.
+     *
+     * @return The map from service interface class to service implementation
+     */
+    public Map<Class<? extends IFloodlightService>,
+            IFloodlightService> getServiceImpls();
+
+    /**
+     * Get a list of Modules that this module depends on.  The module system
+     * will ensure that each these dependencies is resolved before the
+     * subsequent calls to init().
+     *
+     * @return The Collection of IFloodlightServices that this module depends
+     * on.
+     */
+
+    public Collection<Class<? extends IFloodlightService>> getModuleDependencies();
+
+    /**
+     * This is a hook for each module to do its <em>internal</em> initialization,
+     * e.g., call setService(context.getService("Service"))
+     * <p/>
+     * All module dependencies are resolved when this is called, but not every module
+     * is initialized.
+     *
+     * @param context
+     * @throws FloodlightModuleException
+     */
+
+    void init(FloodlightModuleContext context) throws FloodlightModuleException;
+
+    /**
+     * This is a hook for each module to do its <em>external</em> initializations,
+     * e.g., register for callbacks or query for state in other modules
+     * <p/>
+     * It is expected that this function will not block and that modules that want
+     * non-event driven CPU will spawn their own threads.
+     *
+     * @param context
+     */
+
+    void startUp(FloodlightModuleContext context);
 }
diff --git a/src/main/java/net/floodlightcontroller/core/module/IFloodlightModuleContext.java b/src/main/java/net/floodlightcontroller/core/module/IFloodlightModuleContext.java
index 2c058a7..cdaadc3 100644
--- a/src/main/java/net/floodlightcontroller/core/module/IFloodlightModuleContext.java
+++ b/src/main/java/net/floodlightcontroller/core/module/IFloodlightModuleContext.java
@@ -3,31 +3,35 @@
 import java.util.Collection;
 import java.util.Map;
 
-	
-public interface IFloodlightModuleContext {	
+
+public interface IFloodlightModuleContext {
     /**
      * Retrieves a casted version of a module from the registry.
+     *
      * @param name The IFloodlightService object type
      * @return The IFloodlightService
-     * @throws FloodlightModuleException If the module was not found 
-     * or a ClassCastException was encountered.
+     * @throws FloodlightModuleException If the module was not found
+     *                                   or a ClassCastException was encountered.
      */
     public <T extends IFloodlightService> T getServiceImpl(Class<T> service);
-    
+
     /**
      * Returns all loaded services
+     *
      * @return A collection of service classes that have been loaded
      */
     public Collection<Class<? extends IFloodlightService>> getAllServices();
-    
+
     /**
      * Returns all loaded modules
+     *
      * @return All Floodlight modules that are going to be loaded
      */
     public Collection<IFloodlightModule> getAllModules();
-    
+
     /**
      * Gets module specific configuration parameters.
+     *
      * @param module The module to get the configuration parameters for
      * @return A key, value map of the configuration options
      */
diff --git a/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java b/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java
index 5974b3a..b59c62b 100644
--- a/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java
+++ b/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java
@@ -1,10 +1,10 @@
 package net.floodlightcontroller.core.module;
 
 /**
- * This is the base interface for any IFloodlightModule package that provides 
+ * This is the base interface for any IFloodlightModule package that provides
  * a service.
- * @author alexreimers
  *
+ * @author alexreimers
  */
 public abstract interface IFloodlightService {
     // This space is intentionally left blank....don't touch it
diff --git a/src/main/java/net/floodlightcontroller/core/module/ModuleLoaderResource.java b/src/main/java/net/floodlightcontroller/core/module/ModuleLoaderResource.java
index 556b26d..21cbfc3 100644
--- a/src/main/java/net/floodlightcontroller/core/module/ModuleLoaderResource.java
+++ b/src/main/java/net/floodlightcontroller/core/module/ModuleLoaderResource.java
@@ -13,91 +13,94 @@
 
 /**
  * Returns list of modules loaded by Floodlight.
+ *
  * @author Rob Sherwood
  */
 public class ModuleLoaderResource extends ServerResource {
-    protected final static Logger log = 
+    protected final static Logger log =
             LoggerFactory.getLogger(ModuleLoaderResource.class);
-    
+
     /**
      * Retrieves information about loaded modules.
+     *
      * @return Information about loaded modules.
      */
     @Get("json")
     public Map<String, Object> retrieve() {
-    	return retrieveInternal(false);
+        return retrieveInternal(false);
     }
-    
+
     /**
      * Retrieves all modules and their dependencies available
      * to Floodlight.
+     *
      * @param loadedOnly Whether to return all modules available or only the ones loaded.
      * @return Information about modules available or loaded.
      */
-    public Map<String, Object> retrieveInternal(boolean loadedOnly) {    
+    public Map<String, Object> retrieveInternal(boolean loadedOnly) {
         Map<String, Object> model = new HashMap<String, Object>();
 
         Set<String> loadedModules = new HashSet<String>();
         for (Object val : getContext().getAttributes().values()) {
-        	if ((val instanceof IFloodlightModule) || (val instanceof IFloodlightService)) {
-        		String serviceImpl = val.getClass().getCanonicalName();
-        		loadedModules.add(serviceImpl);
-        		// log.debug("Tracking serviceImpl " + serviceImpl);
-        	}
+            if ((val instanceof IFloodlightModule) || (val instanceof IFloodlightService)) {
+                String serviceImpl = val.getClass().getCanonicalName();
+                loadedModules.add(serviceImpl);
+                // log.debug("Tracking serviceImpl " + serviceImpl);
+            }
         }
 
-        for (String moduleName : 
-        				FloodlightModuleLoader.moduleNameMap.keySet() ) {
-        	Map<String,Object> moduleInfo = new HashMap<String, Object>();
+        for (String moduleName :
+                FloodlightModuleLoader.moduleNameMap.keySet()) {
+            Map<String, Object> moduleInfo = new HashMap<String, Object>();
 
-        	IFloodlightModule module = 
-        				FloodlightModuleLoader.moduleNameMap.get(
-        						moduleName);
-        		
-        	Collection<Class<? extends IFloodlightService>> deps = 
-        			module.getModuleDependencies();
-        	if ( deps == null)
-            	deps = new HashSet<Class<? extends IFloodlightService>>();
-        	Map<String,Object> depsMap = new HashMap<String, Object> ();
-        	for (Class<? extends IFloodlightService> service : deps) {
-        		Object serviceImpl = getContext().getAttributes().get(service.getCanonicalName());
-        		if (serviceImpl != null)
-        			depsMap.put(service.getCanonicalName(), serviceImpl.getClass().getCanonicalName());
-        		else
-        			depsMap.put(service.getCanonicalName(), "<unresolved>");
+            IFloodlightModule module =
+                    FloodlightModuleLoader.moduleNameMap.get(
+                            moduleName);
 
-        	}
+            Collection<Class<? extends IFloodlightService>> deps =
+                    module.getModuleDependencies();
+            if (deps == null)
+                deps = new HashSet<Class<? extends IFloodlightService>>();
+            Map<String, Object> depsMap = new HashMap<String, Object>();
+            for (Class<? extends IFloodlightService> service : deps) {
+                Object serviceImpl = getContext().getAttributes().get(service.getCanonicalName());
+                if (serviceImpl != null)
+                    depsMap.put(service.getCanonicalName(), serviceImpl.getClass().getCanonicalName());
+                else
+                    depsMap.put(service.getCanonicalName(), "<unresolved>");
+
+            }
             moduleInfo.put("depends", depsMap);
-        	
-            Collection<Class<? extends IFloodlightService>> provides = 
-            		module.getModuleServices();
-        	if ( provides == null)
-            	provides = new HashSet<Class<? extends IFloodlightService>>();
-        	Map<String,Object> providesMap = new HashMap<String,Object>();
-        	for (Class<? extends IFloodlightService> service : provides) {
-        		providesMap.put(service.getCanonicalName(), module.getServiceImpls().get(service).getClass().getCanonicalName());
-        	}
-        	moduleInfo.put("provides", providesMap);            		
 
-    		moduleInfo.put("loaded", false);	// not loaded, by default
+            Collection<Class<? extends IFloodlightService>> provides =
+                    module.getModuleServices();
+            if (provides == null)
+                provides = new HashSet<Class<? extends IFloodlightService>>();
+            Map<String, Object> providesMap = new HashMap<String, Object>();
+            for (Class<? extends IFloodlightService> service : provides) {
+                providesMap.put(service.getCanonicalName(), module.getServiceImpls().get(service).getClass().getCanonicalName());
+            }
+            moduleInfo.put("provides", providesMap);
 
-        	// check if this module is loaded directly
-        	if (loadedModules.contains(module.getClass().getCanonicalName())) {
-        		moduleInfo.put("loaded", true);  			
-        	} else {
-        		// if not, then maybe one of the services it exports is loaded
-        		for (Class<? extends IFloodlightService> service : provides) {
-        			String modString = module.getServiceImpls().get(service).getClass().getCanonicalName();
-        			if (loadedModules.contains(modString))
-                		moduleInfo.put("loaded", true);
-        			/* else 
-        				log.debug("ServiceImpl not loaded " + modString); */
-        		}
-        	}
+            moduleInfo.put("loaded", false);        // not loaded, by default
 
-        	if ((Boolean)moduleInfo.get("loaded")|| !loadedOnly )
-        		model.put(moduleName, moduleInfo);
-        }            
+            // check if this module is loaded directly
+            if (loadedModules.contains(module.getClass().getCanonicalName())) {
+                moduleInfo.put("loaded", true);
+            } else {
+                // if not, then maybe one of the services it exports is loaded
+                for (Class<? extends IFloodlightService> service : provides) {
+                    String modString = module.getServiceImpls().get(service).getClass().getCanonicalName();
+                    if (loadedModules.contains(modString))
+                        moduleInfo.put("loaded", true);
+                                /* else 
+                                        log.debug("ServiceImpl not loaded " + modString); */
+                }
+            }
+
+            if ((Boolean) moduleInfo.get("loaded") || !loadedOnly)
+                model.put(moduleName, moduleInfo);
+        }
         return model;
     }
 }