public void execute() throws Exception { getNewCount(); File executable = new File(getEXEPath()); if (!executable.exists()) throw new FileNotFoundException("executable file does not exist! " + executable); workingDir = getWorkingDirectory(executable); initExecution(); instruction = getInstructionFileName(workingDir); output = getOutputFileName(workingDir); createInstructionFile(instruction); // Profiler pofiler = new Profiler(); // profiler.start("exec-ilink-search " + xmlFileName, "exec-ilink-search " + xmlFileName); ExecShell shell = new ExecShell(); shell.setExecutable(executable.getAbsolutePath()); shell.setWorkingDirectory(workingDir); setArguments(shell); shell.addCommandLineArgument(executable.getParent()); shell.execute(); // profiler.start("exec-ilink-search " + xmlFileName, "shell-wait-for"); exitCode = shell.timeout(timeout); // profiler.stop("exec-ilink-search " + xmlFileName, "shell-wait-for"); // instructionFile.delete(); handleResponse(output); finishExecution(); if (zws.Server.debugMode()) return; // cleanup File[] contents = workingDir.listFiles(); for (int idx = 0; idx < contents.length; contents[idx++].delete()) ; workingDir.delete(); }
private File getWorkingDirectory(File f) { try { File workingDir = new File( Properties.get(Names.WORKING_DIR) + Names.PATH_SEPARATOR + getOpType() + Names.PATH_SEPARATOR + "work" + getNewCount()); if (!workingDir.exists()) workingDir.mkdirs(); FileUtil.deleteContents(workingDir); return workingDir; } catch (Exception ignore) { // ++ notify of error - maybe out of disk space ignore.printStackTrace(); return null; } }
protected String getOutputFileName(File f) { return f.getAbsolutePath() + Names.PATH_SEPARATOR + "response.xml"; }
protected String getInstructionFileName(File f) { return f.getAbsolutePath() + Names.PATH_SEPARATOR + "instruction.xml"; }