commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgoes...@apache.org
Subject svn commit: r997448 - in /commons/proper/exec/trunk/src: main/java/org/apache/commons/exec/util/StringUtils.java site/apt/tutorial.apt
Date Wed, 15 Sep 2010 18:40:43 GMT
Author: sgoeschl
Date: Wed Sep 15 18:40:42 2010
New Revision: 997448

URL: http://svn.apache.org/viewvc?rev=997448&view=rev
Log:
Updating documentation

Modified:
    commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
    commons/proper/exec/trunk/src/site/apt/tutorial.apt

Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java?rev=997448&r1=997447&r2=997448&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
(original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
Wed Sep 15 18:40:42 2010
@@ -29,8 +29,6 @@ import java.io.File;
  * Supplement of commons-lang, the stringSubstitution() was in a simpler
  * implementation available in an older commons-lang implementation.
  *
- * Furthermore a place to put reusable and/or ugly code.
- *
  * This class is not part of the public API and could change without
  * warning.
  *

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=997448&r1=997447&r2=997448&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/site/apt/tutorial.apt (original)
+++ commons/proper/exec/trunk/src/site/apt/tutorial.apt Wed Sep 15 18:40:42 2010
@@ -20,7 +20,7 @@
 Apache Commons Exec Tutorial
  --------
  --------
-12 November 2008
+15 September 2010
  --------
 
 Apache Commons Exec
@@ -120,34 +120,13 @@ int exitValue = executor.execute(command
   {{{http://ant.apache.org/manual/CoreTasks/exec.html}exec}} task)
   
 +----------------------------------------------------------------------------
-CommandLine commandLine = CommandLine.parse("AcroRd32.exe");
-commandLine.addArgument("/p");
-commandLine.addArgument("/h");
-commandLine.addArgument(file.getAbsolutePath());
-DefaultExecutor executor = new DefaultExecutor();
-executor.setExitValue(1);
-ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
-executor.setWatchdog(watchdog);
-int exitValue = executor.execute(commandLine);
-+----------------------------------------------------------------------------
-
-* Using Command Line Expansion
-
-  In the previous example we basically hardcoded the command line to be
-  executed. Using a different application to print PDF documents or just
-  tinkering with command line options would require a new release - uncool.
-  To write better code you can look at the following code snippet.
-
-+----------------------------------------------------------------------------
 Map map = new HashMap();
-map.put("file", "C:\Document And Settings\documents\432432.pdf");
-
+map.put("file", new File("the_document_you_would_like_to_print"));
 CommandLine commandLine = CommandLine.parse("AcroRd32.exe");
 commandLine.addArgument("/p");
 commandLine.addArgument("/h");
 commandLine.addArgument("${file}");
 commandLine.setSubstitutionMap(map);
-
 DefaultExecutor executor = new DefaultExecutor();
 executor.setExitValue(1);
 ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
@@ -155,17 +134,21 @@ executor.setWatchdog(watchdog);
 int exitValue = executor.execute(commandLine);
 +----------------------------------------------------------------------------
 
+  Please note that we are passing an 'java.io.File' instance for expanding
+  the command line arguments - this allows to convert the resulting file name
+  on the fly to match your OS.
+
 * Unblock Your Execution
 
   Up to now we have a working example but it would not be good enough for
   production - because it is blocking.
 
-  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
-  code.
+  Your worker thread will block until the print process has finished or
+  was killed by the watchdog. 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 code.
 
 +----------------------------------------------------------------------------
 CommandLine commandLine = CommandLine.parse(this.acroRd32Script.getAbsolutePath());
@@ -188,6 +171,5 @@ executor.execute(commandLine, resultHand
 // some time later the result handler callback was invoked so we
 // can safely request the exit value
 int exitValue = resultHandler.waitFor();
-
 +----------------------------------------------------------------------------
   



Mime
View raw message