ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/event TaskEventManager.java
Date Wed, 05 Jun 2002 07:40:40 GMT
adammurdoch    2002/06/05 00:40:40

  Modified:    container/src/java/org/apache/myrmidon/components/event
                        DefaultTaskEventManager.java
               container/src/java/org/apache/myrmidon/components/executor
                        DefaultExecutor.java
               container/src/java/org/apache/myrmidon/interfaces/event
                        TaskEventManager.java
  Log:
  * Changed TaskEventManager.fireTaskStarting() and fireTaskFinished() to take
    a TaskEvent as parameter.
  
  * Changed DefaultExecutor to always fire a task finished event, even if the
    task throws an exception.
  
  Revision  Changes    Path
  1.3       +3 -11     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/event/DefaultTaskEventManager.java
  
  Index: DefaultTaskEventManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/event/DefaultTaskEventManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultTaskEventManager.java	17 May 2002 07:33:24 -0000	1.2
  +++ DefaultTaskEventManager.java	5 Jun 2002 07:40:40 -0000	1.3
  @@ -17,7 +17,7 @@
    * Support for the task listener event dispatching.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/17 07:33:24 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/05 07:40:40 $
    */
   public class DefaultTaskEventManager
       implements TaskEventManager
  @@ -52,12 +52,8 @@
       /**
        * Fire a taskStarting event.
        */
  -    public void fireTaskStarting( final String path,
  -                                  final String name,
  -                                  final String location )
  +    public void fireTaskStarting( final TaskEvent event )
       {
  -        final TaskEvent event =
  -            new TaskEvent( path, name, location, getCurrentProcessID() );
           for( int i = 0; i < m_listeners.length; i++ )
           {
               m_listeners[ i ].taskStarting( event );
  @@ -67,12 +63,8 @@
       /**
        * Fire a taskFinished event.
        */
  -    public void fireTaskFinished( final String path,
  -                                  final String name,
  -                                  final String location )
  +    public void fireTaskFinished( final TaskEvent event )
       {
  -        final TaskEvent event =
  -            new TaskEvent( path, name, location, getCurrentProcessID() );
           for( int i = 0; i < m_listeners.length; i++ )
           {
               m_listeners[ i ].taskFinished( event );
  
  
  
  1.44      +32 -4     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- DefaultExecutor.java	29 May 2002 06:42:26 -0000	1.43
  +++ DefaultExecutor.java	5 Jun 2002 07:40:40 -0000	1.44
  @@ -13,6 +13,8 @@
   import org.apache.myrmidon.api.Task;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.event.TaskEvent;
  +import org.apache.myrmidon.api.event.LogLevel;
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
  @@ -26,7 +28,7 @@
    * The basic executor that just executes the tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.43 $ $Date: 2002/05/29 06:42:26 $
  + * @version $Revision: 1.44 $ $Date: 2002/06/05 07:40:40 $
    */
   public class DefaultExecutor
       extends AbstractLogEnabled
  @@ -44,9 +46,35 @@
           final TaskEventManager eventManager = frame.getTaskEventManager();
           final String taskName = taskModel.getName();
           final String taskPath = frame.getName();
  -        eventManager.fireTaskStarting( taskPath, taskName, taskModel.getLocation() );
  -        doExecute( taskModel, frame );
  -        eventManager.fireTaskFinished( taskPath, taskName, taskModel.getLocation() );
  +        final String taskLocation = taskModel.getLocation();
  +
  +        // Fire start event
  +        final TaskEvent startEvent = new TaskEvent( taskPath, taskName, taskLocation, 0
);
  +        eventManager.fireTaskStarting( startEvent );
  +
  +        // Execute the task
  +        try
  +        {
  +            doExecute( taskModel, frame );
  +        }
  +        catch( final TaskException e )
  +        {
  +            // Task failed - fire finish event
  +            final TaskEvent finishEvent =
  +                new TaskEvent( taskPath,
  +                               taskName,
  +                               taskLocation,
  +                               e.getMessage(),
  +                               e,
  +                               LogLevel.ERROR,
  +                               0 );
  +            eventManager.fireTaskFinished( finishEvent );
  +            throw e;
  +        }
  +
  +        // Fire finish event
  +        final TaskEvent finishEvent = new TaskEvent( taskPath, taskName, taskLocation,
0 );
  +        eventManager.fireTaskFinished( finishEvent );
       }
   
       /**
  
  
  
  1.3       +3 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/event/TaskEventManager.java
  
  Index: TaskEventManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/event/TaskEventManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TaskEventManager.java	25 Apr 2002 08:19:04 -0000	1.2
  +++ TaskEventManager.java	5 Jun 2002 07:40:40 -0000	1.3
  @@ -15,7 +15,7 @@
    * and registration of {@link TaskListener} objects.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2002/04/25 08:19:04 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/05 07:40:40 $
    * @todo Move fire* methods to a separate service
    */
   public interface TaskEventManager
  @@ -39,12 +39,12 @@
       /**
        * Fire a taskStarting event.
        */
  -    void fireTaskStarting( String path, String name, String location );
  +    void fireTaskStarting( TaskEvent event );
   
       /**
        * Fire a taskFinished event.
        */
  -    void fireTaskFinished( String path, String name, String location );
  +    void fireTaskFinished( TaskEvent event );
   
       /**
        * Fire a taskFinished event.
  
  
  

--
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