From f2e2178170c8f908c5eec6232f6c4c91f98c0b73 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 6 Jan 2002 01:43:39 +0000 Subject: [PATCH] Made the ExecManager support another method of execution that involves supplying an ExecOutputHandler git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270555 13f79535-47bb-0310-9956-ffa450edef68 --- .../myrmidon/framework/exec/ExecManager.java | 18 ++++++++++++++++++ .../exec/impl/DefaultExecManager.java | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java index 5aa0c08be..8f95e4e0b 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java @@ -53,4 +53,22 @@ public interface ExecManager OutputStream error, long timeout ) throws IOException, ExecException /*TimeoutException*/; + + /** + * Execute a process and wait for it to finish before + * returning. Note that this version of execute() does not allow you + * to specify input. + * + * @param execMetaData the metaData for native command to execute + * @param handler the handler to which line-orientated output of + * process is directed for standard output and standard error + * @param timeout the maximum duration in milliseconds that a process + * can execute. The value must be positive or zero. If it is zero + * then the process will not timeout. If the process times out it + * will be forcibly shutdown and a TimeoutException thrown + */ + int execute( ExecMetaData execMetaData, + ExecOutputHandler handler, + long timeout ) + throws IOException, ExecException /*TimeoutException*/; } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/impl/DefaultExecManager.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/impl/DefaultExecManager.java index fc646c0b0..2a74602a4 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/impl/DefaultExecManager.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/impl/DefaultExecManager.java @@ -18,6 +18,7 @@ import org.apache.myrmidon.framework.exec.CommandLauncher; import org.apache.myrmidon.framework.exec.ExecException; import org.apache.myrmidon.framework.exec.ExecManager; import org.apache.myrmidon.framework.exec.ExecMetaData; +import org.apache.myrmidon.framework.exec.ExecOutputHandler; import org.apache.myrmidon.framework.exec.launchers.DefaultCommandLauncher; import org.apache.myrmidon.framework.exec.launchers.MacCommandLauncher; import org.apache.myrmidon.framework.exec.launchers.ScriptCommandLauncher; @@ -51,6 +52,20 @@ public class DefaultExecManager m_shellLauncher = createShellLauncher( antDir ); } + /** + * Execute a process and wait for it to finish before + * returning. + */ + public int execute( final ExecMetaData execMetaData, + final ExecOutputHandler handler, + long timeout ) + throws IOException, ExecException /*TimeoutException*/ + { + final LogOutputStream output = new LogOutputStream( handler, false ); + final LogOutputStream error = new LogOutputStream( handler, true ); + return execute( execMetaData, null, output, error, timeout ); + } + /** * Execute a process and wait for it to finish before * returning.