blob: 91b317a2f75bad78d4f6a959f560c76eeafb4699 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.core;
2
3import org.kohsuke.args4j.CmdLineException;
4import org.kohsuke.args4j.CmdLineParser;
5
6import net.floodlightcontroller.core.internal.CmdLineSettings;
7import net.floodlightcontroller.core.module.FloodlightModuleException;
8import net.floodlightcontroller.core.module.FloodlightModuleLoader;
9import net.floodlightcontroller.core.module.IFloodlightModuleContext;
10import net.floodlightcontroller.restserver.IRestApiService;
11
12/**
13 * Host for the Floodlight main method
14 * @author alexreimers
15 */
16public class Main {
17
18 /**
19 * Main method to load configuration and modules
20 * @param args
21 * @throws FloodlightModuleException
22 */
23 public static void main(String[] args) throws FloodlightModuleException {
24 // Setup logger
25 System.setProperty("org.restlet.engine.loggerFacadeClass",
26 "org.restlet.ext.slf4j.Slf4jLoggerFacade");
27
28 CmdLineSettings settings = new CmdLineSettings();
29 CmdLineParser parser = new CmdLineParser(settings);
30 try {
31 parser.parseArgument(args);
32 } catch (CmdLineException e) {
33 parser.printUsage(System.out);
34 System.exit(1);
35 }
36
37 // Load modules
38 FloodlightModuleLoader fml = new FloodlightModuleLoader();
39 IFloodlightModuleContext moduleContext = fml.loadModulesFromConfig(settings.getModuleFile());
40 // Run REST server
41 IRestApiService restApi = moduleContext.getServiceImpl(IRestApiService.class);
42 restApi.run();
43 // Run the main floodlight module
44 IFloodlightProviderService controller =
45 moduleContext.getServiceImpl(IFloodlightProviderService.class);
46 // This call blocks, it has to be the last line in the main
47 controller.run();
48 }
49}