• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PumpStreamHandler类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.tools.ant.taskdefs.PumpStreamHandler的典型用法代码示例。如果您正苦于以下问题:Java PumpStreamHandler类的具体用法?Java PumpStreamHandler怎么用?Java PumpStreamHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PumpStreamHandler类属于org.apache.tools.ant.taskdefs包,在下文中一共展示了PumpStreamHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

点赞 3

import org.apache.tools.ant.taskdefs.PumpStreamHandler; //导入依赖的package包/类
/** execute in a forked VM */
private int run(String[] command) throws BuildException {
    PumpStreamHandler psh =
        new PumpStreamHandler(new LogOutputStream(this, Project.MSG_INFO),
                              new TeeOutputStream(
                                                  new LogOutputStream(this,
                                                                      Project.MSG_WARN),
                                                  bos)
                              );
    Execute exe = new Execute(psh, null);
    exe.setAntRun(getProject());
    if (workingdir != null) {
        exe.setWorkingDirectory(workingdir);
    }
    exe.setCommandline(command);
    try {
        return exe.execute();
    } catch (IOException e) {
        throw new BuildException(e, getLocation());
    } finally {
        FileUtils.close(bos);
    }
}
 

开发者ID:apache,
项目名称:ant,
代码行数:24,
代码来源:ANTLR.java

示例2: handle

点赞 2

import org.apache.tools.ant.taskdefs.PumpStreamHandler; //导入依赖的package包/类
@Override
public void handle(Message inputMessage, ISendMessageCallback callback, boolean unitOfWorkBoundaryReached) {		
	if ((PER_UNIT_OF_WORK.equals(runWhen) && inputMessage instanceof ControlMessage)
			|| (!PER_UNIT_OF_WORK.equals(runWhen) && !(inputMessage instanceof ControlMessage))) {
		try {
			ByteArrayOutputStream os = getByteArrayOutputStream();
			PumpStreamHandler outputHandler = new PumpStreamHandler(os);
			org.apache.tools.ant.taskdefs.Execute antTask = getAntTask(outputHandler);
			String[] commands = parseCommand(getComponent().get(COMMAND), inputMessage);
			antTask.setCommandline(commands);
			info("About to execute: %s", ArrayUtils.toString(commands));
			int code = antTask.execute();				
			String output = new String(os.toByteArray());
			if (successCode == code || continueOnError) {
				if (successCode == code) {
					info("Returned an code of %d", code);
				} else {
					warn("Returned an code of %d", code);
				}
				info("The output of the command was: %s", output);

				ArrayList<String> payload = new ArrayList<String>();
				payload.add(output);
				callback.sendTextMessage(null, payload);
			} else {
				info("The output of the command was: %s", output);
				throw new IoException("%s failed with an error code of %d", ArrayUtils.toString(commands), code);
			}
		} catch (IOException e) {
			throw new IoException(e);
		}
	}
}
 

开发者ID:JumpMind,
项目名称:metl,
代码行数:34,
代码来源:Execute.java

示例3: execute

点赞 2

import org.apache.tools.ant.taskdefs.PumpStreamHandler; //导入依赖的package包/类
private void execute(String outputFileName, String errorFileName, String expectedFileName) throws IOException {
       CommandlineJava commandLine = new CommandlineJava();
       String mainClass = className.substring(0, className.length() - ".f3".length());
       commandLine.setClassname(F3_MAIN);
       Project project = new Project();
       Path p = commandLine.createClasspath(project);
       p.createPathElement().setPath(System.getProperty("java.class.path"));
       p.createPathElement().setPath(buildDir.getPath());
       // for possible .f3properties files in the test source directory
       p.createPathElement().setPath(testFile.getParent());
      
       commandLine.createArgument().setValue(mainClass);
       if (param != null)
           commandLine.createArgument().setLine(param);

       // set locale to en_US (required to make test-output reproduceable)
       commandLine.createVmArgument().setValue("-Duser.language=en");
       commandLine.createVmArgument().setValue("-Duser.country=US");
commandLine.createVmArgument().setValue("-Djava.io.tmpdir=" + System.getProperty("java.io.tmpdir"));

       PumpStreamHandler sh = new PumpStreamHandler(new FileOutputStream(outputFileName), new FileOutputStream(errorFileName));
       Execute exe = new Execute(sh);
       String[] strings = commandLine.getCommandline();
       exe.setCommandline(strings);
       try {
           exe.execute();
           File errorFileHandle = new File(errorFileName);
           if (errorFileHandle.length() > 0) {
               if (expectRunFailure)
                   return;
               if (!ignoreStdError && !checkForMacOSJavaBug(errorFileHandle)) {
                   TestHelper.dumpFile(new FileInputStream(outputFileName), "Test Output", testFile.toString());
                   TestHelper.dumpFile(new FileInputStream(errorFileName), "Test Error", testFile.toString());
                   System.out.println("--");
                   fail("Output written to standard error");
               }
           }
           if (compare)
               compare(outputFileName, expectedFileName, false);
       }
       catch (IOException e) {
           if (!expectRunFailure)
               fail("Failure running test " + testFile + ": " + e.getMessage());
           // else success
       }
   }
 

开发者ID:unktomi,
项目名称:form-follows-function,
代码行数:47,
代码来源:F3RunAndCompareWrapper.java

示例4: getAntTask

点赞 2

import org.apache.tools.ant.taskdefs.PumpStreamHandler; //导入依赖的package包/类
org.apache.tools.ant.taskdefs.Execute getAntTask(PumpStreamHandler outputHandler) {
	return new org.apache.tools.ant.taskdefs.Execute(outputHandler);
}
 

开发者ID:JumpMind,
项目名称:metl,
代码行数:4,
代码来源:Execute.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)