donaldp 01/12/22 22:19:33
Modified: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec
ExecTask.java
Log:
Set the output stremes via setters not via constructor
Set timeoout value rather than passing in watchdog
Revision Changes Path
1.10 +13 -25
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java
Index: ExecTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ExecTask.java 2001/12/23 03:39:04 1.9
+++ ExecTask.java 2001/12/23 06:19:33 1.10
@@ -17,7 +17,6 @@
import java.util.Iterator;
import java.util.Properties;
import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.exec.ExecuteWatchdog;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Argument;
@@ -220,10 +219,6 @@
final int err = exe.execute();
//test for and handle a forced process death
- if( exe.killedProcess() )
- {
- getLogger().warn( "Timeout: killed the sub-process" );
- }
maybeSetResultPropertyValue( err );
if( 0 != err )
{
@@ -283,7 +278,7 @@
* @return Description of the Returned Value
* @exception TaskException Description of Exception
*/
- protected PumpStreamHandler createHandler()
+ private void setupOutput( final Execute exe )
throws TaskException
{
if( m_outputFile != null )
@@ -292,7 +287,8 @@
{
m_ouput = new FileOutputStream( m_outputFile );
getLogger().debug( "Output redirected to " + m_outputFile );
- return new PumpStreamHandler( m_ouput );
+ exe.setOutput( m_ouput );
+ exe.setError( m_ouput );
}
catch( FileNotFoundException fne )
{
@@ -307,30 +303,17 @@
{
m_byteArrayOutput = new ByteArrayOutputStream();
getLogger().debug( "Output redirected to ByteArray" );
- return new PumpStreamHandler( m_byteArrayOutput );
+ exe.setOutput( m_byteArrayOutput );
+ exe.setError( m_byteArrayOutput );
}
else
{
- return new LogStreamHandler( this,
- Project.MSG_INFO, Project.MSG_WARN
);
+ exe.setOutput( new LogOutputStream( this, Project.MSG_INFO ) );
+ exe.setError( new LogOutputStream( this, Project.MSG_WARN ) );
}
}
/**
- * Create the Watchdog to kill a runaway process.
- *
- * @return Description of the Returned Value
- * @exception TaskException Description of Exception
- */
- protected ExecuteWatchdog createWatchdog()
- throws TaskException
- {
- if( m_timeout == null )
- return null;
- return new ExecuteWatchdog( m_timeout.intValue() );
- }
-
- /**
* Flush the output stream - if there is one.
*/
protected void logFlush()
@@ -372,7 +355,12 @@
// show the command
getLogger().debug( m_command.toString() );
- final Execute exe = new Execute( createHandler(), createWatchdog() );
+ final Execute exe = new Execute();
+ setupOutput( exe );
+ if( null != m_timeout )
+ {
+ exe.setTimeout( m_timeout.intValue() );
+ }
exe.setWorkingDirectory( m_workingDirectory );
exe.setVMLauncher( m_useVMLauncher );
exe.setNewenvironment( m_newEnvironment );
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>