ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs ExecuteJava.java
Date Sun, 07 Apr 2002 14:35:22 GMT
conor       02/04/07 07:35:22

  Modified:    src/main/org/apache/tools/ant Project.java
               src/main/org/apache/tools/ant/taskdefs ExecuteJava.java
  Log:
  Refector the new method into a separate set and get methods
  
  Revision  Changes    Path
  1.103     +23 -8     jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -w -u -r1.102 -r1.103
  --- Project.java	5 Apr 2002 15:11:42 -0000	1.102
  +++ Project.java	7 Apr 2002 14:35:22 -0000	1.103
  @@ -82,7 +82,7 @@
    *
    * @author duncan@x180.com
    *
  - * @version $Revision: 1.102 $
  + * @version $Revision: 1.103 $
    */
   
   public class Project {
  @@ -1782,7 +1782,7 @@
        */
       protected void fireTaskStarted(Task task) {
           // register this as the current task on the current thread.
  -        threadTasks.put(Thread.currentThread(), task);
  +        registerThreadTask(Thread.currentThread(), task);
           BuildEvent event = new BuildEvent(task);
           for (int i = 0; i < listeners.size(); i++) {
               BuildListener listener = (BuildListener) listeners.elementAt(i);
  @@ -1801,7 +1801,7 @@
        *                  a successful build.
        */
       protected void fireTaskFinished(Task task, Throwable exception) {
  -        threadTasks.remove(Thread.currentThread());
  +        registerThreadTask(Thread.currentThread(), null);
           System.out.flush();
           System.err.flush();
           BuildEvent event = new BuildEvent(task);
  @@ -1876,16 +1876,31 @@
       }
   
       /**
  -     * Treat messages generated in the given thread as messages that
  -     * come from the same task that is performed on the current
  -     * thread.
  +     * Register a task as the current task for a thread.
  +     * If the task is null, the thread's entry is removed.
        *
  +     * @param thread the thread on which the task is registered.
  +     * @param task the task to be registered.
        * @since 1.102, Ant 1.5
        */
  -    public void registerThreadLikeCurrent(Thread thread) {
  -        Task task = (Task) threadTasks.get(Thread.currentThread());
  +    public void registerThreadTask(Thread thread, Task task) {
           if (task != null) {
               threadTasks.put(thread, task);
  +        } else {
  +            threadTasks.remove(thread);
           }
       }
  +    
  +    /**
  +     * Get the current task assopciated with a thread, if any
  +     *
  +     * @param thread the thread for which the task is required.
  +     * @return the task which is currently registered for the given thread or
  +     *         null if no task is registered. 
  +     */
  +    public Task getThreadTask(Thread thread) {
  +        return (Task)threadTasks.get(thread);
  +    }
  +    
  +    
   }
  
  
  
  1.22      +4 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  
  Index: ExecuteJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -w -u -r1.21 -r1.22
  --- ExecuteJava.java	5 Apr 2002 15:11:42 -0000	1.21
  +++ ExecuteJava.java	7 Apr 2002 14:35:22 -0000	1.22
  @@ -57,7 +57,7 @@
   
   import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.BuildException;
  -
  +import org.apache.tools.ant.Task;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.Commandline;
   import org.apache.tools.ant.types.CommandlineJava;
  @@ -139,7 +139,9 @@
                   run();
               } else {
                   thread = new Thread(this, "ExecuteJava");
  -                project.registerThreadLikeCurrent(thread);
  +                Task currentThreadTask 
  +                    = project.getThreadTask(Thread.currentThread());
  +                project.registerThreadTask(thread, currentThreadTask);
                   // if we run into a timout, the run-away thread shall not
                   // make the VM run forever - if no timeout occurs, Ant's
                   // main thread will still be there to let the new thread
  
  
  

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