List of usage examples for java.io File getAbsolutePath
public String getAbsolutePath()
From source file:at.nonblocking.cliwix.cli.CliwixCliClient.java
public static void main(String[] args) throws Exception { Options options = null;/*from w w w . java 2 s . c o m*/ try { options = Options.parseArgs(args); } catch (CliwixCliClientArgumentException e) { if (debug) console.printStacktrace(e); console.printlnError("Error: Invalid arguments: " + e.getMessage()); Options.printUsage(); console.exit(EXIT_STATUS_FAIL); return; } if (options == null || Options.COMMAND_HELP.equals(options.getCommand())) { Options.printUsage(); console.exit(0); return; } if (Options.COMMAND_CREATE_CONFIG.equals(options.getCommand())) { if (args.length < 2) { console.printlnError("Error: No config file location given!"); console.exit(EXIT_STATUS_FAIL); return; } File configFile = new File(args[1]); options.copyDefaultPropertiesTo(configFile); console.println("Configuration saved under: " + configFile.getAbsolutePath()); console.exit(0); return; } debug = options.isDebug(); String cliwixServerUrl = options.getServerCliwixUrl(); String username = options.getServerUsername(); String password = options.getServerPassword(); if (cliwixServerUrl == null) { console.printlnError("Error: Property server.cliwix.url is required!"); console.exit(EXIT_STATUS_FAIL); return; } cookieManager.clear(); //Login if (username != null && password != null) { JSONObject loginData = new JSONObject(); loginData.put("username", username); loginData.put("password", password); JSONObject result = postJson(cliwixServerUrl, "/services/login", loginData); JSONObject loginResult = (JSONObject) result.get("loginResult"); if (loginResult.get("succeeded") == Boolean.TRUE) { console.println("Login successful"); } else { console.printlnError("Error: Login failed! Reason: " + loginData.get("errorMessage")); console.exit(EXIT_STATUS_FAIL); return; } } else if (username != null) { console.printlnError("Error: If -user is set -pass is required!"); console.exit(EXIT_STATUS_FAIL); return; } else if (password != null) { console.printlnError("Error: If -pass is set -user is required!"); console.exit(EXIT_STATUS_FAIL); return; } switch (options.getCommand()) { case Options.COMMAND_INFO: doInfo(cliwixServerUrl, options); break; case Options.COMMAND_EXPORT: doExport(cliwixServerUrl, options); break; case Options.COMMAND_IMPORT: doImport(cliwixServerUrl, options); break; default: case Options.COMMAND_HELP: Options.printUsage(); } }
From source file:com.joseflavio.unhadegato.Concentrador.java
/** * @param args [0] = Diretrio de configuraes. *///from ww w . j ava 2 s.c o m public static void main(String[] args) { log.info(Util.getMensagem("unhadegato.iniciando")); try { /***********************/ if (args.length > 0) { if (!args[0].isEmpty()) { configuracao = new File(args[0]); if (!configuracao.isDirectory()) { String msg = Util.getMensagem("unhadegato.diretorio.incorreto"); System.out.println(msg); log.error(msg); System.exit(1); } } } if (configuracao == null) { configuracao = new File(System.getProperty("user.home") + File.separator + "unhadegato"); configuracao.mkdirs(); } log.info(Util.getMensagem("unhadegato.diretorio.endereco", configuracao.getAbsolutePath())); /***********************/ File confGeralArq = new File(configuracao, "unhadegato.conf"); if (!confGeralArq.exists()) { try (InputStream is = Concentrador.class.getResourceAsStream("/unhadegato.conf"); OutputStream os = new FileOutputStream(confGeralArq);) { IOUtils.copy(is, os); } } Properties confGeral = new Properties(); try (FileInputStream fis = new FileInputStream(confGeralArq)) { confGeral.load(fis); } String prop_porta = confGeral.getProperty("porta"); String prop_porta_segura = confGeral.getProperty("porta.segura"); String prop_seg_pri = confGeral.getProperty("seguranca.privada"); String prop_seg_pri_senha = confGeral.getProperty("seguranca.privada.senha"); String prop_seg_pri_tipo = confGeral.getProperty("seguranca.privada.tipo"); String prop_seg_pub = confGeral.getProperty("seguranca.publica"); String prop_seg_pub_senha = confGeral.getProperty("seguranca.publica.senha"); String prop_seg_pub_tipo = confGeral.getProperty("seguranca.publica.tipo"); if (StringUtil.tamanho(prop_porta) == 0) prop_porta = "8885"; if (StringUtil.tamanho(prop_porta_segura) == 0) prop_porta_segura = "8886"; if (StringUtil.tamanho(prop_seg_pri) == 0) prop_seg_pri = "servidor.jks"; if (StringUtil.tamanho(prop_seg_pri_senha) == 0) prop_seg_pri_senha = "123456"; if (StringUtil.tamanho(prop_seg_pri_tipo) == 0) prop_seg_pri_tipo = "JKS"; if (StringUtil.tamanho(prop_seg_pub) == 0) prop_seg_pub = "cliente.jks"; if (StringUtil.tamanho(prop_seg_pub_senha) == 0) prop_seg_pub_senha = "123456"; if (StringUtil.tamanho(prop_seg_pub_tipo) == 0) prop_seg_pub_tipo = "JKS"; /***********************/ File seg_pri = new File(prop_seg_pri); if (!seg_pri.isAbsolute()) seg_pri = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pri); if (seg_pri.exists()) { System.setProperty("javax.net.ssl.keyStore", seg_pri.getAbsolutePath()); System.setProperty("javax.net.ssl.keyStorePassword", prop_seg_pri_senha); System.setProperty("javax.net.ssl.keyStoreType", prop_seg_pri_tipo); } File seg_pub = new File(prop_seg_pub); if (!seg_pub.isAbsolute()) seg_pub = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pub); if (seg_pub.exists()) { System.setProperty("javax.net.ssl.trustStore", seg_pub.getAbsolutePath()); System.setProperty("javax.net.ssl.trustStorePassword", prop_seg_pub_senha); System.setProperty("javax.net.ssl.trustStoreType", prop_seg_pub_tipo); } /***********************/ new Thread() { File arquivo = new File(configuracao, "copaibas.conf"); long ultimaData = -1; @Override public void run() { while (true) { long data = arquivo.lastModified(); if (data > ultimaData) { executarCopaibas(arquivo); ultimaData = data; } try { Thread.sleep(5 * 1000); } catch (InterruptedException e) { return; } } } }.start(); /***********************/ log.info(Util.getMensagem("unhadegato.conexao.esperando")); log.info(Util.getMensagem("copaiba.porta.normal.abrindo", prop_porta)); Portal portal1 = new Portal(new SocketServidor(Integer.parseInt(prop_porta), false, true)); log.info(Util.getMensagem("copaiba.porta.segura.abrindo", prop_porta_segura)); Portal portal2 = new Portal(new SocketServidor(Integer.parseInt(prop_porta_segura), true, true)); portal1.start(); portal2.start(); portal1.join(); /***********************/ } catch (Exception e) { log.error(e.getMessage(), e); } finally { for (CopaibaGerenciador gerenciador : gerenciadores.values()) gerenciador.encerrar(); gerenciadores.clear(); gerenciadores = null; } }
From source file:com.faces.controller.util.FaceRecognitionUtils.java
public static void main(String[] args) { String path = "H:\\MyWork\\facerecognition\\javacv-02385ce192fb\\facerecExample_ORL\\Cambridge_FaceDB\\s42\\"; List<String> listOfimages = new ArrayList<>(); File dir = new File(path); File[] arrFile = dir.listFiles(); for (File file : arrFile) { listOfimages.add(file.getAbsolutePath()); }//from w w w . ja v a 2 s . co m FaceRecognitionUtils utils = new FaceRecognitionUtils(); utils.storeTraningData(1, listOfimages); listOfimages.clear(); String path1 = "H:\\MyWork\\facerecognition\\javacv-02385ce192fb\\facerecExample_ORL\\Cambridge_FaceDB\\s41\\"; listOfimages.add(path1 + File.separator + "35.jpg"); utils.recognizeStudent(1, listOfimages); }
From source file:com.act.lcms.v2.TraceIndexExtractor.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());/*from w w w . ja v a2s .co m*/ } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } // Not enough memory available? We're gonna need a bigger heap. long maxMemory = Runtime.getRuntime().maxMemory(); if (maxMemory < 1 << 34) { // 16GB String msg = StringUtils.join( String.format( "You have run this class with a maximum heap size of less than 16GB (%d to be exact). ", maxMemory), "There is no way this process will complete with that much space available. ", "Crank up your heap allocation with -Xmx and try again.", ""); throw new RuntimeException(msg); } File inputFile = new File(cl.getOptionValue(OPTION_SCAN_FILE)); if (!inputFile.exists()) { System.err.format("Cannot find input scan file at %s\n", inputFile.getAbsolutePath()); HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } File rocksDBFile = new File(cl.getOptionValue(OPTION_INDEX_PATH)); if (rocksDBFile.exists()) { System.err.format("Index file at %s already exists--remove and retry\n", rocksDBFile.getAbsolutePath()); HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } List<Double> targetMZs = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader(cl.getOptionValue(OPTION_TARGET_MASSES)))) { String line; while ((line = reader.readLine()) != null) { targetMZs.add(Double.valueOf(line)); } } TraceIndexExtractor extractor = new TraceIndexExtractor(); extractor.processScan(targetMZs, inputFile, rocksDBFile); }
From source file:fi.uta.infim.usaproxyreportgenerator.App.java
/** * Entry point.//w w w . j av a 2s . c om * @param args command line arguments */ public static void main(String[] args) { printLicense(); System.out.println(); try { // Command line arguments cli = parser.parse(cliOptions, args); } catch (org.apache.commons.cli.ParseException e) { System.err.println(e.getMessage()); printHelp(); return; } File outputDir; // Use CWD if output dir is not supplied outputDir = new File(cli.getOptionValue("outputDir", ".")); // Set up the browsing data provider that mines the log entries for // visualizable data. setupDataProvider(); // Output CLI options, so that the user sees what is happening System.out.println("Output directory: " + outputDir.getAbsolutePath()); System.out.println("Data provider class: " + dataProviderClass.getCanonicalName()); UsaProxyLogParser parser = new UsaProxyLogParser(); UsaProxyLog log; try { String filenames[] = cli.getArgs(); if (filenames.length == 0) { throw new IndexOutOfBoundsException(); } // Interpret remaining cli args as file names System.out.print("Parsing log file... "); log = parser.parseFilesByName(Arrays.asList(filenames)); System.out.println("done."); } catch (IOException ioe) { System.err.println("Error opening log file: " + ioe.getMessage()); printHelp(); return; } catch (ParseException pe) { System.err.println("Error parsing log file."); printHelp(); return; } catch (IndexOutOfBoundsException e) { System.err.println("Please supply a file name."); printHelp(); return; } catch (NoSuchElementException e) { System.err.println("Error opening log file: " + e.getMessage()); printHelp(); return; } setupJsonConfig(); // Set up JSON processors // Iterate over sessions and generate a report for each one. for (UsaProxySession s : log.getSessions()) { System.out.print("Generating report for session " + s.getSessionID() + "... "); try { generateHTMLReport(s, outputDir); System.out.println("done."); } catch (IOException e) { System.err.println( "I/O error generating report for session id " + s.getSessionID() + ": " + e.getMessage()); System.err.println("Skipping."); } catch (TemplateException e) { System.err.println( "Error populating template for session id " + s.getSessionID() + ": " + e.getMessage()); System.err.println("Skipping."); } } }
From source file:hk.idv.kenson.jrconsole.Console.java
/** * @param args//from w ww. j a v a 2 s.c o m */ public static void main(String[] args) { try { Map<String, Object> params = Console.parseArgs(args); if (params.containsKey("help")) { printUsage(); return; } if (params.containsKey("version")) { System.err.println("Version: " + VERSION); return; } if (params.containsKey("debug")) { for (String key : params.keySet()) log.info("\"" + key + "\" => \"" + params.get(key) + "\""); return; } checkParam(params); stepCompile(params); JasperReport jasper = stepLoadReport(params); JasperPrint print = stepFill(jasper, params); InputStream stream = stepExport(print, params); File output = new File(params.get("output").toString()); FileOutputStream fos = new FileOutputStream(output); copy(stream, fos); fos.close(); stream.close(); System.out.println(output.getAbsolutePath()); //Output the report path for pipe } catch (IllegalArgumentException ex) { printUsage(); System.err.println("Error: " + ex.getMessage()); ex.printStackTrace(); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException("Unexpected exception", ex); } }
From source file:com.act.lcms.db.io.ExportStandardIonResultsFromDB.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());/* w w w .j a va 2s . c o m*/ } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(ExportStandardIonResultsFromDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(ExportStandardIonResultsFromDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } try (DB db = DB.openDBFromCLI(cl)) { List<String> chemicalNames = new ArrayList<>(); if (cl.hasOption(OPTION_CONSTRUCT)) { // Extract the chemicals in the pathway and their product masses, then look up info on those chemicals List<Pair<ChemicalAssociatedWithPathway, Double>> productMasses = Utils .extractMassesForChemicalsAssociatedWithConstruct(db, cl.getOptionValue(OPTION_CONSTRUCT)); for (Pair<ChemicalAssociatedWithPathway, Double> pair : productMasses) { chemicalNames.add(pair.getLeft().getChemical()); } } if (cl.hasOption(OPTION_CHEMICALS)) { chemicalNames.addAll(Arrays.asList(cl.getOptionValues(OPTION_CHEMICALS))); } if (chemicalNames.size() == 0) { System.err.format("No chemicals can be found from the input query.\n"); System.exit(-1); } List<String> standardIonHeaderFields = new ArrayList<String>() { { add(STANDARD_ION_HEADER_FIELDS.CHEMICAL.name()); add(STANDARD_ION_HEADER_FIELDS.BEST_ION_FROM_ALGO.name()); add(STANDARD_ION_HEADER_FIELDS.MANUAL_PICK.name()); add(STANDARD_ION_HEADER_FIELDS.AUTHOR.name()); add(STANDARD_ION_HEADER_FIELDS.DIAGNOSTIC_PLOTS.name()); add(STANDARD_ION_HEADER_FIELDS.NOTE.name()); } }; String outAnalysis; if (cl.hasOption(OPTION_OUTPUT_PREFIX)) { outAnalysis = cl.getOptionValue(OPTION_OUTPUT_PREFIX) + "." + TSV_FORMAT; } else { outAnalysis = String.join("-", chemicalNames) + "." + TSV_FORMAT; } File lcmsDir = new File(cl.getOptionValue(OPTION_DIRECTORY)); if (!lcmsDir.isDirectory()) { System.err.format("File at %s is not a directory\n", lcmsDir.getAbsolutePath()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } String plottingDirectory = cl.getOptionValue(OPTION_PLOTTING_DIR); TSVWriter<String, String> resultsWriter = new TSVWriter<>(standardIonHeaderFields); resultsWriter.open(new File(outAnalysis)); // For each chemical, create a TSV row and a corresponding diagnostic plot for (String chemicalName : chemicalNames) { List<String> graphLabels = new ArrayList<>(); List<Double> yMaxList = new ArrayList<>(); String outData = plottingDirectory + "/" + chemicalName + ".data"; String outImg = plottingDirectory + "/" + chemicalName + ".pdf"; // For each diagnostic plot, open a new file stream. try (FileOutputStream fos = new FileOutputStream(outData)) { List<StandardIonResult> getResultByChemicalName = StandardIonResult.getByChemicalName(db, chemicalName); if (getResultByChemicalName != null && getResultByChemicalName.size() > 0) { // PART 1: Get the best metlin ion across all standard ion results for a given chemical String bestGlobalMetlinIon = AnalysisHelper .scoreAndReturnBestMetlinIonFromStandardIonResults(getResultByChemicalName, new HashMap<>(), true, true); // PART 2: Plot all the graphs related to the chemical. The plots are structured as follows: // // Page 1: All graphs (water, MeOH, Yeast) for Global ion picked (best ion among ALL standard ion runs for // the given chemical) by the algorithm // Page 2: All graphs for M+H // Page 3: All graphs for Local ions picked (best ion within a SINGLE standard ion run) + negative controls // for Yeast. // // Each page is demarcated by a blank graph. // Arrange results based on media Map<String, List<StandardIonResult>> categories = StandardIonResult .categorizeListOfStandardWellsByMedia(db, getResultByChemicalName); // This set contains all the best metlin ions corresponding to all the standard ion runs. Set<String> bestLocalIons = new HashSet<>(); bestLocalIons.add(bestGlobalMetlinIon); bestLocalIons.add(DEFAULT_ION); for (StandardIonResult result : getResultByChemicalName) { bestLocalIons.add(result.getBestMetlinIon()); } // We sort the best local ions are follows: // 1) Global best ion spectra 2) M+H spectra 3) Local best ion spectra List<String> bestLocalIonsArray = new ArrayList<>(bestLocalIons); Collections.sort(bestLocalIonsArray, new Comparator<String>() { @Override public int compare(String o1, String o2) { if (o1.equals(bestGlobalMetlinIon) && !o2.equals(bestGlobalMetlinIon)) { return -1; } else if (o1.equals(DEFAULT_ION) && !o2.equals(bestGlobalMetlinIon)) { return -1; } else { return 1; } } }); // This variable stores the index of the array at which all the remaining spectra are contained in one // page. This happens right after the M+H ion spectra. Integer combineAllSpectraIntoPageThreeFromIndex = 0; for (int i = 0; i < bestLocalIonsArray.size(); i++) { if (bestLocalIonsArray.get(i).equals(DEFAULT_ION)) { combineAllSpectraIntoPageThreeFromIndex = i + 1; } } for (int i = 0; i < bestLocalIonsArray.size(); i++) { String ion = bestLocalIonsArray.get(i); for (Map.Entry<String, List<StandardIonResult>> mediaToListOfIonResults : categories .entrySet()) { for (StandardIonResult result : mediaToListOfIonResults.getValue()) { // For every standard ion result, we plot the best global metlin ion and M+H. These plots are in the // pages 1 and 2. For all page 3 (aka miscellaneous spectra), we only plot the best local ion // corresponding to it's spectra and not some other graph's spectra. In the below condition, // we reach the page 3 case with not the same best ion as the spectra, in which case we just continue // and not draw anything on the page. if (i >= combineAllSpectraIntoPageThreeFromIndex && !(result.getBestMetlinIon().equals(ion))) { continue; } StandardWell positiveWell = StandardWell.getInstance().getById(db, result.getStandardWellId()); String positiveControlChemical = positiveWell.getChemical(); ScanData<StandardWell> encapsulatedDataForPositiveControl = AnalysisHelper .getScanDataForWell(db, lcmsDir, positiveWell, positiveControlChemical, positiveControlChemical); Set<String> singletonSet = Collections.singleton(ion); String additionalInfo = generateAdditionalLabelInformation(positiveWell, result, ion); List<String> labels = AnalysisHelper .writeScanData(fos, lcmsDir, MAX_INTENSITY, encapsulatedDataForPositiveControl, false, false, singletonSet) .stream().map(label -> label + additionalInfo) .collect(Collectors.toList()); yMaxList.add(encapsulatedDataForPositiveControl.getMs1ScanResults() .getMaxIntensityForIon(ion)); List<String> negativeLabels = null; // Only do the negative control in the miscellaneous page (page 3) and if the well is in yeast media. if (mediaToListOfIonResults.getKey() .equals(StandardWell.MEDIA_TYPE.YEAST.name()) && (i >= combineAllSpectraIntoPageThreeFromIndex && (result.getBestMetlinIon().equals(ion)))) { //TODO: Change the representative negative well to one that displays the highest noise in the future. // For now, we just use the first index among the negative wells. int representativeIndex = 0; StandardWell representativeNegativeControlWell = StandardWell.getInstance() .getById(db, result.getNegativeWellIds().get(representativeIndex)); ScanData encapsulatedDataForNegativeControl = AnalysisHelper .getScanDataForWell(db, lcmsDir, representativeNegativeControlWell, positiveWell.getChemical(), representativeNegativeControlWell.getChemical()); String negativePlateAdditionalInfo = generateAdditionalLabelInformation( representativeNegativeControlWell, null, null); negativeLabels = AnalysisHelper.writeScanData(fos, lcmsDir, MAX_INTENSITY, encapsulatedDataForNegativeControl, false, false, singletonSet) .stream().map(label -> label + negativePlateAdditionalInfo) .collect(Collectors.toList()); yMaxList.add(encapsulatedDataForNegativeControl.getMs1ScanResults() .getMaxIntensityForIon(ion)); } graphLabels.addAll(labels); if (negativeLabels != null) { graphLabels.addAll(negativeLabels); } } } // Add a blank graph to demarcate pages. if (i < combineAllSpectraIntoPageThreeFromIndex) { graphLabels.addAll(AnalysisHelper.writeScanData(fos, lcmsDir, 0.0, BLANK_SCAN, false, false, new HashSet<>())); yMaxList.add(0.0d); } } // We need to pass the yMax values as an array to the Gnuplotter. Double fontScale = null; if (cl.hasOption(FONT_SCALE)) { try { fontScale = Double.parseDouble(cl.getOptionValue(FONT_SCALE)); } catch (IllegalArgumentException e) { System.err.format("Argument for font-scale must be a floating point number.\n"); System.exit(1); } } Double[] yMaxes = yMaxList.toArray(new Double[yMaxList.size()]); Gnuplotter plotter = fontScale == null ? new Gnuplotter() : new Gnuplotter(fontScale); plotter.plot2D(outData, outImg, graphLabels.toArray(new String[graphLabels.size()]), "time", null, "intensity", "pdf", null, null, yMaxes, outImg + ".gnuplot"); Map<String, String> row = new HashMap<>(); row.put(STANDARD_ION_HEADER_FIELDS.CHEMICAL.name(), chemicalName); row.put(STANDARD_ION_HEADER_FIELDS.BEST_ION_FROM_ALGO.name(), bestGlobalMetlinIon); row.put(STANDARD_ION_HEADER_FIELDS.DIAGNOSTIC_PLOTS.name(), outImg); resultsWriter.append(row); resultsWriter.flush(); } } } resultsWriter.flush(); resultsWriter.close(); } }
From source file:de.ingrid.iplug.AdminServer.java
/** * To start the admin web server from the commandline. * @param args The server port and the web app folder. * @throws Exception Something goes wrong. *//*from w ww. j av a2s . co m*/ public static void main(String[] args) throws Exception { String usage = "<serverPort> <webappFolder>"; if ((args.length == 0) && (args.length != 4) && (args.length != 6)) { System.err.println(usage); return; } Map arguments = readParameters(args); File plugDescriptionFile = new File(PLUG_DESCRIPTION); if (arguments.containsKey("--plugdescription")) { plugDescriptionFile = new File((String) arguments.get("--plugdescription")); } File communicationProperties = new File(COMMUNICATION_PROPERTES); if (arguments.containsKey("--descriptor")) { communicationProperties = new File((String) arguments.get("--descriptor")); } int port = Integer.parseInt(args[0]); File webFolder = new File(args[1]); //push init params for all contexts (e.g. step1 and step2) HashMap hashMap = new HashMap(); hashMap.put("plugdescription.xml", plugDescriptionFile.getAbsolutePath()); hashMap.put("communication.xml", communicationProperties.getAbsolutePath()); WebContainer container = startWebContainer(hashMap, port, webFolder, false, null); container.join(); }
From source file:avantssar.aslanpp.testing.Tester.java
public static void main(String[] args) { Debug.initLog(LogLevel.INFO);//from ww w .j av a 2 s . co m TesterCommandLineOptions options = new TesterCommandLineOptions(); try { options.getParser().parseArgument(args); options.ckeckAtEnd(); } catch (CmdLineException ex) { reportException("Inconsistent options.", ex, System.err); options.showShortHelp(System.err); return; } if (options.isShowHelp()) { options.showLongHelp(System.out); return; } ASLanPPConnectorImpl translator = new ASLanPPConnectorImpl(); if (options.isShowVersion()) { System.out.println(translator.getFullTitleLine()); return; } ISpecificationBundleProvider sbp; File realInDir; if (options.isLibrary()) { if (options.getHornClausesLevel() != HornClausesLevel.ALL) { System.out.println("When checking the internal library we output all Horn clauses."); options.setHornClausesLevel(HornClausesLevel.ALL); } if (!options.isStripOutput()) { System.out.println( "When checking the internal library, the ouput is stripped of comments and line information."); options.setStripOutput(true); } File modelsDir = new File(FilenameUtils.concat(options.getOut().getAbsolutePath(), "_models")); try { FileUtils.forceMkdir(modelsDir); } catch (IOException e1) { System.out.println("Failed to create models folder: " + e1.getMessage()); Debug.logger.error("Failed to create models folder.", e1); } realInDir = modelsDir; sbp = new LibrarySpecificationsProvider(modelsDir.getAbsolutePath()); } else { realInDir = options.getIn(); sbp = new DiskSpecificationsProvider(options.getIn().getAbsolutePath()); } System.setProperty(EntityManager.ASLAN_ENVVAR, sbp.getASLanPath()); // try { // EntityManager.loadASLanPath(); // } // catch (IOException e) { // System.out.println("Exception while reloading ASLANPATH: " + // e.getMessage()); // Debug.logger.error("Exception while loading ASLANPATH.", e); // } try { bm = BackendsManager.instance(); if (bm != null) { for (IBackendRunner br : bm.getBackendRunners()) { System.out.println(br.getFullDescription()); if (br.getTimeout() > finalTimeout) { finalTimeout = br.getTimeout(); } } } } catch (IOException e) { System.out.println("Failed to load backends: " + e); } int threadsCount = 50; if (options.getThreads() > 0) { threadsCount = options.getThreads(); } System.out.println("Will launch " + threadsCount + " threads in parallel (+ will show that a thread starts, - that a thread ends)."); TranslationReport rep = new TranslationReport( bm != null ? bm.getBackendRunners() : new ArrayList<IBackendRunner>(), options.getOut()); long startTime = System.currentTimeMillis(); int specsCount = 0; pool = Executors.newFixedThreadPool(threadsCount); for (ITestTask task : sbp) { doTest(rep, task, realInDir, options.getOut(), translator, options, System.err); specsCount++; } pool.shutdown(); String reportFile = FilenameUtils.concat(options.getOut().getAbsolutePath(), "index.html"); try { while (!pool.awaitTermination(finalTimeout, TimeUnit.SECONDS)) { } } catch (InterruptedException e) { Debug.logger.error("Interrupted while waiting for pool termination.", e); System.out.println("Interrupted while waiting for pool termination: " + e.getMessage()); System.out.println("The report may be incomplete."); } long endTime = System.currentTimeMillis(); long duration = (endTime - startTime) / 1000; System.out.println(); System.out.println(specsCount + " specifications checked in " + duration + " seconds."); rep.report(reportFile); System.out.println("You can find an overview report at '" + reportFile + "'."); }
From source file:io.werval.cli.DamnSmallDevShell.java
public static void main(String[] args) { Options options = declareOptions();/*ww w.j a v a 2 s.co m*/ CommandLineParser parser = new PosixParser(); try { CommandLine cmd = parser.parse(options, args); // Handle --help if (cmd.hasOption("help")) { PrintWriter out = new PrintWriter(System.out); printHelp(options, out); out.flush(); System.exit(0); } // Handle --version if (cmd.hasOption("version")) { System.out.print(String.format( "Werval CLI v%s\n" + "Git commit: %s%s, built on: %s\n" + "Java version: %s, vendor: %s\n" + "Java home: %s\n" + "Default locale: %s, platform encoding: %s\n" + "OS name: %s, version: %s, arch: %s\n", VERSION, COMMIT, (DIRTY ? " (DIRTY)" : ""), DATE, System.getProperty("java.version"), System.getProperty("java.vendor"), System.getProperty("java.home"), Locale.getDefault().toString(), System.getProperty("file.encoding"), System.getProperty("os.name"), System.getProperty("os.version"), System.getProperty("os.arch"))); System.out.flush(); System.exit(0); } // Debug final boolean debug = cmd.hasOption('d'); // Temporary directory final File tmpDir = new File(cmd.getOptionValue('t', "build" + separator + "devshell.tmp")); if (debug) { System.out.println("Temporary directory set to '" + tmpDir.getAbsolutePath() + "'."); } // Handle commands @SuppressWarnings("unchecked") List<String> commands = cmd.getArgList(); if (commands.isEmpty()) { commands = Collections.singletonList("start"); } if (debug) { System.out.println("Commands to be executed: " + commands); } Iterator<String> commandsIterator = commands.iterator(); while (commandsIterator.hasNext()) { String command = commandsIterator.next(); switch (command) { case "new": System.out.println(LOGO); newCommand(commandsIterator.hasNext() ? commandsIterator.next() : "werval-application", cmd); break; case "clean": cleanCommand(debug, tmpDir); break; case "devshell": System.out.println(LOGO); devshellCommand(debug, tmpDir, cmd); break; case "start": System.out.println(LOGO); startCommand(debug, tmpDir, cmd); break; case "secret": secretCommand(); break; default: PrintWriter out = new PrintWriter(System.err); System.err.println("Unknown command: '" + command + "'"); printHelp(options, out); out.flush(); System.exit(1); break; } } } catch (IllegalArgumentException | ParseException | IOException ex) { PrintWriter out = new PrintWriter(System.err); printHelp(options, out); out.flush(); System.exit(1); } catch (WervalException ex) { ex.printStackTrace(System.err); System.err.flush(); System.exit(1); } }