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/23 00:54:47 UTC
cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec CommandLauncher.java Environment.java ExecManager.java
donaldp 01/12/22 15:54:47
Modified: proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec
CommandLauncher.java Environment.java
ExecManager.java
Log:
Convert from using TaskException to ExecException
Revision Changes Path
1.2 +3 -4 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/CommandLauncher.java
Index: CommandLauncher.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/CommandLauncher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CommandLauncher.java 2001/12/21 13:12:03 1.1
+++ CommandLauncher.java 2001/12/22 23:54:47 1.2
@@ -8,7 +8,6 @@
package org.apache.myrmidon.framework.exec;
import java.io.IOException;
-import org.apache.myrmidon.api.TaskException;
/**
* This is the interface implemented by objects which are capable of
@@ -19,7 +18,7 @@
* <code>CommandLauncher</code> most appropriate for their environment.</p>
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.1 $ $Date: 2001/12/21 13:12:03 $
+ * @version $Revision: 1.2 $ $Date: 2001/12/22 23:54:47 $
*/
public interface CommandLauncher
{
@@ -32,9 +31,9 @@
* launch the application for some reason. Usually due
* to the command not being fully specified and not in
* the PATH env var.
- * @exception TaskException if the command launcher detects that
+ * @exception ExecException if the command launcher detects that
* it can not execute the native command for some reason.
*/
Process exec( ExecMetaData metaData )
- throws IOException, TaskException;
+ throws IOException, ExecException;
}
1.2 +24 -17 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/Environment.java
Index: Environment.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/Environment.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Environment.java 2001/12/22 13:05:14 1.1
+++ Environment.java 2001/12/22 23:54:47 1.2
@@ -15,8 +15,8 @@
import java.util.Iterator;
import java.util.Locale;
import java.util.Properties;
-import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.exec.Execute;
import org.apache.tools.ant.taskdefs.exec.PumpStreamHandler;
@@ -26,7 +26,7 @@
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:thomas.haas@softwired-inc.com">Thomas Haas</a>
- * @version $Revision: 1.1 $ $Date: 2001/12/22 13:05:14 $
+ * @version $Revision: 1.2 $ $Date: 2001/12/22 23:54:47 $
*/
public final class Environment
{
@@ -49,7 +49,7 @@
}
public static String[] toNativeFormat( final Properties environment )
- throws TaskException
+ throws ExecException
{
final ArrayList newEnvironment = new ArrayList();
@@ -68,7 +68,7 @@
* @deprecated Dont use me!!!
*/
public static Properties createEnvVars( final String[] environment )
- throws TaskException
+ throws ExecException
{
final Properties newEnvironment = new Properties();
@@ -82,7 +82,7 @@
}
public static void addNativeEnvironment( final Properties environment )
- throws TaskException, IOException
+ throws ExecException, IOException
{
final Properties nativeEnvironment = getEnvironmentVariables();
final Iterator nativeKeys = nativeEnvironment.keySet().iterator();
@@ -105,7 +105,7 @@
* native EnvironmentData Variables for the current process.
*/
private static String[] getNativeEnvironmentAsArray()
- throws IOException, TaskException
+ throws IOException, ExecException
{
final Properties environment = getEnvironmentVariables();
@@ -128,7 +128,7 @@
* native EnvironmentData Variables for the current process.
*/
public static Properties getNativeEnvironment()
- throws IOException, TaskException
+ throws IOException, ExecException
{
return new Properties( getEnvironmentVariables() );
}
@@ -138,7 +138,7 @@
* attempt to load it if it has not already been loaded.
*/
private synchronized static Properties getEnvironmentVariables()
- throws IOException, TaskException
+ throws IOException, ExecException
{
if( null == c_procEnvironment )
{
@@ -152,7 +152,7 @@
* Retrieve a last of environment variables from the native OS.
*/
private static synchronized Properties retrieveEnvironmentVariables()
- throws IOException, TaskException
+ throws IOException, ExecException
{
final Properties properties = new Properties();
final String data = getEnvironmentText();
@@ -198,7 +198,7 @@
*/
private static void addProperty( final Properties properties,
final String data )
- throws TaskException
+ throws ExecException
{
final int index = data.indexOf( '=' );
if( -1 == index )
@@ -206,7 +206,7 @@
//Our env variable does not have any = in it.
final String message = "EnvironmentData variable '" + data +
"' does not have a '=' character in it";
- throw new TaskException( message );
+ throw new ExecException( message );
}
else
{
@@ -221,7 +221,7 @@
* running the environment command.
*/
private static String getEnvironmentText()
- throws IOException, TaskException
+ throws IOException, ExecException
{
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final Execute exe = new Execute( new PumpStreamHandler( output ) );
@@ -230,10 +230,17 @@
// Make sure we do not recurse forever
exe.setNewenvironment( true );
- final int retval = exe.execute();
- if( retval != 0 )
+ try
+ {
+ final int retval = exe.execute();
+ if( retval != 0 )
+ {
+ // Just try to use what we got
+ }
+ }
+ catch( final TaskException te )
{
- // Just try to use what we got
+ throw new ExecException( te.getMessage(), te );
}
return output.toString();
@@ -244,7 +251,7 @@
* variables.
*/
private static String[] getEnvCommand()
- throws TaskException
+ throws ExecException
{
if( Os.isFamily( "os/2" ) )
{
@@ -280,7 +287,7 @@
{
final String message =
"Unable to determine native environment variables";
- throw new TaskException( message );
+ throw new ExecException( message );
}
}
}
1.2 +2 -3 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java
Index: ExecManager.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ExecManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExecManager.java 2001/12/22 23:11:34 1.1
+++ ExecManager.java 2001/12/22 23:54:47 1.2
@@ -10,7 +10,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.myrmidon.api.TaskException;
/**
* Interface via which clients can request that a native
@@ -27,7 +26,7 @@
* </ul>
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.1 $ $Date: 2001/12/22 23:11:34 $
+ * @version $Revision: 1.2 $ $Date: 2001/12/22 23:54:47 $
*/
public interface ExecManager
{
@@ -53,5 +52,5 @@
OutputStream output,
OutputStream error,
long timeout )
- throws IOException, TaskException /*TimeoutException*/;
+ throws IOException, ExecException /*TimeoutException*/;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>