private void printUsage() { CommandLineInterfaceLibrary.printUsage(getClass()); }
public void run(String[] args) throws Exception { if (args.length == 0 || CommandLineInterfaceLibrary.wantsHelp(args)) { printUsage(); System.exit(-1); } Options options = new Options(); buildOptions(options); Daemonizer.buildOptions(options); Parser parser = new GnuParser(); final CommandLine cli = parser.parse(options, args); Daemonizer.handleDaemonization(cli); Set<Module> modules = new HashSet<>(); WMATARealtimeModule.addModuleAndDependencies(modules); _injector = Guice.createInjector( new URLConverter(), new FileConverter(), new PropertiesConverter(), new ConfigurationModule() { @Override protected void bindConfigurations() { bindEnvironmentVariables(); bindSystemProperties(); if (cli.hasOption(ARG_CONFIG_FILE)) { bindProperties(new File(cli.getOptionValue(ARG_CONFIG_FILE))); } } }, Rocoto.expandVariables(modules)); _injector.injectMembers(this); _tripUpdatesUrl = getConfigurationValue(URL.class, "tripUpdates.url"); if (_tripUpdatesUrl != null) { GtfsRealtimeServlet servlet = _injector.getInstance(GtfsRealtimeServlet.class); servlet.setUrl(_tripUpdatesUrl); servlet.setSource(_tripUpdatesExporter); } _tripUpdatesPath = getConfigurationValue(File.class, "tripUpdates.path"); if (_tripUpdatesPath != null) { GtfsRealtimeFileWriter writer = _injector.getInstance(GtfsRealtimeFileWriter.class); writer.setPath(_tripUpdatesPath); writer.setSource(_tripUpdatesExporter); } _vehiclePositionsUrl = getConfigurationValue(URL.class, "vehiclePositions.url"); if (_vehiclePositionsUrl != null) { GtfsRealtimeServlet servlet = _injector.getInstance(GtfsRealtimeServlet.class); servlet.setUrl(_vehiclePositionsUrl); servlet.setSource(_vehiclePositionsExporter); } _vehiclePositionsPath = getConfigurationValue(File.class, "vehiclePositions.path"); if (_vehiclePositionsPath != null) { GtfsRealtimeFileWriter writer = _injector.getInstance(GtfsRealtimeFileWriter.class); writer.setPath(_vehiclePositionsPath); writer.setSource(_vehiclePositionsExporter); } _alertsUrl = getConfigurationValue(URL.class, "alerts.url"); if (_alertsUrl != null) { GtfsRealtimeServlet servlet = _injector.getInstance(GtfsRealtimeServlet.class); servlet.setUrl(_alertsUrl); servlet.setSource(_alertsExporter); } _alertsPath = getConfigurationValue(File.class, "alerts.path"); if (_alertsPath != null) { GtfsRealtimeFileWriter writer = _injector.getInstance(GtfsRealtimeFileWriter.class); writer.setPath(_alertsPath); writer.setSource(_alertsExporter); } _lifecycleService.start(); }