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/proposal/mutant/src/java/common/org/apache/ant/common/service EventService.java ComponentService.java
Date Thu, 07 Feb 2002 14:42:37 GMT
conor       02/02/07 06:42:37

  Modified:    proposal/mutant ant1compat.xml
               proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib
                        AntLibDefinition.java AntLibrary.java
               proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
                        ComponentManager.java ExecutionFrame.java
               proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant
                        Ant1Factory.java Project.java Target.java
               proposal/mutant/src/java/antlibs/system antlib.xml
               proposal/mutant/src/java/common/org/apache/ant/common/service
                        ComponentService.java
  Added:       proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
                        CoreEventService.java
               proposal/mutant/src/java/common/org/apache/ant/common/service
                        EventService.java
  Removed:     proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant
                        AntClassLoader.java BuildEvent.java
                        BuildListener.java
  Log:
  Improved Ant1 compatability by removing some facades
  
  Revision  Changes    Path
  1.5       +6 -3      jakarta-ant/proposal/mutant/ant1compat.xml
  
  Index: ant1compat.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/ant1compat.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -u -r1.4 -r1.5
  --- ant1compat.xml	7 Feb 2002 09:43:17 -0000	1.4
  +++ ant1compat.xml	7 Feb 2002 14:42:36 -0000	1.5
  @@ -29,9 +29,9 @@
       <exclude name="org/apache/tools/ant/taskdefs/optional/sound/*.java"/>
       <exclude name="org/apache/tools/ant/taskdefs/optional/Native2Ascii.java"/>
       <exclude name="org/apache/tools/ant/taskdefs/optional/Javah.java"/>
  -    <exclude name="org/apache/tools/ant/taskdefs/Typedef.java"/>
  -    <exclude name="org/apache/tools/ant/taskdefs/Taskdef.java"/>
  -    <exclude name="org/apache/tools/ant/taskdefs/Definer.java"/>
  +    <!-- <exclude name="org/apache/tools/ant/taskdefs/Typedef.java"/> -->
  +    <!-- <exclude name="org/apache/tools/ant/taskdefs/Taskdef.java"/> -->
  +    <!-- <exclude name="org/apache/tools/ant/taskdefs/Definer.java"/> -->
       <exclude name="org/apache/tools/ant/taskdefs/Parallel.java"/>
       <exclude name="org/apache/tools/ant/taskdefs/Sequential.java"/>
       <exclude name="org/apache/tools/ant/taskdefs/optional/ejb/**/*.java"/>
  @@ -61,6 +61,9 @@
       <include name="org/apache/tools/ant/FileScanner.java"/>
       <include name="org/apache/tools/ant/TaskAdapter.java"/>
       <include name="org/apache/tools/ant/Location.java"/>
  +    <include name="org/apache/tools/ant/AntClassLoader.java"/>
  +    <include name="org/apache/tools/ant/BuildEvent.java"/>
  +    <include name="org/apache/tools/ant/BuildListener.java"/>
       <patternset refid="deprecated"/>
       <patternset refid="toohard"/>
       <patternset refid="converted"/>
  
  
  
  1.3       +1 -1      jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibDefinition.java
  
  Index: AntLibDefinition.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibDefinition.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -u -r1.2 -r1.3
  --- AntLibDefinition.java	22 Jan 2002 23:03:11 -0000	1.2
  +++ AntLibDefinition.java	7 Feb 2002 14:42:36 -0000	1.3
  @@ -60,7 +60,7 @@
    * @created 19 January 2002
    */
   public class AntLibDefinition {
  -    /** The tpye of element being defined int his definition */
  +    /** The type of element being defined int his definition */
       private int definitionType;
       /** The default name for the defintion */
       private String definitionName;
  
  
  
  1.4       +23 -0     jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrary.java
  
  Index: AntLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrary.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -u -r1.3 -r1.4
  --- AntLibrary.java	2 Feb 2002 14:50:30 -0000	1.3
  +++ AntLibrary.java	7 Feb 2002 14:42:36 -0000	1.4
  @@ -55,6 +55,7 @@
   import java.net.URL;
   import java.net.URLClassLoader;
   import java.util.ArrayList;
  +import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  @@ -68,10 +69,13 @@
    * @created 14 January 2002
    */
   public class AntLibrary {
  +
       /** constant indicating a taskdef definition */
       public final static int TASKDEF = 1;
       /** constant indicating a typedef definition */
       public final static int TYPEDEF = 2;
  +    /** A counter for generating unique ids */
  +    private static int implicitLibCount = 0;
   
       /**
        * This is the globally unique name of this library. It uses the same
  @@ -122,6 +126,25 @@
           this.converterClassNames.addAll(spec.getConverters());
           this.factoryClassName = spec.getFactory();
           this.definitionURL = spec.getLibraryURL();
  +    }
  +
  +    /**
  +     * Create an Ant library to wrap around an existing class
  +     *
  +     * @param componentName the name of the component to be wrapped
  +     * @param componentClass the class to be wrapped
  +     * @param defType the type of definition being defined
  +     */
  +    public AntLibrary(int defType, String componentName, Class componentClass) {
  +        this.libraryId = "_internal" + (implicitLibCount++);
  +        this.definitions = new HashMap();
  +        AntLibDefinition definition = new AntLibDefinition(defType,
  +            componentName, componentClass.getName());
  +        this.definitions.put(componentName, definition);
  +        this.isolated = false;
  +        this.factoryClassName = null;
  +        this.definitionURL = null;
  +        loader = componentClass.getClassLoader();
       }
   
       /**
  
  
  
  1.2       +42 -0     jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java
  
  Index: ComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -u -r1.1 -r1.2
  --- ComponentManager.java	5 Feb 2002 11:49:04 -0000	1.1
  +++ ComponentManager.java	7 Feb 2002 14:42:37 -0000	1.2
  @@ -199,6 +199,30 @@
       }
   
       /**
  +     * Experimental - define a new task
  +     *
  +     * @param taskName the name by which this task will be referred
  +     * @param taskClass the class of the task
  +     * @exception ExecutionException if the task cannot be defined
  +     */
  +    public void taskdef(String taskName, Class taskClass)
  +         throws ExecutionException {
  +        defineComponent(AntLibrary.TASKDEF, taskName, taskClass);
  +    }
  +
  +    /**
  +     * Experimental - define a new type
  +     *
  +     * @param typeName the name by which this type will be referred
  +     * @param typeClass the class of the type
  +     * @exception ExecutionException if the type cannot be defined
  +     */
  +    public void typedef(String typeName, Class typeClass)
  +         throws ExecutionException {
  +        defineComponent(AntLibrary.TYPEDEF, typeName, typeClass);
  +    }
  +
  +    /**
        * Set the standard libraries (i.e. those which are independent of the
        * build files) to be used in this component manager
        *
  @@ -293,6 +317,24 @@
               definitions.put(defName, new ImportInfo(library, libdef));
           }
           addLibraryConverters(library);
  +    }
  +
  +    /**
  +     * Experimental - define a new component
  +     *
  +     * @param componentName the name this component will take
  +     * @param componentClass the component's class
  +     * @param defType the type of component being defined
  +     * @exception ExecutionException if the component cannot be defined
  +     */
  +    private void defineComponent(int defType, String componentName,
  +                                 Class componentClass)
  +         throws ExecutionException {
  +        AntLibrary wrapperLibrary
  +             = new AntLibrary(defType, componentName, componentClass);
  +        String libraryId = wrapperLibrary.getLibraryId();
  +        antLibraries.put(libraryId, wrapperLibrary);
  +        importLibrary(libraryId);
       }
   
       /**
  
  
  
  1.11      +2 -0      jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java
  
  Index: ExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -u -r1.10 -r1.11
  --- ExecutionFrame.java	7 Feb 2002 09:43:17 -0000	1.10
  +++ ExecutionFrame.java	7 Feb 2002 14:42:37 -0000	1.11
  @@ -72,6 +72,7 @@
   import org.apache.ant.common.service.ComponentService;
   import org.apache.ant.common.service.DataService;
   import org.apache.ant.common.service.FileService;
  +import org.apache.ant.common.service.EventService;
   import org.apache.ant.common.service.MagicProperties;
   import org.apache.ant.common.util.AntException;
   import org.apache.ant.common.util.ConfigException;
  @@ -764,6 +765,7 @@
           services.put(FileService.class, fileService);
           services.put(ComponentService.class, componentManager);
           services.put(DataService.class, dataService);
  +        services.put(EventService.class,  new CoreEventService(this));
       }
   
       /**
  
  
  
  1.1                  jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreEventService.java
  
  Index: CoreEventService.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.ant.antcore.execution;
  import org.apache.ant.common.event.BuildListener;
  import org.apache.ant.common.service.EventService;
  import org.apache.ant.common.util.ExecutionException;
  
  /**
   * Core implementation of the event service
   *
   * @author <a href="mailto:conor@apache.org">Conor MacNeill</a>
   * @created 7 February 2002
   */
  public class CoreEventService implements EventService {
      /** The ExecutionFrame this service instance is working for */
      private ExecutionFrame frame;
  
      /**
       * Constructor
       *
       * @param frame the frame for which this instance is providing service
       */
      public CoreEventService(ExecutionFrame frame) {
          this.frame = frame;
      }
  
      /**
       * Add a build listener to the current frame
       *
       * @param listener the lister which will receive build events
       * @exception ExecutionException if the listener cannot be added
       */
      public void addBuildListener(BuildListener listener)
           throws ExecutionException {
          frame.addBuildListener(listener);
      }
  
      /**
       * Remove a listener from the current frame
       *
       * @param listener the listener to be removed
       * @exception ExecutionException if the listener could not be removed
       */
      public void removeBuildListener(BuildListener listener)
           throws ExecutionException {
          frame.removeBuildListener(listener);
      }
  }
  
  
  
  
  1.5       +5 -0      jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java
  
  Index: Ant1Factory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -u -r1.4 -r1.5
  --- Ant1Factory.java	7 Feb 2002 09:43:17 -0000	1.4
  +++ Ant1Factory.java	7 Feb 2002 14:42:37 -0000	1.5
  @@ -56,6 +56,7 @@
   import org.apache.ant.common.antlib.Converter;
   import org.apache.ant.common.antlib.StandardLibFactory;
   import org.apache.ant.common.util.ExecutionException;
  +import org.apache.ant.common.service.EventService;
   import org.apache.ant.init.LoaderUtils;
   
   /**
  @@ -89,6 +90,10 @@
   
           project = new Project();
           project.init(context);
  +        
  +        EventService eventService = 
  +            (EventService)context.getCoreService(EventService.class);
  +        eventService.addBuildListener(project);
       }
   
   
  
  
  
  1.5       +279 -8    jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -u -r1.4 -r1.5
  --- Project.java	6 Feb 2002 12:52:57 -0000	1.4
  +++ Project.java	7 Feb 2002 14:42:37 -0000	1.5
  @@ -60,7 +60,10 @@
   import java.util.Iterator;
   import java.util.Map;
   import java.util.Properties;
  +import java.util.Stack;
  +import java.util.Vector;
   import org.apache.ant.common.antlib.AntContext;
  +import org.apache.ant.common.service.ComponentService;
   import org.apache.ant.common.service.DataService;
   import org.apache.ant.common.service.FileService;
   import org.apache.ant.common.util.ExecutionException;
  @@ -76,7 +79,7 @@
    * @author <a href="mailto:conor@apache.org">Conor MacNeill</a>
    * @created 30 January 2002
    */
  -public class Project {
  +public class Project implements org.apache.ant.common.event.BuildListener {
   
       /** String which indicates Java version 1.0 */
       public final static String JAVA_1_0 = "1.0";
  @@ -133,12 +136,21 @@
       /** The core's DataService instance */
       private DataService dataService;
   
  -    /** Ant1 FileUtils instance fro manipulating files */
  +    /** The core's Component Service instance */
  +    private ComponentService componentService;
  +
  +    /** Ant1 FileUtils instance for manipulating files */
       private FileUtils fileUtils;
       /** The collection of global filters */
       private FilterSetCollection globalFilters
            = new FilterSetCollection(globalFilterSet);
   
  +    /** This project's listeners */
  +    private Vector listeners = new Vector();
  +
  +    /** the target's we have seen */
  +    private Stack targetStack = new Stack();
  +
       static {
   
           // Determine the Java version by looking at available classes
  @@ -273,6 +285,15 @@
       }
   
       /**
  +     * Gets the buildListeners of the Project
  +     *
  +     * @return A Vector of BuildListener instances
  +     */
  +    public Vector getBuildListeners() {
  +        return listeners;
  +    }
  +
  +    /**
        * Gets the AntContext of the Project
        *
        * @return the AntContext
  @@ -410,6 +431,91 @@
       }
   
       /**
  +     * build started event
  +     *
  +     * @param event build started event
  +     */
  +    public void buildStarted(org.apache.ant.common.event.BuildEvent event) {
  +        fireBuildStarted();
  +    }
  +
  +    /**
  +     * build finished event
  +     *
  +     * @param event build finished event
  +     */
  +    public void buildFinished(org.apache.ant.common.event.BuildEvent event) {
  +        fireBuildFinished(event.getCause());
  +    }
  +
  +    /**
  +     * target started event.
  +     *
  +     * @param event target started event.
  +     */
  +    public void targetStarted(org.apache.ant.common.event.BuildEvent event) {
  +        Target newTarget = new Target(this);
  +        org.apache.ant.common.model.Target realTarget =
  +            (org.apache.ant.common.model.Target)event.getModelElement();
  +        newTarget.setName(realTarget.getName());
  +        targetStack.push(newTarget);
  +        fireTargetStarted(newTarget);
  +    }
  +
  +    /**
  +     * target finished event
  +     *
  +     * @param event target finished event
  +     */
  +    public void targetFinished(org.apache.ant.common.event.BuildEvent event) {
  +        Target currentTarget = (Target)targetStack.pop();
  +        fireTargetFinished(currentTarget, event.getCause());
  +        currentTarget = null;
  +    }
  +
  +    /**
  +     * task started event
  +     *
  +     * @param event task started event
  +     */
  +    public void taskStarted(org.apache.ant.common.event.BuildEvent event) {
  +    }
  +
  +    /**
  +     * task finished event
  +     *
  +     * @param event task finished event
  +     */
  +    public void taskFinished(org.apache.ant.common.event.BuildEvent event) {
  +    }
  +
  +    /**
  +     * message logged event
  +     *
  +     * @param event message logged event
  +     */
  +    public void messageLogged(org.apache.ant.common.event.BuildEvent event) {
  +    }
  +
  +    /**
  +     * add a build listener to this project
  +     *
  +     * @param listener the listener to be added to the project
  +     */
  +    public void addBuildListener(BuildListener listener) {
  +        listeners.addElement(listener);
  +    }
  +
  +    /**
  +     * remove a build listener from this project
  +     *
  +     * @param listener the listener to be removed
  +     */
  +    public void removeBuildListener(BuildListener listener) {
  +        listeners.removeElement(listener);
  +    }
  +
  +    /**
        * Add a reference to an object. NOte that in Ant2 objects and
        * properties occupy the same namespace.
        *
  @@ -577,6 +683,8 @@
           this.context = context;
           fileService = (FileService)context.getCoreService(FileService.class);
           dataService = (DataService)context.getCoreService(DataService.class);
  +        componentService
  +             = (ComponentService)context.getCoreService(ComponentService.class);
   
           String defs = "/org/apache/tools/ant/taskdefs/defaults.properties";
   
  @@ -701,12 +809,35 @@
       }
   
       /**
  -     * add a build listener to this project
  +     * define a new task
        *
  -     * @param listener the listener to be added to the project
  +     * @param taskName the anme of the task in build files
  +     * @param taskClass the class that implements the task
  +     * @exception BuildException if the task cannot be defined
        */
  -    public void addBuildListener(BuildListener listener) {
  -        // XXX do nothing for now
  +    public void addTaskDefinition(String taskName, Class taskClass)
  +         throws BuildException {
  +        try {
  +            componentService.taskdef(taskName, taskClass);
  +            taskClassDefinitions.put(taskName, taskClass);
  +        } catch (ExecutionException e) {
  +            throw new BuildException(e);
  +        }
  +    }
  +
  +    /**
  +     * Add a new type definition
  +     *
  +     * @param typeName the name of the type
  +     * @param typeClass the class which implements the type
  +     */
  +    public void addDataTypeDefinition(String typeName, Class typeClass) {
  +        try {
  +            componentService.typedef(typeName, typeClass);
  +            dataClassDefinitions.put(typeName, typeClass);
  +        } catch (ExecutionException e) {
  +            throw new BuildException(e);
  +        }
       }
   
       /**
  @@ -732,6 +863,146 @@
               return task;
           } catch (Throwable e) {
               throw new BuildException(e);
  +        }
  +    }
  +
  +    /** send build started event to the listeners */
  +    protected void fireBuildStarted() {
  +        BuildEvent event = new BuildEvent(this);
  +        for (int i = 0; i < listeners.size(); i++) {
  +            BuildListener listener = (BuildListener)listeners.elementAt(i);
  +            listener.buildStarted(event);
  +        }
  +    }
  +
  +    /**
  +     * send build finished event to the listeners
  +     *
  +     * @param exception exception which indicates failure if not null
  +     */
  +    protected void fireBuildFinished(Throwable exception) {
  +        BuildEvent event = new BuildEvent(this);
  +        event.setException(exception);
  +        for (int i = 0; i < listeners.size(); i++) {
  +            BuildListener listener = (BuildListener)listeners.elementAt(i);
  +            listener.buildFinished(event);
  +        }
  +    }
  +
  +
  +    /**
  +     * send target started event to the listeners
  +     *
  +     * @param target the target which has started
  +     */
  +    protected void fireTargetStarted(Target target) {
  +        BuildEvent event = new BuildEvent(target);
  +        for (int i = 0; i < listeners.size(); i++) {
  +            BuildListener listener = (BuildListener)listeners.elementAt(i);
  +            listener.targetStarted(event);
  +        }
  +    }
  +
  +    /**
  +     * send build finished event to the listeners
  +     *
  +     * @param exception exception which indicates failure if not null
  +     * @param target the target which is just finished
  +     */
  +    protected void fireTargetFinished(Target target, Throwable exception) {
  +        BuildEvent event = new BuildEvent(target);
  +        event.setException(exception);
  +        for (int i = 0; i < listeners.size(); i++) {
  +            BuildListener listener = (BuildListener)listeners.elementAt(i);
  +            listener.targetFinished(event);
  +        }
  +    }
  +
  +    /**
  +     * fire a task started event
  +     *
  +     * @param task the task which has started
  +     */
  +    protected void fireTaskStarted(Task task) {
  +        // register this as the current task on the current thread.
  +        // threadTasks.put(Thread.currentThread(), task);
  +        BuildEvent event = new BuildEvent(task);
  +        for (int i = 0; i < listeners.size(); i++) {
  +            BuildListener listener = (BuildListener)listeners.elementAt(i);
  +            listener.taskStarted(event);
  +        }
  +    }
  +
  +    /**
  +     * Fire a task finished event
  +     *
  +     * @param task the task which has finsihed
  +     * @param exception the exception associated with the task
  +     */
  +    protected void fireTaskFinished(Task task, Throwable exception) {
  +        // threadTasks.remove(Thread.currentThread());
  +        //System.out.flush();
  +        // System.err.flush();
  +        BuildEvent event = new BuildEvent(task);
  +        event.setException(exception);
  +        for (int i = 0; i < listeners.size(); i++) {
  +            BuildListener listener = (BuildListener)listeners.elementAt(i);
  +            listener.taskFinished(event);
  +        }
  +    }
  +
  +    /**
  +     * Fire a message event from the project
  +     *
  +     * @param project the project sending the event
  +     * @param message the message
  +     * @param priority the messsage priority
  +     */
  +    protected void fireMessageLogged(Project project, String message,
  +                                     int priority) {
  +        BuildEvent event = new BuildEvent(project);
  +        fireMessageLoggedEvent(event, message, priority);
  +    }
  +
  +    /**
  +     * Fire a message event from the project
  +     *
  +     * @param message the message
  +     * @param priority the messsage priority
  +     * @param target the target sending the message
  +     */
  +    protected void fireMessageLogged(Target target, String message,
  +                                     int priority) {
  +        BuildEvent event = new BuildEvent(target);
  +        fireMessageLoggedEvent(event, message, priority);
  +    }
  +
  +    /**
  +     * Fire a message event from the project
  +     *
  +     * @param message the message
  +     * @param priority the messsage priority
  +     * @param task the task sending the message
  +     */
  +    protected void fireMessageLogged(Task task, String message,
  +                                     int priority) {
  +        BuildEvent event = new BuildEvent(task);
  +        fireMessageLoggedEvent(event, message, priority);
  +    }
  +
  +    /**
  +     * Fire a message event from the project
  +     *
  +     * @param message the message
  +     * @param priority the messsage priority
  +     * @param event the message event
  +     */
  +    private void fireMessageLoggedEvent(BuildEvent event, String message,
  +                                        int priority) {
  +        event.setMessage(message, priority);
  +        for (int i = 0; i < listeners.size(); i++) {
  +            BuildListener listener = (BuildListener)listeners.elementAt(i);
  +            listener.messageLogged(event);
           }
       }
   }
  
  
  
  1.2       +42 -0     jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Target.java
  
  Index: Target.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Target.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -u -r1.1 -r1.2
  --- Target.java	2 Feb 2002 14:50:32 -0000	1.1
  +++ Target.java	7 Feb 2002 14:42:37 -0000	1.2
  @@ -60,5 +60,47 @@
    * @created 31 January 2002
    */
   public class Target {
  +    /** The project to which this target belongs */
  +    private Project project;
  +
  +    /** The name of this target */
  +    private String name;
  +
  +    /**
  +     * Construct a Target that is part of the project
  +     *
  +     * @param project the target's project
  +     */
  +    public Target(Project project) {
  +        this.project = project;
  +    }
  +
  +    /**
  +     * set the name of the target
  +     *
  +     * @param name the new name value
  +     */
  +    public void setName(String name) {
  +        this.name = name;
  +    }
  +
  +    /**
  +     * get the project to which this target belongs
  +     *
  +     * @return the target's project.
  +     */
  +    public Project getProject() {
  +        return project;
  +    }
  +
  +    /**
  +     * Gets the name of the Target
  +     *
  +     * @return the target's name
  +     */
  +    public String getName() {
  +        return name;
  +    }
  +
   }
   
  
  
  
  1.3       +0 -2      jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml
  
  Index: antlib.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -u -r1.2 -r1.3
  --- antlib.xml	5 Feb 2002 11:49:06 -0000	1.2
  +++ antlib.xml	7 Feb 2002 14:42:37 -0000	1.3
  @@ -3,8 +3,6 @@
   
     <taskdef name="import" classname="org.apache.ant.antlib.system.Import"/>
     <taskdef name="libpath" classname="org.apache.ant.antlib.system.LibPath"/>
  -  <taskdef name="taskdef" classname="org.apache.ant.antlib.system.TaskDef"/>
  -  <taskdef name="typedef" classname="org.apache.ant.antlib.system.TypeDef"/>
     <taskdef name="loadlib" classname="org.apache.ant.antlib.system.LoadLib"/>
   
     <taskdef name="ant" classname="org.apache.ant.antlib.system.Ant"/>
  
  
  
  1.3       +21 -0     jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java
  
  Index: ComponentService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -u -r1.2 -r1.3
  --- ComponentService.java	5 Feb 2002 11:49:06 -0000	1.2
  +++ ComponentService.java	7 Feb 2002 14:42:37 -0000	1.3
  @@ -116,5 +116,26 @@
        */
       void callTarget(Map properties, List targets)
            throws ExecutionException;
  +
  +    /**
  +     * Experimental - define a new type
  +     *
  +     * @param typeName the name by which this type will be referred
  +     * @param typeClass the class of the type
  +     * @exception ExecutionException if the type cannot be defined
  +     */
  +    void typedef(String typeName, Class typeClass)
  +         throws ExecutionException;
  +         
  +    /**
  +     * Experimental - define a new task
  +     *
  +     * @param taskName the name by which this task will be referred
  +     * @param taskClass the class of the task
  +     * @exception ExecutionException if the task cannot be defined
  +     */
  +    void taskdef(String taskName, Class taskClass)
  +         throws ExecutionException;
  +
   }
   
  
  
  
  1.1                  jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/EventService.java
  
  Index: EventService.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.ant.common.service;
  import org.apache.ant.common.event.BuildListener;
  import org.apache.ant.common.util.ExecutionException;
  
  /**
   * Core service to manage receiving of events by components within Ant.
   *
   * @author <a href="mailto:conor@apache.org">Conor MacNeill</a>
   * @created 7 February 2002
   */
  public interface EventService {
      /**
       * Add a build listener to the current frame
       *
       * @param listener the lister which will receive build events
       * @exception ExecutionException if the listener cannot be added
       */
      void addBuildListener(BuildListener listener) throws ExecutionException;
  
      /**
       * Remove a listener from the current frame
       *
       * @param listener the listener to be removed
       * @exception ExecutionException if the listener could not be removed
       */
      void removeBuildListener(BuildListener listener) throws ExecutionException;
  }
  
  
  
  

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