ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec Execute2.java Execute.java
Date Sat, 26 Jan 2002 04:53:53 GMT
donaldp     02/01/25 20:53:53

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec
                        Execute2.java Execute.java
  Log:
  Ugly hack to retrieve ExecManagerService by directly instantiating factory. This should
really be done by the container in the future but is done here now to test out some ideas
  
  Revision  Changes    Path
  1.3       +12 -19    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute2.java
  
  Index: Execute2.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute2.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Execute2.java	12 Jan 2002 04:56:25 -0000	1.2
  +++ Execute2.java	26 Jan 2002 04:53:53 -0000	1.3
  @@ -10,13 +10,15 @@
   import java.io.File;
   import java.io.IOException;
   import java.util.Properties;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.myrmidon.api.TaskException;
   import org.apache.aut.nativelib.DefaultExecOutputHandler;
   import org.apache.aut.nativelib.ExecException;
  +import org.apache.aut.nativelib.ExecManager;
   import org.apache.aut.nativelib.ExecMetaData;
   import org.apache.aut.nativelib.ExecOutputHandler;
  -import org.apache.aut.nativelib.impl.DefaultExecManager;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.framework.factorys.ExecManagerFactory;
  +import org.apache.myrmidon.services.ServiceException;
   
   /**
    * Runs an external program.
  @@ -38,19 +40,6 @@
        */
       private boolean m_useVMLauncher = true;
   
  -    private static File getAntHomeDirectory()
  -    {
  -        final String antHome = System.getProperty( "myrmidon.home" );
  -        if( null == antHome )
  -        {
  -            final String message =
  -                "Cannot locate antRun script: Property 'ant.home' not specified";
  -            throw new IllegalStateException( message );
  -        }
  -
  -        return new File( antHome );
  -    }
  -
       public void setTimeout( final long timeout )
       {
           m_timeout = timeout;
  @@ -66,7 +55,7 @@
        *
        * @param commandline the commandline of the subprocess to launch
        */
  -    public void setCommandline( String[] commandline )
  +    public void setCommandline( final String[] commandline )
       {
           m_command = commandline;
       }
  @@ -117,8 +106,8 @@
   
           try
           {
  -            final DefaultExecManager manager =
  -                new DefaultExecManager( getAntHomeDirectory() );
  +            final ExecManagerFactory factory = new ExecManagerFactory();
  +            final ExecManager manager = (ExecManager)factory.createService();
   
               final ExecMetaData metaData =
                   new ExecMetaData( m_command, m_environment,
  @@ -129,6 +118,10 @@
           catch( final ExecException ee )
           {
               throw new TaskException( ee.getMessage(), ee );
  +        }
  +        catch( final ServiceException se )
  +        {
  +            throw new TaskException( se.getMessage(), se );
           }
       }
   }
  
  
  
  1.27      +16 -32    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute.java
  
  Index: Execute.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Execute.java	12 Jan 2002 04:56:25 -0000	1.26
  +++ Execute.java	26 Jan 2002 04:53:53 -0000	1.27
  @@ -11,10 +11,13 @@
   import java.io.IOException;
   import java.io.OutputStream;
   import java.util.Properties;
  -import org.apache.myrmidon.api.TaskException;
   import org.apache.aut.nativelib.ExecException;
  +import org.apache.aut.nativelib.ExecManager;
   import org.apache.aut.nativelib.ExecMetaData;
  -import org.apache.aut.nativelib.impl.DefaultExecManager;
  +import org.apache.avalon.excalibur.io.IOUtil;
  +import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.framework.factorys.ExecManagerFactory;
  +import org.apache.myrmidon.services.ServiceException;
   
   /**
    * Runs an external program.
  @@ -36,34 +39,6 @@
        */
       private boolean m_useVMLauncher = true;
   
  -    private static File getAntHomeDirectory()
  -    {
  -        final String antHome = System.getProperty( "myrmidon.home" );
  -        if( null == antHome )
  -        {
  -            final String message =
  -                "Cannot locate antRun script: Property 'ant.home' not specified";
  -            throw new IllegalStateException( message );
  -        }
  -
  -        return new File( antHome );
  -    }
  -
  -    /**
  -     * Creates a new execute object.
  -     *
  -     * @param streamHandler the stream handler used to handle the input and
  -     *      output streams of the subprocess.
  -     */
  -    public Execute( final ExecuteStreamHandler streamHandler )
  -    {
  -        //m_streamHandler = streamHandler;
  -    }
  -
  -    public Execute()
  -    {
  -    }
  -
       public void setTimeout( final long timeout )
       {
           m_timeout = timeout;
  @@ -142,8 +117,8 @@
       {
           try
           {
  -            final DefaultExecManager manager =
  -                new DefaultExecManager( getAntHomeDirectory() );
  +            final ExecManagerFactory factory = new ExecManagerFactory();
  +            final ExecManager manager = (ExecManager)factory.createService();
   
               final ExecMetaData metaData =
                   new ExecMetaData( m_command, m_environment,
  @@ -153,6 +128,15 @@
           catch( final ExecException ee )
           {
               throw new TaskException( ee.getMessage(), ee );
  +        }
  +        catch( final ServiceException se )
  +        {
  +            throw new TaskException( se.getMessage(), se );
  +        }
  +        finally
  +        {
  +            IOUtil.shutdownStream( m_output );
  +            IOUtil.shutdownStream( m_error );
           }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message