You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by sg...@apache.org on 2010/08/12 20:10:12 UTC
svn commit: r984890 - in /commons/proper/exec/trunk/src:
main/java/org/apache/commons/exec/DefaultExecutor.java
main/java/org/apache/commons/exec/Executor.java site/apt/tutorial.apt
Author: sgoeschl
Date: Thu Aug 12 18:10:12 2010
New Revision: 984890
URL: http://svn.apache.org/viewvc?rev=984890&view=rev
Log:
Updating the documentation
Modified:
commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java
commons/proper/exec/trunk/src/site/apt/tutorial.apt
Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java?rev=984890&r1=984889&r2=984890&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java Thu Aug 12 18:10:12 2010
@@ -64,7 +64,12 @@ public class DefaultExecutor implements
private ProcessDestroyer processDestroyer;
/**
- * Default Constrctor
+ * Default constructor creating a default <code>PumpStreamHandler</code>.
+ * The <code>PumpStreamHandler</code> pumps the output of the subprocess
+ * into our <code>System.out</code> and <code>System.err</code> to avoid
+ * into our <code>System.out</code> and <code>System.err</code> to avoid
+ * a blocked or deadlocked subprocess (see
+ * {@link java.lang.Process Process}).
*/
public DefaultExecutor() {
this.streamHandler = new PumpStreamHandler();
Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java?rev=984890&r1=984889&r2=984890&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java Thu Aug 12 18:10:12 2010
@@ -96,11 +96,11 @@ public interface Executor {
ExecuteStreamHandler getStreamHandler();
/**
- * Set the StreamHandler used for providing input and
- * retrieving the output. If you don't provide a stream
- * handler the executed process might block when writing
- * to stdout and/or stderr (see {@link java.lang.Process
- * Process}).
+ * Set a custom the StreamHandler used for providing
+ * input and retrieving the output. If you don't provide
+ * a proper stream handler the executed process might block
+ * when writing to stdout and/or stderr (see
+ * {@link java.lang.Process Process}).
*
* @param streamHandler the stream handler
*/
Modified: commons/proper/exec/trunk/src/site/apt/tutorial.apt
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/site/apt/tutorial.apt?rev=984890&r1=984889&r2=984890&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/site/apt/tutorial.apt (original)
+++ commons/proper/exec/trunk/src/site/apt/tutorial.apt Thu Aug 12 18:10:12 2010
@@ -52,8 +52,8 @@ DefaultExecutor executor = new DefaultEx
int exitValue = executor.execute(commandLine);
+----------------------------------------------------------------------------
- You successfuly printed your first PDF document but at the end an exception is thrown - what
- happpend? Oops, Acrobat Reader returned an exit value of '1' on success which is usually
+ You successfully printed your first PDF document but at the end an exception is thrown - what
+ happend? Oops, Acrobat Reader returned an exit value of '1' on success which is usually
considered as an execution failure. So we have to tweak our code to fix this odd behaviour -
we define the exit value of "1" to be considered as successful execution.
@@ -160,14 +160,8 @@ int exitValue = executor.execute(command
Up to now we have a working example but it would not be good enough for
production - because it is blocking.
- At the one hand your print process might block when it tries to write to
- 'stdout' or 'stderr'. Avoiding this problem is done by setting a pump stream
- handler which pumps the output from the print process to your own process. A
- more detailed discussion can be found at
- {{{http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Process.html}java.lang.Process}}
-
- On the other hand your own worker thread will block until the print process
- has exited. Therefore executing the print job asynchronously will do the trick.
+ Your own worker thread will block until the print process has finshed.
+ Therefore executing the print job asynchronously will do the trick.
In this example we create an instance of 'ExecuteResultHandler' and pass it
to the 'Executor' instance in order to execute the process asynchronously.
The 'resultHandler' picks up any offending exception or the process exit