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-myrmidon/api/src/java/org/apache/myrmidon/api TaskContext.java
Date Fri, 21 Jun 2002 00:59:38 GMT
donaldp     2002/06/20 17:59:38

  Modified:    container/src/java/org/apache/myrmidon/components/executor
                        DefaultExecutor.java
               api/src/java/org/apache/myrmidon/api TaskContext.java
  Log:
  Start decoupling DefaultExecutor from ExecutionFrame
  
  Revision  Changes    Path
  1.49      +23 -28    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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- DefaultExecutor.java	21 Jun 2002 00:45:16 -0000	1.48
  +++ DefaultExecutor.java	21 Jun 2002 00:59:38 -0000	1.49
  @@ -43,9 +43,12 @@
                            final ExecutionFrame frame )
           throws TaskException
       {
  -        final TaskEventManager eventManager = (TaskEventManager)frame.lookup( TaskEventManager.ROLE
);
  +        final TaskContext context = frame.createTaskContext( taskModel.getName(), taskModel.getName()
);
  +
  +        final TaskEventManager eventManager =
  +            (TaskEventManager)context.getService( TaskEventManager.class );
           final String taskName = taskModel.getName();
  -        final String taskPath = frame.getName();
  +        final String taskPath = context.getPath();
           final String taskLocation = taskModel.getLocation();
   
           // Fire start event
  @@ -55,7 +58,7 @@
           // Execute the task
           try
           {
  -            doExecute( taskModel, frame );
  +            doExecute( taskModel, context );
           }
           catch( final TaskException e )
           {
  @@ -71,6 +74,11 @@
               eventManager.fireTaskFinished( finishEvent );
               throw e;
           }
  +        finally
  +        {
  +            // TODO - need to deactivate the context once the task has finished
  +            // executing
  +        }
   
           // Fire finish event
           final TaskEvent finishEvent = new TaskEvent( taskPath, taskName, taskLocation,
0 );
  @@ -88,26 +96,25 @@
        * </ul>
        *
        * @param taskModel the task model representing task
  -     * @param frame the frame in which to execute task
  +     * @param context the context in which to execute task
        * @throws TaskException if the task generates a TaskException
        *         or there is a failure configuring task
        */
       protected void doExecute( final ModelElement taskModel,
  -                              final ExecutionFrame frame )
  +                              final TaskContext context )
           throws TaskException
       {
           final String taskName = taskModel.getName();
           try
           {
               debug( "creating.notice", taskName );
  -            final Task task = doCreateTask( taskName, frame );
  +            final Task task = doCreateTask( taskName, context );
   
               debug( "contextualizing.notice", taskName );
  -            final TaskContext context = doCreateContext( frame, taskModel );
  -            doContextualize( task, taskModel, context, frame );
  +            doContextualize( task, taskModel, context );
   
               debug( "configuring.notice", taskName );
  -            doConfigure( task, taskModel, context, frame );
  +            doConfigure( task, taskModel, context );
   
               debug( "executing.notice", taskName );
               doTaskExecute( taskModel, task );
  @@ -144,25 +151,15 @@
       }
   
       /**
  -     * Creates a context for the task.
  -     */
  -    protected TaskContext doCreateContext( final ExecutionFrame frame, ModelElement taskModel
)
  -        throws TaskException
  -    {
  -        // TODO - need to deactivate the context once the task has finished
  -        // executing
  -        return frame.createTaskContext( taskModel.getName(), taskModel.getName() );
  -    }
  -
  -    /**
        * Creates a task instance.
        */
  -    protected final Task doCreateTask( final String name, final ExecutionFrame frame )
  +    protected final Task doCreateTask( final String name,
  +                                       final TaskContext context )
           throws TaskException
       {
           try
           {
  -            final TypeManager typeManager = (TypeManager)frame.lookup( TypeManager.ROLE
);
  +            final TypeManager typeManager = (TypeManager)context.getService( TypeManager.class
);
               final TypeFactory factory = typeManager.getFactory( Task.ROLE );
               return (Task)factory.create( name );
           }
  @@ -178,8 +175,7 @@
        */
       protected final void doContextualize( final Task task,
                                             final ModelElement taskModel,
  -                                          final TaskContext taskContext,
  -                                          final ExecutionFrame frame )
  +                                          final TaskContext taskContext )
           throws TaskException
       {
           try
  @@ -199,11 +195,10 @@
        */
       protected final void doConfigure( final Task task,
                                         final ModelElement taskModel,
  -                                      final TaskContext taskContext,
  -                                      final ExecutionFrame frame )
  +                                      final TaskContext taskContext )
           throws Exception
       {
  -        final Configurer configurer = (Configurer)frame.lookup( Configurer.ROLE );
  +        final Configurer configurer = (Configurer)taskContext.getService( Configurer.class
);
           configurer.configureElement( task, taskModel, taskContext );
       }
   
  
  
  
  1.38      +1 -8      jakarta-ant-myrmidon/api/src/java/org/apache/myrmidon/api/TaskContext.java
  
  Index: TaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/api/src/java/org/apache/myrmidon/api/TaskContext.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- TaskContext.java	21 Jun 2002 00:45:16 -0000	1.37
  +++ TaskContext.java	21 Jun 2002 00:59:38 -0000	1.38
  @@ -38,13 +38,6 @@
       String getPath();
   
       /**
  -     * Retrieve Name of task.
  -     *
  -     * @return the name
  -     */
  -    String getName();
  -
  -    /**
        * Retrieve the physical location of the task.
        * The format of this string is not specified but is dependent
        * on the medium tasks are built from. For standard XML files
  
  
  

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