Browse Source

Use simplified AbstractContainerTask

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271693 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
16a1e94b65
2 changed files with 6 additions and 35 deletions
  1. +2
    -12
      proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
  2. +4
    -23
      proposal/myrmidon/src/java/org/apache/antlib/core/TryCatchTask.java

+ 2
- 12
proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java View File

@@ -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()


+ 4
- 23
proposal/myrmidon/src/java/org/apache/antlib/core/TryCatchTask.java View File

@@ -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";


Loading…
Cancel
Save