You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/12/19 12:50:18 UTC

cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec PumpStreamHandler.java ExecuteWatchdog.java

donaldp     01/12/19 03:50:18

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec
                        PumpStreamHandler.java ExecuteWatchdog.java
  Log:
  spruced.
  
  Revision  Changes    Path
  1.2       +25 -23    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java
  
  Index: PumpStreamHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PumpStreamHandler.java	2001/12/17 09:49:30	1.1
  +++ PumpStreamHandler.java	2001/12/19 11:50:18	1.2
  @@ -19,18 +19,20 @@
    *
    * @author thomas.haas@softwired-inc.com
    */
  -public class PumpStreamHandler implements ExecuteStreamHandler
  +public class PumpStreamHandler
  +    implements ExecuteStreamHandler
   {
  -    private Thread errorThread;
  +    private Thread m_errorThread;
  +    private Thread m_inputThread;
   
  -    private Thread inputThread;
  +    private OutputStream m_output;
  +    private OutputStream m_error;
   
  -    private OutputStream out, err;
  -
  -    public PumpStreamHandler( OutputStream out, OutputStream err )
  +    public PumpStreamHandler( final OutputStream output,
  +                              final OutputStream error )
       {
  -        this.out = out;
  -        this.err = err;
  +        m_output = output;
  +        m_error = error;
       }
   
       public PumpStreamHandler( OutputStream outAndErr )
  @@ -45,7 +47,7 @@
   
       public void setProcessErrorStream( InputStream is )
       {
  -        createProcessErrorPump( is, err );
  +        createProcessErrorPump( is, m_error );
       }
   
       public void setProcessInputStream( OutputStream os )
  @@ -54,13 +56,13 @@
   
       public void setProcessOutputStream( InputStream is )
       {
  -        createProcessOutputPump( is, out );
  +        createProcessOutputPump( is, m_output );
       }
   
       public void start()
       {
  -        inputThread.start();
  -        errorThread.start();
  +        m_inputThread.start();
  +        m_errorThread.start();
       }
   
       public void stop()
  @@ -68,28 +70,28 @@
       {
           try
           {
  -            inputThread.join();
  +            m_inputThread.join();
           }
           catch( InterruptedException e )
           {
           }
           try
           {
  -            errorThread.join();
  +            m_errorThread.join();
           }
           catch( InterruptedException e )
           {
           }
           try
           {
  -            err.flush();
  +            m_error.flush();
           }
           catch( IOException e )
           {
           }
           try
           {
  -            out.flush();
  +            m_output.flush();
           }
           catch( IOException e )
           {
  @@ -98,22 +100,22 @@
   
       protected OutputStream getErr()
       {
  -        return err;
  +        return m_error;
       }
   
       protected OutputStream getOut()
       {
  -        return out;
  +        return m_output;
       }
   
       protected void createProcessErrorPump( InputStream is, OutputStream os )
       {
  -        errorThread = createPump( is, os );
  +        m_errorThread = createPump( is, os );
       }
   
       protected void createProcessOutputPump( InputStream is, OutputStream os )
       {
  -        inputThread = createPump( is, os );
  +        m_inputThread = createPump( is, os );
       }
   
       /**
  @@ -124,11 +126,11 @@
        * @param os Description of Parameter
        * @return Description of the Returned Value
        */
  -    protected Thread createPump( InputStream is, OutputStream os )
  +    protected Thread createPump( final InputStream input,
  +                                 final OutputStream output )
       {
  -        final Thread result = new Thread( new StreamPumper( is, os ) );
  +        final Thread result = new Thread( new StreamPumper( input, output ) );
           result.setDaemon( true );
           return result;
       }
  -
   }
  
  
  
  1.2       +27 -27    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java
  
  Index: ExecuteWatchdog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExecuteWatchdog.java	2001/12/17 09:49:30	1.1
  +++ ExecuteWatchdog.java	2001/12/19 11:50:18	1.2
  @@ -24,34 +24,34 @@
    * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
    * @see Execute
    */
  -public class ExecuteWatchdog implements Runnable
  +public class ExecuteWatchdog
  +    implements Runnable
   {
  -
       /**
        * say whether or not the watchog is currently monitoring a process
        */
  -    private boolean watch = false;
  +    private boolean m_watch;
   
       /**
        * exception that might be thrown during the process execution
        */
  -    private Exception caught = null;
  +    private Exception m_caught;
   
       /**
        * say whether or not the process was killed due to running overtime
        */
  -    private boolean killedProcess = false;
  +    private boolean m_killedProcess;
   
       /**
        * the process to execute and watch for duration
        */
  -    private Process process;
  +    private Process m_process;
   
       /**
        * timeout duration. Once the process running time exceeds this it should be
        * killed
        */
  -    private int timeout;
  +    private int m_timeout;
   
       /**
        * Creates a new watchdog with a given timeout.
  @@ -65,7 +65,7 @@
           {
               throw new IllegalArgumentException( "timeout lesser than 1." );
           }
  -        this.timeout = timeout;
  +        this.m_timeout = timeout;
       }
   
       /**
  @@ -76,7 +76,7 @@
        */
       public boolean isWatching()
       {
  -        return watch;
  +        return m_watch;
       }
   
       /**
  @@ -91,10 +91,10 @@
       public void checkException()
           throws TaskException
       {
  -        if( caught != null )
  +        if( m_caught != null )
           {
               throw new TaskException( "Exception in ExecuteWatchdog.run: "
  -                                     + caught.getMessage(), caught );
  +                                     + m_caught.getMessage(), m_caught );
           }
       }
   
  @@ -106,7 +106,7 @@
        */
       public boolean killedProcess()
       {
  -        return killedProcess;
  +        return m_killedProcess;
       }
   
       /**
  @@ -118,9 +118,9 @@
           {
               // This isn't a Task, don't have a Project object to log.
               // project.log("ExecuteWatchdog: timeout = "+timeout+" msec",  Project.MSG_VERBOSE);
  -            final long until = System.currentTimeMillis() + timeout;
  +            final long until = System.currentTimeMillis() + m_timeout;
               long now;
  -            while( watch && until > ( now = System.currentTimeMillis() ) )
  +            while( m_watch && until > ( now = System.currentTimeMillis() ) )
               {
                   try
                   {
  @@ -138,22 +138,22 @@
               {
                   // We must check if the process was not stopped
                   // before being here
  -                process.exitValue();
  +                m_process.exitValue();
               }
               catch( IllegalThreadStateException e )
               {
                   // the process is not terminated, if this is really
                   // a timeout and not a manual stop then kill it.
  -                if( watch )
  +                if( m_watch )
                   {
  -                    killedProcess = true;
  -                    process.destroy();
  +                    m_killedProcess = true;
  +                    m_process.destroy();
                   }
               }
           }
           catch( Exception e )
           {
  -            caught = e;
  +            m_caught = e;
           }
           finally
           {
  @@ -175,14 +175,14 @@
           {
               throw new NullPointerException( "process is null." );
           }
  -        if( this.process != null )
  +        if( this.m_process != null )
           {
               throw new IllegalStateException( "Already running." );
           }
  -        this.caught = null;
  -        this.killedProcess = false;
  -        this.watch = true;
  -        this.process = process;
  +        this.m_caught = null;
  +        this.m_killedProcess = false;
  +        this.m_watch = true;
  +        this.m_process = process;
           final Thread thread = new Thread( this, "WATCHDOG" );
           thread.setDaemon( true );
           thread.start();
  @@ -194,7 +194,7 @@
        */
       public synchronized void stop()
       {
  -        watch = false;
  +        m_watch = false;
           notifyAll();
       }
   
  @@ -203,8 +203,8 @@
        */
       protected void cleanUp()
       {
  -        watch = false;
  -        process = null;
  +        m_watch = false;
  +        m_process = null;
       }
   }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>