From 007e5e2034ecd772345540300195ae11d2bb590d Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Wed, 19 Dec 2001 11:50:18 +0000 Subject: [PATCH] spruced. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270268 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/exec/ExecuteWatchdog.java | 54 +++++++++---------- .../ant/taskdefs/exec/PumpStreamHandler.java | 48 +++++++++-------- .../ant/taskdefs/exec/ExecuteWatchdog.java | 54 +++++++++---------- .../ant/taskdefs/exec/PumpStreamHandler.java | 48 +++++++++-------- 4 files changed, 104 insertions(+), 100 deletions(-) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java index 71ee84a29..670622c51 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java @@ -24,34 +24,34 @@ import org.apache.myrmidon.api.TaskException; * @author Stephane Bailliez * @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 @@ public class ExecuteWatchdog implements Runnable { throw new IllegalArgumentException( "timeout lesser than 1." ); } - this.timeout = timeout; + this.m_timeout = timeout; } /** @@ -76,7 +76,7 @@ public class ExecuteWatchdog implements Runnable */ public boolean isWatching() { - return watch; + return m_watch; } /** @@ -91,10 +91,10 @@ public class ExecuteWatchdog implements Runnable 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 class ExecuteWatchdog implements Runnable */ public boolean killedProcess() { - return killedProcess; + return m_killedProcess; } /** @@ -118,9 +118,9 @@ public class ExecuteWatchdog implements Runnable { // 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 @@ public class ExecuteWatchdog implements Runnable { // 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 @@ public class ExecuteWatchdog implements Runnable { 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 class ExecuteWatchdog implements Runnable */ public synchronized void stop() { - watch = false; + m_watch = false; notifyAll(); } @@ -203,8 +203,8 @@ public class ExecuteWatchdog implements Runnable */ protected void cleanUp() { - watch = false; - process = null; + m_watch = false; + m_process = null; } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java index 3631dc27c..288221df9 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java @@ -19,18 +19,20 @@ import org.apache.myrmidon.api.TaskException; * * @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 class PumpStreamHandler implements ExecuteStreamHandler public void setProcessErrorStream( InputStream is ) { - createProcessErrorPump( is, err ); + createProcessErrorPump( is, m_error ); } public void setProcessInputStream( OutputStream os ) @@ -54,13 +56,13 @@ public class PumpStreamHandler implements ExecuteStreamHandler 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 @@ public class PumpStreamHandler implements ExecuteStreamHandler { 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 @@ public class PumpStreamHandler implements ExecuteStreamHandler 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 @@ public class PumpStreamHandler implements ExecuteStreamHandler * @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; } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java index 71ee84a29..670622c51 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecuteWatchdog.java @@ -24,34 +24,34 @@ import org.apache.myrmidon.api.TaskException; * @author Stephane Bailliez * @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 @@ public class ExecuteWatchdog implements Runnable { throw new IllegalArgumentException( "timeout lesser than 1." ); } - this.timeout = timeout; + this.m_timeout = timeout; } /** @@ -76,7 +76,7 @@ public class ExecuteWatchdog implements Runnable */ public boolean isWatching() { - return watch; + return m_watch; } /** @@ -91,10 +91,10 @@ public class ExecuteWatchdog implements Runnable 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 class ExecuteWatchdog implements Runnable */ public boolean killedProcess() { - return killedProcess; + return m_killedProcess; } /** @@ -118,9 +118,9 @@ public class ExecuteWatchdog implements Runnable { // 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 @@ public class ExecuteWatchdog implements Runnable { // 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 @@ public class ExecuteWatchdog implements Runnable { 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 class ExecuteWatchdog implements Runnable */ public synchronized void stop() { - watch = false; + m_watch = false; notifyAll(); } @@ -203,8 +203,8 @@ public class ExecuteWatchdog implements Runnable */ protected void cleanUp() { - watch = false; - process = null; + m_watch = false; + m_process = null; } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java index 3631dc27c..288221df9 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/PumpStreamHandler.java @@ -19,18 +19,20 @@ import org.apache.myrmidon.api.TaskException; * * @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 class PumpStreamHandler implements ExecuteStreamHandler public void setProcessErrorStream( InputStream is ) { - createProcessErrorPump( is, err ); + createProcessErrorPump( is, m_error ); } public void setProcessInputStream( OutputStream os ) @@ -54,13 +56,13 @@ public class PumpStreamHandler implements ExecuteStreamHandler 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 @@ public class PumpStreamHandler implements ExecuteStreamHandler { 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 @@ public class PumpStreamHandler implements ExecuteStreamHandler 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 @@ public class PumpStreamHandler implements ExecuteStreamHandler * @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; } - }