From 16a1e94b65dc7485304a4f5d0f2f14baf6a56c3e Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 3 Mar 2002 06:43:50 +0000 Subject: [PATCH] Use simplified AbstractContainerTask git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271693 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/antlib/core/IfTask.java | 14 ++-------- .../org/apache/antlib/core/TryCatchTask.java | 27 +++---------------- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java index f376ff937..06fdd29bd 100644 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java +++ b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java @@ -16,8 +16,6 @@ import org.apache.myrmidon.framework.AbstractContainerTask; import org.apache.myrmidon.framework.Condition; import org.apache.myrmidon.framework.conditions.IsSetCondition; import org.apache.myrmidon.framework.conditions.NotCondition; -import org.apache.myrmidon.interfaces.executor.ExecutionFrame; -import org.apache.myrmidon.interfaces.executor.Executor; /** * A simple task to test a supplied condition. If the condition is true @@ -77,7 +75,7 @@ public class IfTask } // Evaluate the condition - if( ! m_condition.evaluate( getContext() ) ) + if( !m_condition.evaluate( getContext() ) ) { return; } @@ -85,15 +83,7 @@ public class IfTask final Configuration[] tasks = (Configuration[])m_tasks.toArray( new Configuration[ m_tasks.size() ] ); - // TODO - don't use getService() - final ExecutionFrame frame = (ExecutionFrame)getService( ExecutionFrame.class ); - final Executor executor = (Executor)getService( Executor.class ); - - for( int i = 0; i < tasks.length; i++ ) - { - final Configuration task = tasks[ i ]; - executor.execute( task, frame ); - } + executeTasks( tasks ); } public String toString() diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/TryCatchTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/TryCatchTask.java index 89cf944b0..4e915d811 100644 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/TryCatchTask.java +++ b/proposal/myrmidon/src/java/org/apache/antlib/core/TryCatchTask.java @@ -12,8 +12,7 @@ import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.configuration.Configuration; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.framework.AbstractContainerTask; -import org.apache.myrmidon.interfaces.executor.ExecutionFrame; -import org.apache.myrmidon.interfaces.executor.Executor; +import org.apache.myrmidon.framework.TaskList; /** * A task that emulates the try-catch-finally construct in a number @@ -81,20 +80,17 @@ public final class TryCatchTask { validate(); - final ExecutionFrame frame = (ExecutionFrame)getService( ExecutionFrame.class ); - final Executor executor = (Executor)getService( Executor.class ); - try { final Configuration[] tasks = m_try.getTasks(); - executeTasks( executor, frame, tasks ); + executeTasks( tasks ); } catch( final TaskException te ) { if( null != m_catch ) { final Configuration[] tasks = m_catch.getTasks(); - executeTasks( executor, frame, tasks ); + executeTasks( tasks ); } else { @@ -106,7 +102,7 @@ public final class TryCatchTask if( null != m_finally ) { final Configuration[] tasks = m_finally.getTasks(); - executeTasks( executor, frame, tasks ); + executeTasks( tasks ); } } } @@ -126,21 +122,6 @@ public final class TryCatchTask } } - /** - * Utility method to execute the tasks in an appropriate environment. - */ - private void executeTasks( final Executor executor, - final ExecutionFrame frame, - final Configuration[] tasks ) - throws TaskException - { - for( int i = 0; i < tasks.length; i++ ) - { - final Configuration task = tasks[ i ]; - executor.execute( task, frame ); - } - } - public String toString() { return "Try-Catch-Finally";