Browse Source

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
master
Peter Donald 23 years ago
parent
commit
f2e2178170
2 changed files with 33 additions and 0 deletions
  1. +18
    -0
      proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java
  2. +15
    -0
      proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/impl/DefaultExecManager.java

+ 18
- 0
proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java View File

@@ -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*/;
}

+ 15
- 0
proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/impl/DefaultExecManager.java View File

@@ -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.


Loading…
Cancel
Save