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