From a57f963f8bac3bd2d5b7693c17b16edf68b9f6ca Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 16 Dec 2001 04:41:03 +0000 Subject: [PATCH] Container tasks will need to erwritten in the context of Myrmidons mechanisms. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270187 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/Parallel.java | 171 ------------------ .../apache/tools/ant/taskdefs/Sequential.java | 60 ------ .../apache/tools/ant/taskdefs/Parallel.java | 171 ------------------ .../apache/tools/ant/taskdefs/Sequential.java | 60 ------ 4 files changed, 462 deletions(-) delete mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java delete mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sequential.java delete mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java delete mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sequential.java diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java deleted file mode 100644 index ac911515d..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.tools.ant.taskdefs; - -import java.util.Enumeration; -import java.util.Vector; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Location; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TaskContainer; - -/** - * Implements a multi threaded task execution.

- * - * - * - * @author Thomas Christen chr@active.ch - * @author Conor MacNeill - */ -public class Parallel extends Task - implements TaskContainer -{ - - /** - * Collection holding the nested tasks - */ - private Vector nestedTasks = new Vector(); - - /** - * Add a nested task to execute parallel (asynchron).

- * - * - * - * @param nestedTask Nested task to be executed in parallel - * @exception TaskException Description of Exception - */ - public void addTask( Task nestedTask ) - throws TaskException - { - nestedTasks.addElement( nestedTask ); - } - - /** - * Block execution until the specified time or for a specified amount of - * milliseconds and if defined, execute the wait status. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - TaskThread[] threads = new TaskThread[ nestedTasks.size() ]; - int threadNumber = 0; - for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); threadNumber++ ) - { - Task nestedTask = (Task)e.nextElement(); - threads[ threadNumber ] = new TaskThread( threadNumber, nestedTask ); - } - - // now start all threads - for( int i = 0; i < threads.length; ++i ) - { - threads[ i ].start(); - } - - // now join to all the threads - for( int i = 0; i < threads.length; ++i ) - { - try - { - threads[ i ].join(); - } - catch( InterruptedException ie ) - { - // who would interrupt me at a time like this? - } - } - - // now did any of the threads throw an exception - StringBuffer exceptionMessage = new StringBuffer(); - String lSep = System.getProperty( "line.separator" ); - int numExceptions = 0; - Throwable firstException = null; - Location firstLocation = Location.UNKNOWN_LOCATION; - ; - for( int i = 0; i < threads.length; ++i ) - { - Throwable t = threads[ i ].getException(); - if( t != null ) - { - numExceptions++; - if( firstException == null ) - { - firstException = t; - } - /* - if( t instanceof TaskException && - firstLocation == Location.UNKNOWN_LOCATION ) - { - firstLocation = ( (TaskException)t ).getLocation(); - } - */ - exceptionMessage.append( lSep ); - exceptionMessage.append( t.getMessage() ); - } - } - - if( numExceptions == 1 ) - { - if( firstException instanceof TaskException ) - { - throw (TaskException)firstException; - } - else - { - throw new TaskException( "Error", firstException ); - } - } - else if( numExceptions > 1 ) - { - throw new TaskException( exceptionMessage.toString() ); - } - } - - class TaskThread extends Thread - { - private Throwable exception; - private Task task; - private int taskNumber; - - /** - * Construct a new TaskThread

- * - * - * - * @param task the Task to be executed in a seperate thread - * @param taskNumber Description of Parameter - */ - TaskThread( int taskNumber, Task task ) - { - this.task = task; - this.taskNumber = taskNumber; - } - - public Throwable getException() - { - return exception; - } - - /** - * Executes the task within a thread and takes care about Exceptions - * raised within the task. - */ - public void run() - { - try - { - task.perform(); - } - catch( Throwable t ) - { - exception = t; - } - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sequential.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sequential.java deleted file mode 100644 index 15f042962..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sequential.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.tools.ant.taskdefs; - -import java.util.Enumeration; -import java.util.Vector; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TaskContainer; - -/** - * Implements a single threaded task execution.

- * - * - * - * @author Thomas Christen chr@active.ch - */ -public class Sequential extends Task - implements TaskContainer -{ - - /** - * Optional Vector holding the nested tasks - */ - private Vector nestedTasks = new Vector(); - - /** - * Add a nested task to Sequential.

- * - * - * - * @param nestedTask Nested task to execute Sequential

- * - * - */ - public void addTask( Task nestedTask ) - { - nestedTasks.addElement( nestedTask ); - } - - /** - * Execute all nestedTasks. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); ) - { - Task nestedTask = (Task)e.nextElement(); - nestedTask.perform(); - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java deleted file mode 100644 index ac911515d..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.tools.ant.taskdefs; - -import java.util.Enumeration; -import java.util.Vector; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Location; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TaskContainer; - -/** - * Implements a multi threaded task execution.

- * - * - * - * @author Thomas Christen chr@active.ch - * @author Conor MacNeill - */ -public class Parallel extends Task - implements TaskContainer -{ - - /** - * Collection holding the nested tasks - */ - private Vector nestedTasks = new Vector(); - - /** - * Add a nested task to execute parallel (asynchron).

- * - * - * - * @param nestedTask Nested task to be executed in parallel - * @exception TaskException Description of Exception - */ - public void addTask( Task nestedTask ) - throws TaskException - { - nestedTasks.addElement( nestedTask ); - } - - /** - * Block execution until the specified time or for a specified amount of - * milliseconds and if defined, execute the wait status. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - TaskThread[] threads = new TaskThread[ nestedTasks.size() ]; - int threadNumber = 0; - for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); threadNumber++ ) - { - Task nestedTask = (Task)e.nextElement(); - threads[ threadNumber ] = new TaskThread( threadNumber, nestedTask ); - } - - // now start all threads - for( int i = 0; i < threads.length; ++i ) - { - threads[ i ].start(); - } - - // now join to all the threads - for( int i = 0; i < threads.length; ++i ) - { - try - { - threads[ i ].join(); - } - catch( InterruptedException ie ) - { - // who would interrupt me at a time like this? - } - } - - // now did any of the threads throw an exception - StringBuffer exceptionMessage = new StringBuffer(); - String lSep = System.getProperty( "line.separator" ); - int numExceptions = 0; - Throwable firstException = null; - Location firstLocation = Location.UNKNOWN_LOCATION; - ; - for( int i = 0; i < threads.length; ++i ) - { - Throwable t = threads[ i ].getException(); - if( t != null ) - { - numExceptions++; - if( firstException == null ) - { - firstException = t; - } - /* - if( t instanceof TaskException && - firstLocation == Location.UNKNOWN_LOCATION ) - { - firstLocation = ( (TaskException)t ).getLocation(); - } - */ - exceptionMessage.append( lSep ); - exceptionMessage.append( t.getMessage() ); - } - } - - if( numExceptions == 1 ) - { - if( firstException instanceof TaskException ) - { - throw (TaskException)firstException; - } - else - { - throw new TaskException( "Error", firstException ); - } - } - else if( numExceptions > 1 ) - { - throw new TaskException( exceptionMessage.toString() ); - } - } - - class TaskThread extends Thread - { - private Throwable exception; - private Task task; - private int taskNumber; - - /** - * Construct a new TaskThread

- * - * - * - * @param task the Task to be executed in a seperate thread - * @param taskNumber Description of Parameter - */ - TaskThread( int taskNumber, Task task ) - { - this.task = task; - this.taskNumber = taskNumber; - } - - public Throwable getException() - { - return exception; - } - - /** - * Executes the task within a thread and takes care about Exceptions - * raised within the task. - */ - public void run() - { - try - { - task.perform(); - } - catch( Throwable t ) - { - exception = t; - } - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sequential.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sequential.java deleted file mode 100644 index 15f042962..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sequential.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.tools.ant.taskdefs; - -import java.util.Enumeration; -import java.util.Vector; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TaskContainer; - -/** - * Implements a single threaded task execution.

- * - * - * - * @author Thomas Christen chr@active.ch - */ -public class Sequential extends Task - implements TaskContainer -{ - - /** - * Optional Vector holding the nested tasks - */ - private Vector nestedTasks = new Vector(); - - /** - * Add a nested task to Sequential.

- * - * - * - * @param nestedTask Nested task to execute Sequential

- * - * - */ - public void addTask( Task nestedTask ) - { - nestedTasks.addElement( nestedTask ); - } - - /** - * Execute all nestedTasks. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); ) - { - Task nestedTask = (Task)e.nextElement(); - nestedTask.perform(); - } - } -}