Main for ONOS
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/Main.java b/src/main/java/net/onrc/onos/ofcontroller/core/Main.java
new file mode 100644
index 0000000..a80ac36
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/Main.java
@@ -0,0 +1,50 @@
+package net.onrc.onos.ofcontroller.core;
+
+import org.kohsuke.args4j.CmdLineException;
+import org.kohsuke.args4j.CmdLineParser;
+
+import net.floodlightcontroller.core.IFloodlightProviderService;
+import net.floodlightcontroller.core.internal.CmdLineSettings;
+import net.floodlightcontroller.core.module.FloodlightModuleException;
+import net.floodlightcontroller.core.module.FloodlightModuleLoader;
+import net.floodlightcontroller.core.module.IFloodlightModuleContext;
+import net.floodlightcontroller.restserver.IRestApiService;
+
+/**
+ * Host for the ONOS main method
+ * @author alexreimers
+ */
+public class Main {
+
+ /**
+ * Main method to load configuration and modules
+ * @param args
+ * @throws FloodlightModuleException
+ */
+ public static void main(String[] args) throws FloodlightModuleException {
+ // Setup logger
+ System.setProperty("org.restlet.engine.loggerFacadeClass",
+ "org.restlet.ext.slf4j.Slf4jLoggerFacade");
+
+ CmdLineSettings settings = new CmdLineSettings();
+ CmdLineParser parser = new CmdLineParser(settings);
+ try {
+ parser.parseArgument(args);
+ } catch (CmdLineException e) {
+ parser.printUsage(System.out);
+ System.exit(1);
+ }
+
+ // Load modules
+ FloodlightModuleLoader fml = new FloodlightModuleLoader();
+ IFloodlightModuleContext moduleContext = fml.loadModulesFromConfig(settings.getModuleFile());
+ // Run REST server
+ IRestApiService restApi = moduleContext.getServiceImpl(IRestApiService.class);
+ restApi.run();
+ // Run the main floodlight module
+ IFloodlightProviderService controller =
+ moduleContext.getServiceImpl(IFloodlightProviderService.class);
+ // This call blocks, it has to be the last line in the main
+ controller.run();
+ }
+}