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 ComponentService.java
Date Tue, 14 May 2002 15:11:10 GMT
conor       02/05/14 08:11:10

  Modified:    proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib
                        AntLibHandler.java AntLibManager.java
                        AntLibrary.java AntLibrarySpec.java
               proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
                        ComponentManager.java CoreExecService.java
                        ExecutionManager.java Frame.java ImportInfo.java
               proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant
                        Ant1Factory.java Project.java
               proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs
                        Ant.java CallTarget.java
               proposal/mutant/src/java/antlibs/system antlib.xml
               proposal/mutant/src/java/common/org/apache/ant/common/antlib
                        AntLibFactory.java ExecutionComponent.java
                        StandardLibFactory.java
               proposal/mutant/src/java/common/org/apache/ant/common/service
                        ComponentService.java
  Added:       proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system
                        AntAspect.java
               proposal/mutant/src/java/common/org/apache/ant/common/antlib
                        AbstractAspect.java Aspect.java
  Log:
  Add support for Aspects
  
  Revision  Changes    Path
  1.8       +7 -2      jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibHandler.java
  
  Index: AntLibHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- AntLibHandler.java	18 Mar 2002 02:44:24 -0000	1.7
  +++ AntLibHandler.java	14 May 2002 15:11:09 -0000	1.8
  @@ -144,12 +144,17 @@
                   antLibrarySpec.addDefinition(defnHandler.getDefinitionType(),
                       defnHandler.getName(), defnHandler.getClassName());
               } else if (qualifiedName.equals("converter")) {
  -                ClassNameHandler converterHandler
  -                    = new ClassNameHandler();
  +                ClassNameHandler converterHandler = new ClassNameHandler();
                   converterHandler.start(getParseContext(), getXMLReader(),
                       this, getLocator(), attributes, getElementSource(),
                       qualifiedName);
                   antLibrarySpec.addConverter(converterHandler.getClassName());
  +            } else if (qualifiedName.equals("aspect")) {
  +                ClassNameHandler aspectHandler = new ClassNameHandler();
  +                aspectHandler.start(getParseContext(), getXMLReader(),
  +                    this, getLocator(), attributes, getElementSource(),
  +                    qualifiedName);
  +                antLibrarySpec.addAspect(aspectHandler.getClassName());
               } else if (qualifiedName.equals("factory")) {
                   ClassNameHandler factoryHandler
                       = new ClassNameHandler();
  
  
  
  1.11      +17 -6     jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java
  
  Index: AntLibManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -u -r1.10 -r1.11
  --- AntLibManager.java	1 May 2002 07:19:30 -0000	1.10
  +++ AntLibManager.java	14 May 2002 15:11:09 -0000	1.11
  @@ -60,6 +60,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.HashMap;
   import org.apache.ant.antcore.xml.ParseContext;
   import org.apache.ant.antcore.xml.XMLParseException;
   import org.apache.ant.common.util.CircularDependencyChecker;
  @@ -153,10 +154,11 @@
        * @param initConfig the Ant initialization configuration
        * @param libraries the collection of libraries already configured
        * @param libPathsMap a map of lists of library paths for each library
  +     * @return A map of the newly configured libraries
        * @exception ExecutionException if a library cannot be configured from
        *      the given specification
        */
  -    public void configLibraries(InitConfig initConfig, Map librarySpecs,
  +    public Map configLibraries(InitConfig initConfig, Map librarySpecs,
                                   Map libraries, Map libPathsMap)
            throws ExecutionException {
   
  @@ -180,15 +182,18 @@
               }
           }
   
  +        Map newLibraries = new HashMap();
           CircularDependencyChecker configuring
                = new CircularDependencyChecker("configuring Ant libraries");
           for (Iterator i = librarySpecs.keySet().iterator(); i.hasNext();) {
               String libraryId = (String) i.next();
               if (!libraries.containsKey(libraryId)) {
                   configLibrary(initConfig, librarySpecs, libraryId,
  -                    configuring, libraries, libPathsMap);
  +                    configuring, libraries, newLibraries, libPathsMap);
               }
           }
  +        
  +        return newLibraries;
       }
   
       /**
  @@ -267,13 +272,14 @@
        *      dependencies.
        * @param libraries the collection of libraries which have already been
        *      configured
  +     * @param newLibraries the new libraries being configured. 
        * @param libPathsMap a map of lists of library patsh fro each library
        * @exception ExecutionException if the library cannot be configured.
        */
       private void configLibrary(InitConfig initConfig, Map librarySpecs,
                                  String libraryId,
                                  CircularDependencyChecker configuring,
  -                               Map libraries, Map libPathsMap)
  +                               Map libraries, Map newLibraries, Map libPathsMap)
            throws ExecutionException {
   
           try {
  @@ -283,14 +289,15 @@
                    = (AntLibrarySpec) librarySpecs.get(libraryId);
               String extendsId = librarySpec.getExtendsLibraryId();
               if (extendsId != null) {
  -                if (!libraries.containsKey(extendsId)) {
  +                if (!libraries.containsKey(extendsId) &&
  +                    !newLibraries.containsKey(extendsId)) {
                       if (!librarySpecs.containsKey(extendsId)) {
                           throw new ExecutionException("Could not find library, "
                                + extendsId + ", upon which library "
                                + libraryId + " depends");
                       }
                       configLibrary(initConfig, librarySpecs, extendsId,
  -                        configuring, libraries, libPathsMap);
  +                        configuring, libraries, newLibraries, libPathsMap);
                   }
               }
   
  @@ -323,10 +330,14 @@
               if (extendsId != null) {
                   AntLibrary extendsLibrary
                        = (AntLibrary) libraries.get(extendsId);
  +                if (extendsLibrary == null) {
  +                    extendsLibrary = (AntLibrary) newLibraries.get(extendsId);
  +                }
  +                
                   antLibrary.setExtendsLibrary(extendsLibrary);
               }
               antLibrary.setParentLoader(initConfig.getCommonLoader());
  -            libraries.put(libraryId, antLibrary);
  +            newLibraries.put(libraryId, antLibrary);
   
               if (libPathsMap != null) {
                   List libPaths = (List) libPathsMap.get(libraryId);
  
  
  
  1.9       +23 -1     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.8
  retrieving revision 1.9
  diff -u -w -u -r1.8 -r1.9
  --- AntLibrary.java	7 Apr 2002 14:38:05 -0000	1.8
  +++ AntLibrary.java	14 May 2002 15:11:09 -0000	1.9
  @@ -88,6 +88,9 @@
       /** The list of converter classnames defined in this library */
       private List converterClassNames = new ArrayList();
   
  +    /** The list of aspect classnames defined in this library */
  +    private List aspectClassNames = new ArrayList();
  +
       /** The class name of this library's factory class, if any */
       private String factoryClassName;
   
  @@ -116,6 +119,7 @@
           this.definitions = spec.getDefinitions();
           this.isolated = spec.isIsolated();
           this.converterClassNames.addAll(spec.getConverters());
  +        this.aspectClassNames.addAll(spec.getAspects());
           this.factoryClassName = spec.getFactory();
           this.definitionURL = spec.getLibraryURL();
       }
  @@ -182,7 +186,7 @@
       }
   
       /**
  -     * Gets an the converter class names of the AntLibrary
  +     * Gets the converter class names of the AntLibrary
        *
        * @return an iterator over a list of String class names
        */
  @@ -191,6 +195,15 @@
       }
   
       /**
  +     * Gets the aspect class names of the AntLibrary
  +     *
  +     * @return an iterator over a list of String class names
  +     */
  +    public Iterator getAspectClassNames() {
  +        return aspectClassNames.iterator();
  +    }
  +
  +    /**
        * Get the URL to where the library was loaded from
        *
        * @return the library's URL
  @@ -249,6 +262,15 @@
        */
       public boolean hasConverters() {
           return !converterClassNames.isEmpty();
  +    }
  +
  +    /**
  +     * Indicate whether this library has any aspects defined
  +     *
  +     * @return true if any aspects have been defined
  +     */
  +    public boolean hasAspects() {
  +        return !aspectClassNames.isEmpty();
       }
   
       /**
  
  
  
  1.7       +23 -1     jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrarySpec.java
  
  Index: AntLibrarySpec.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrarySpec.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -u -r1.6 -r1.7
  --- AntLibrarySpec.java	18 Mar 2002 02:44:24 -0000	1.6
  +++ AntLibrarySpec.java	14 May 2002 15:11:09 -0000	1.7
  @@ -85,6 +85,9 @@
       /** The list of converter classnames defined in this library */
       private List converterClassNames = new ArrayList();
   
  +    /** The list of aspect classnames defined in this library */
  +    private List aspectClassNames = new ArrayList();
  +
       /** The name of the factory class for this library */
       private String factoryClassName;
   
  @@ -196,6 +199,16 @@
           return converterClassNames;
       }
   
  +
  +    /**
  +     * Get the list of aspect classnames defined in this library spec
  +     *
  +     * @return the aspect classnames list
  +     */
  +    public List getAspects() {
  +        return aspectClassNames;
  +    }
  +
       /**
        * Gets the factory classname of the AntLibrarySpec
        *
  @@ -262,7 +275,7 @@
       }
   
       /**
  -     * Add a converter to this library sec
  +     * Add a converter to this library spec
        *
        * @param className the name of the converter class
        */
  @@ -270,6 +283,15 @@
           converterClassNames.add(className);
       }
   
  +    /**
  +     * Add an aspect to this the library spec
  +     *
  +     * @param className the name of the aspect class
  +     */
  +    public void addAspect(String className) {
  +        aspectClassNames.add(className);
  +    }
  +    
       /**
        * Indicates if this library requires Ant's XML parser
        *
  
  
  
  1.16      +244 -79   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.15
  retrieving revision 1.16
  diff -u -w -u -r1.15 -r1.16
  --- ComponentManager.java	1 May 2002 07:19:30 -0000	1.15
  +++ ComponentManager.java	14 May 2002 15:11:09 -0000	1.16
  @@ -66,7 +66,9 @@
   import org.apache.ant.antcore.antlib.AntLibrary;
   import org.apache.ant.antcore.antlib.ComponentLibrary;
   import org.apache.ant.antcore.antlib.DynamicLibrary;
  +import org.apache.ant.antcore.config.AntConfig;
   import org.apache.ant.common.antlib.AntLibFactory;
  +import org.apache.ant.common.antlib.Aspect;
   import org.apache.ant.common.antlib.Converter;
   import org.apache.ant.common.antlib.DeferredTask;
   import org.apache.ant.common.antlib.ExecutionComponent;
  @@ -79,16 +81,21 @@
   import org.apache.ant.common.util.ExecutionException;
   import org.apache.ant.common.util.Location;
   import org.apache.ant.init.LoaderUtils;
  -import org.apache.ant.antcore.config.AntConfig;
   
   /**
  - * The instance of the ComponentServices made available by the core to the
  - * ant libraries.
  + * The instance of the ComponentServices made available by the core to the ant
  + * libraries.
    *
    * @author Conor MacNeill
    * @created 27 January 2002
    */
   public class ComponentManager implements ComponentService {
  +
  +    /**
  +     * These are AntLibraries which have been loaded into this component
  +     * manager
  +     */
  +    private static Map antLibraries = new HashMap();
       /**
        * Type converters for this frame. Converters are used when configuring
        * Tasks to handle special type conversions.
  @@ -98,6 +105,9 @@
       /** This is the set of libraries whose converters have been loaded */
       private Set loadedConverters = new HashSet();
   
  +    /** This is the set of libraries whose aspects have been loaded */
  +    private Set loadedAspects = new HashSet();
  +
       /** The factory objects for each library, indexed by the library Id */
       private Map libFactories = new HashMap();
   
  @@ -108,20 +118,20 @@
       private AntLibManager libManager;
   
       /**
  -     * These are AntLibraries which have been loaded into this component
  -     * manager
  +     * This is the list of aspects which have been loaded from the various Ant
  +     * libraries
        */
  -    private static Map antLibraries = new HashMap();
  +    private List aspects = new ArrayList();
   
       /** dynamic libraries which have been defined */
       private Map dynamicLibraries;
   
       /** The definitions which have been imported into this frame. */
  -    private Map definitions = new HashMap();
  +    private Map imports = new HashMap();
   
       /**
  -     * This map stores a list of additional paths for each library indexed
  -     * by the libraryId
  +     * This map stores a list of additional paths for each library indexed by
  +     * the libraryId
        */
       private Map libPathsMap = new HashMap();
   
  @@ -133,8 +143,11 @@
        * Constructor
        *
        * @param frame the frame containing this context
  +     *
  +     * @exception ExecutionException if the loaded libraries could not be 
  +     * imported.
        */
  -    protected ComponentManager(Frame frame) {
  +    protected ComponentManager(Frame frame) throws ExecutionException {
           this.frame = frame;
           AntConfig config = frame.getConfig();
           libManager = new AntLibManager(config.isRemoteLibAllowed());
  @@ -159,10 +172,11 @@
           try {
               Map librarySpecs = new HashMap();
               libManager.loadLibs(librarySpecs, libLocation);
  -            libManager.configLibraries(frame.getInitConfig(), librarySpecs,
  -                antLibraries, libPathsMap);
  +            Map newLibraries = libManager.configLibraries(frame.getInitConfig(),
  +                librarySpecs, antLibraries, libPathsMap);
   
  -            Iterator i = librarySpecs.keySet().iterator();
  +            antLibraries.putAll(newLibraries);
  +            Iterator i = antLibraries.keySet().iterator();
               while (i.hasNext()) {
                   String libraryId = (String) i.next();
                   boolean doAuto = autoImport 
  @@ -170,6 +184,7 @@
                   if (importAll || doAuto) {
                       importLibrary(libraryId);
                   }
  +                addAspects((AntLibrary) antLibraries.get(libraryId));
               }
           } catch (MalformedURLException e) {
               throw new ExecutionException("Unable to load libraries from "
  @@ -181,8 +196,7 @@
        * Experimental - define a new task
        *
        * @param taskName the name by which this task will be referred
  -     * @param factory the library factory object to create the task
  -     *      instances
  +     * @param factory the library factory object to create the task instances
        * @param loader the class loader to use to create the particular tasks
        * @param className the name of the class implementing the task
        * @exception ExecutionException if the task cannot be defined
  @@ -198,8 +212,7 @@
        * Experimental - define a new type
        *
        * @param typeName the name by which this type will be referred
  -     * @param factory the library factory object to create the type
  -     *      instances
  +     * @param factory the library factory object to create the type instances
        * @param loader the class loader to use to create the particular types
        * @param className the name of the class implementing the type
        * @exception ExecutionException if the type cannot be defined
  @@ -251,15 +264,15 @@
               String defName = (String) i.next();
               importLibraryDef(library, defName, null);
           }
  -        addLibraryConverters(library);
  +        addConverters(library);
       }
   
       /**
        * Import a single component from a library, optionally aliasing it to a
        * new name
        *
  -     * @param libraryId the unique id of the library from which the
  -     *      component is being imported
  +     * @param libraryId the unique id of the library from which the component
  +     *      is being imported
        * @param defName the name of the component within its library
        * @param alias the name under which this component will be used in the
        *      build scripts. If this is null, the components default name is
  @@ -274,7 +287,7 @@
                    + "library \"" + libraryId + "\" as it has not been loaded");
           }
           importLibraryDef(library, defName, alias);
  -        addLibraryConverters(library);
  +        addConverters(library);
       }
   
       /**
  @@ -306,7 +319,7 @@
                + "> as <" + label + "> from library \""
                + definition.getComponentLibrary().getLibraryId() + "\", class: "
                + definition.getClassName(), MessageLevel.MSG_DEBUG);
  -        definitions.put(label, definition);
  +        imports.put(label, definition);
       }
   
       /**
  @@ -321,30 +334,36 @@
        */
       public Object createComponent(String componentName)
            throws ExecutionException {
  -        return createComponent(componentName, null);
  +        return createComponent(componentName, (BuildElement) null);
       }
   
       /**
  -     * Create a component given its class. The component will have a context
  -     * but will not be configured. It should be configured using the
  -     * appropriate set methods and then validated before being used.
  +     * Create a component given its libraryId and local name within the
  +     * library. This method is unambiguous in the face of imports, aliases and
  +     * taskdefs performed in the build.
        *
  -     * @param componentClass the component's class
  -     * @param factory the factory to create the component
  -     * @param loader the classloader associated with the component
  -     * @param addTaskAdapter whenther the returned component should be a
  -     *      task, potentially being wrapped in an adapter
  -     * @param componentName the name of the component type
  +     * @param libraryId the component's library identifier.
  +     * @param localName the name component within the library.
        * @return the created component. The return type of this method depends
        *      on the component type.
        * @exception ExecutionException if the component cannot be created
        */
  -    public Object createComponent(AntLibFactory factory, ClassLoader loader,
  -                                  Class componentClass, boolean addTaskAdapter,
  -                                  String componentName)
  +    public Object createComponent(String libraryId, String localName)
            throws ExecutionException {
  -        return createComponent(loader, factory, componentClass,
  -            componentName, componentName, addTaskAdapter, null);
  +        AntLibrary library
  +             = (AntLibrary) antLibraries.get(libraryId);
  +        if (library == null) {
  +            throw new ExecutionException("No library with libraryId \""
  +                 + libraryId + "\" is available");
  +        }
  +
  +        AntLibDefinition libDefinition = library.getDefinition(localName);
  +        if (libDefinition == null) {
  +            throw new ExecutionException("No component with name \""
  +                 + localName + "\" was found in library with libraryId \""
  +                 + libraryId + "\"");
  +        }
  +        return createComponentFromDef(localName, library, libDefinition, null);
       }
   
       /**
  @@ -361,8 +380,8 @@
        * Get the collection of Ant Libraries defined for this frame Gets the
        * factory object for the given library
        *
  -     * @param componentLibrary the compnent library for which a factory
  -     *      objetc is required
  +     * @param componentLibrary the compnent library for which a factory objetc
  +     *      is required
        * @return the library's factory object
        * @exception ExecutionException if the factory cannot be created
        */
  @@ -386,11 +405,11 @@
        * Get an imported definition from the component manager
        *
        * @param name the name under which the component has been imported
  -     * @return the ImportInfo object detailing the import's library and
  -     *      other details
  +     * @return the ImportInfo object detailing the import's library and other
  +     *      details
        */
  -    protected ImportInfo getDefinition(String name) {
  -        return (ImportInfo) definitions.get(name);
  +    protected ImportInfo getImport(String name) {
  +        return (ImportInfo) imports.get(name);
       }
   
       /**
  @@ -409,10 +428,11 @@
       }
   
       /**
  -     * Create a component.
  +     * Create a component. This method creates a component and then configures
  +     * it from the given build model.
        *
  -     * @param componentName the name of the component which is used to
  -     *      select the object type to be created
  +     * @param componentName the name of the component which is used to select
  +     *      the object type to be created
        * @param model the build model of the component. If this is null, the
        *      component is created but not configured.
        * @return the configured component
  @@ -422,38 +442,119 @@
       protected Object createComponent(String componentName, BuildElement model)
            throws ExecutionException {
   
  -        Location location = Location.UNKNOWN_LOCATION;
  -        if (model != null) {
  -            location = model.getLocation();
  -        }
  -        ImportInfo definition = getDefinition(componentName);
  -        if (definition == null) {
  +        ImportInfo importInfo = getImport(componentName);
  +        if (importInfo == null) {
               throw new ExecutionException("There is no definition of the <"
                    + componentName + "> component");
           }
  -        String className = definition.getClassName();
  +        String className = importInfo.getClassName();
   
           ComponentLibrary componentLibrary
  -             = definition.getComponentLibrary();
  -        boolean isTask = definition.getDefinitionType() == AntLibrary.TASKDEF;
  -        String localName = definition.getLocalName();
  +             = importInfo.getComponentLibrary();
  +
  +        return createComponentFromDef(componentName, componentLibrary,
  +            importInfo.getDefinition(), model);
  +    }
  +
  +    /**
  +     * Create a component from its library definition.
  +     *
  +     * @param componentName The component's name in the global context
  +     * @param componentLibrary the library which provides the deifnition of
  +     *      the component
  +     * @param libDefinition the component's definition
  +     * @param model the BuildElement model of the component's configuration.
  +     * @return the required component potentially wrapped in a wrapper object.
  +     * @exception ExecutionException if the component cannot be created
  +     */
  +    private Object createComponentFromDef(String componentName,
  +                                          ComponentLibrary componentLibrary,
  +                                          AntLibDefinition libDefinition,
  +                                          BuildElement model)
  +         throws ExecutionException {
  +
  +        Location location = Location.UNKNOWN_LOCATION;
  +        if (model != null) {
  +            location = model.getLocation();
  +        }
  +
  +        boolean isTask
  +             = libDefinition.getDefinitionType() == AntLibrary.TASKDEF;
  +        String localName = libDefinition.getDefinitionName();
  +        String className = libDefinition.getClassName();
           try {
               ClassLoader componentLoader = componentLibrary.getClassLoader();
               Class componentClass
                    = Class.forName(className, true, componentLoader);
               AntLibFactory libFactory = getLibFactory(componentLibrary);
  -            return createComponent(componentLoader, libFactory, componentClass,
  -                componentName, localName, isTask, model);
  +            // create the component using the factory
  +            Object component
  +                 = libFactory.createComponent(componentClass, localName);
  +
  +            // wrap the component in an adapter if required.
  +            ExecutionComponent execComponent = null;
  +            if (isTask) {
  +                if (component instanceof Task) {
  +                    execComponent = (Task) component;
  +                } else {
  +                    execComponent = new TaskAdapter(componentName, component);
  +                }
  +            } else if (component instanceof ExecutionComponent) {
  +                execComponent = (ExecutionComponent) component;
  +            }
  +
  +            // set the context loader to that for the component
  +            ClassLoader currentLoader
  +                 = LoaderUtils.setContextLoader(componentLoader);
  +
  +            // if the component is an execution component create a context and
  +            // initialise the component with it.
  +            if (execComponent != null) {
  +                ExecutionContext context
  +                     = new ExecutionContext(frame, execComponent, location);
  +                context.setClassLoader(componentLoader);
  +                execComponent.init(context, componentName);
  +            }
  +
  +            // if we have a model, use it to configure the component. Otherwise
  +            // the caller is expected to configure thre object
  +            if (model != null) {
  +                configureElement(libFactory, component, model);
  +                // if the component is an execution component and we have a
  +                // model, validate it
  +                if (execComponent != null) {
  +                    execComponent.validateComponent();
  +                }
  +            }
  +
  +            // reset the loader
  +            LoaderUtils.setContextLoader(currentLoader);
  +
  +            // if we have an execution component, potentially a wrapper,
  +            // return it otherwise the component directly
  +            if (execComponent != null) {
  +                return execComponent;
  +            } else {
  +                return component;
  +            }
           } catch (ClassNotFoundException e) {
               throw new ExecutionException("Class " + className
                    + " for component <" + componentName + "> was not found", e,
                   location);
           } catch (NoClassDefFoundError e) {
               throw new ExecutionException("Could not load a dependent class ("
  -                 + e.getMessage() + ") for component " + componentName,
  -                e, location);
  +                 + e.getMessage() + ") for component " + componentName, e,
  +                location);
  +        } catch (InstantiationException e) {
  +            throw new ExecutionException("Unable to instantiate component "
  +                 + "class " + className + " for component <"
  +                 + componentName + ">", e, location);
  +        } catch (IllegalAccessException e) {
  +            throw new ExecutionException("Unable to access task class "
  +                 + className + " for component <"
  +                 + componentName + ">", e, location);
           } catch (ExecutionException e) {
  -            e.setLocation(model.getLocation(), false);
  +            e.setLocation(location, false);
               throw e;
           }
       }
  @@ -477,7 +578,7 @@
           frame.log("Adding component <" + defName + "> as <" + label
                + "> from library \"" + library.getLibraryId() + "\", class: "
                + libDef.getClassName(), MessageLevel.MSG_DEBUG);
  -        definitions.put(label, new ImportInfo(library, libDef));
  +        imports.put(label, new ImportInfo(library, libDef));
       }
   
       /**
  @@ -514,8 +615,7 @@
        * @param localName The name of the component within its library
        * @param model the BuildElement model of the component's configuration
        * @param factory the facrtory object used to create the component
  -     * @return the required component potentially wrapped in a wrapper
  -     *      object.
  +     * @return the required component potentially wrapped in a wrapper object.
        * @exception ExecutionException if the component cannot be created
        */
       private Object createComponent(ClassLoader loader, AntLibFactory factory,
  @@ -650,8 +750,8 @@
        * @param element the container element in which the nested element will
        *      be created
        * @param model the model of the nested element
  -     * @param factory Ant Library factory associated with the element to
  -     *      which the attribute is to be added.
  +     * @param factory Ant Library factory associated with the element to which
  +     *      the attribute is to be added.
        * @exception ExecutionException if the nested element cannot be created
        */
       private void addNestedElement(AntLibFactory factory, Setter setter,
  @@ -734,10 +834,9 @@
        * @param element the container object for which a nested element is
        *      required.
        * @param model the build model for the nestd element
  -     * @param factory Ant Library factory associated with the element
  -     *      creating the nested element
  -     * @exception ExecutionException if the nested element cannot be
  -     *      created.
  +     * @param factory Ant Library factory associated with the element creating
  +     *      the nested element
  +     * @exception ExecutionException if the nested element cannot be created.
        */
       private void createNestedElement(AntLibFactory factory, Setter setter,
                                        Object element, BuildElement model)
  @@ -807,7 +906,7 @@
           for (Iterator i = model.getNestedElements(); i.hasNext();) {
               BuildElement nestedElementModel = (BuildElement) i.next();
               String nestedElementName = nestedElementModel.getType();
  -            ImportInfo info = getDefinition(nestedElementName);
  +            ImportInfo info = getImport(nestedElementName);
               if (element instanceof TaskContainer
                    && info != null
                    && info.getDefinitionType() == AntLibrary.TASKDEF
  @@ -859,6 +958,63 @@
   
   
       /**
  +     * Load any apsects from the given library.
  +     *
  +     * @param library the library from which the aspects are to be loaded.
  +     *
  +     * @exception ExecutionException if an aspect cannot be loaded.
  +     */
  +    private void addAspects(AntLibrary library) throws ExecutionException {
  +        if (!library.hasAspects()
  +            || loadedAspects.contains(library.getLibraryId())) {
  +            return;
  +        }
  +
  +        String className = null;
  +        try {
  +            AntLibFactory libFactory = getLibFactory(library);
  +            ClassLoader aspectLoader = library.getClassLoader();
  +            for (Iterator i = library.getAspectClassNames(); i.hasNext();) {
  +                className = (String) i.next();
  +                Class aspectClass
  +                     = Class.forName(className, true, aspectLoader);
  +                if (!Aspect.class.isAssignableFrom(aspectClass)) {
  +                    throw new ExecutionException("In Ant library \""
  +                         + library.getLibraryId() + "\" the aspect class "
  +                         + aspectClass.getName()
  +                         + " does not implement the Aspect interface");
  +                }
  +                Aspect aspect = (Aspect) libFactory.createInstance(aspectClass);
  +                ExecutionContext context = new ExecutionContext(frame,
  +                    null, Location.UNKNOWN_LOCATION);
  +                aspect.init(context);
  +                aspects.add(aspect);
  +            }
  +            loadedAspects.add(library.getLibraryId());
  +        } catch (ClassNotFoundException e) {
  +            throw new ExecutionException("In Ant library \""
  +                 + library.getLibraryId() + "\" aspect class "
  +                 + className + " was not found", e);
  +        } catch (NoClassDefFoundError e) {
  +            throw new ExecutionException("In Ant library \""
  +                 + library.getLibraryId()
  +                 + "\" could not load a dependent class ("
  +                 + e.getMessage() + ") for aspect " + className);
  +        } catch (InstantiationException e) {
  +            throw new ExecutionException("In Ant library \""
  +                 + library.getLibraryId()
  +                 + "\" unable to instantiate aspect class "
  +                 + className, e);
  +        } catch (IllegalAccessException e) {
  +            throw new ExecutionException("In Ant library \""
  +                 + library.getLibraryId()
  +                 + "\" unable to access aspect class "
  +                 + className, e);
  +        }
  +    }
  +
  +
  +    /**
        * Add the converters from the given library to those managed by this
        * frame.
        *
  @@ -866,7 +1022,7 @@
        * @exception ExecutionException if a converter defined in the library
        *      cannot be instantiated
        */
  -    private void addLibraryConverters(AntLibrary library)
  +    private void addConverters(AntLibrary library)
            throws ExecutionException {
           if (!library.hasConverters()
                || loadedConverters.contains(library.getLibraryId())) {
  @@ -888,7 +1044,7 @@
                            + " does not implement the Converter interface");
                   }
                   Converter converter
  -                     = libFactory.createConverter(converterClass);
  +                     = (Converter) libFactory.createInstance(converterClass);
                   ExecutionContext context = new ExecutionContext(frame,
                       null, Location.UNKNOWN_LOCATION);
                   converter.init(context);
  @@ -918,6 +1074,15 @@
                    + "\" unable to access converter class "
                    + className, e);
           }
  +    }
  +
  +    /**
  +     * Get the aspects which have been registered from ant libraries. 
  +     *
  +     * @return the list of Aspect instances currently defined.
  +     */
  +    protected List getAspects() {
  +        return aspects;
       }
   }
   
  
  
  
  1.15      +1 -32     jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreExecService.java
  
  Index: CoreExecService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreExecService.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -w -u -r1.14 -r1.15
  --- CoreExecService.java	1 May 2002 09:51:39 -0000	1.14
  +++ CoreExecService.java	14 May 2002 15:11:09 -0000	1.15
  @@ -59,13 +59,11 @@
   import java.util.Map;
   import org.apache.ant.antcore.modelparser.XMLProjectParser;
   import org.apache.ant.antcore.xml.XMLParseException;
  -import org.apache.ant.common.antlib.AntContext;
   import org.apache.ant.common.antlib.Task;
   import org.apache.ant.common.model.Project;
   import org.apache.ant.common.service.ExecService;
   import org.apache.ant.common.util.ExecutionException;
   import org.apache.ant.init.InitUtils;
  -import org.apache.ant.init.LoaderUtils;
   
   /**
    * This is the core's implementation of the Execution Service.
  @@ -100,36 +98,7 @@
        * @exception ExecutionException if there is an execution problem
        */
       public void executeTask(Task task) throws ExecutionException {
  -        AntContext context = task.getAntContext();
  -
  -        if (!(context instanceof ExecutionContext)) {
  -            throw new ExecutionException("The Task was not configured with an"
  -                 + " appropriate context");
  -        }
  -        ExecutionContext execContext = (ExecutionContext) context;
  -
  -        frame.getEventSupport().fireTaskStarted(task);
  -
  -        Throwable failureCause = null;
  -
  -        try {
  -            ClassLoader currentLoader
  -                 = LoaderUtils.setContextLoader(execContext.getClassLoader());
  -
  -            task.execute();
  -            LoaderUtils.setContextLoader(currentLoader);
  -        } catch (ExecutionException e) {
  -            failureCause = e;
  -            throw e;
  -        } catch (Throwable e) {
  -            ExecutionException ee =
  -                new ExecutionException(e);
  -
  -            failureCause = ee;
  -            throw ee;
  -        } finally {
  -            frame.getEventSupport().fireTaskFinished(task, failureCause);
  -        }
  +        frame.executeTask(task);
       }
   
   
  
  
  
  1.18      +4 -2      jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java
  
  Index: ExecutionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -w -u -r1.17 -r1.18
  --- ExecutionManager.java	1 May 2002 07:19:30 -0000	1.17
  +++ ExecutionManager.java	14 May 2002 15:11:09 -0000	1.18
  @@ -148,9 +148,11 @@
           } catch (RuntimeException e) {
               buildFailureCause = e;
               throw e;
  -        } catch (AntException e) {
  +        } catch (ExecutionException e) {
  +            ExecutionException ee = e instanceof ExecutionException 
  +                ? e : new ExecutionException(e);
               buildFailureCause = e;
  -            throw e;
  +            throw ee;
           } finally {
               eventSupport.fireBuildFinished(project, buildFailureCause);
           }
  
  
  
  1.24      +90 -13    jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
  
  Index: Frame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -w -u -r1.23 -r1.24
  --- Frame.java	1 May 2002 09:51:39 -0000	1.23
  +++ Frame.java	14 May 2002 15:11:09 -0000	1.24
  @@ -61,8 +61,11 @@
   import java.util.StringTokenizer;
   import java.util.List;
   import java.util.ArrayList;
  +import java.util.Set;
   import org.apache.ant.antcore.config.AntConfig;
   import org.apache.ant.common.antlib.Task;
  +import org.apache.ant.common.antlib.Aspect;
  +import org.apache.ant.common.antlib.AntContext;
   import org.apache.ant.common.event.BuildListener;
   import org.apache.ant.common.event.MessageLevel;
   import org.apache.ant.common.model.BuildElement;
  @@ -79,6 +82,7 @@
   import org.apache.ant.common.util.ExecutionException;
   import org.apache.ant.common.util.FileUtils;
   import org.apache.ant.init.InitConfig;
  +import org.apache.ant.init.LoaderUtils;
   
   /**
    * An Frame maintains the state of a project during an execution. The Frame
  @@ -99,6 +103,13 @@
       private Map referencedFrames = new HashMap();
   
       /** 
  +     * This is a Map of Maps. This map is keyed on an executing task.
  +     * Each entry is itself a Map of Aspects to their context for the
  +     * particular task.
  +     */
  +    private Map aspectContextsMap = new HashMap();
  +    
  +    /** 
        * The property overrides for the referenced frames. This map is indexed 
        * by the reference names of the frame. Each entry is another Map of 
        * property values indexed by their relative name.
  @@ -390,7 +401,7 @@
                    + "to the name \"" + definitionName + "\"");
           }
           if (containingFrame == this) {
  -            return componentManager.getDefinition(localName);
  +            return componentManager.getImport(localName);
           } else {
               return containingFrame.getReferencedDefinition(localName);
           }
  @@ -657,8 +668,6 @@
              overrides.remove(name);
          }
   
  -
  -        
          referencedFrames.put(name, referencedFrame);
          referencedFrame.initialize();
       }
  @@ -850,6 +859,68 @@
           }
       }
   
  +    /**
  +     * Execute a task notifiying all registered aspects of the fact
  +     *
  +     * @param task the Task instance to execute.
  +     *
  +     * @exception ExecutionException if the task has a problem.
  +     */
  +    protected void executeTask(Task task) throws ExecutionException {
  +        List aspects = componentManager.getAspects();
  +        Map aspectContexts = new HashMap();
  +        for (Iterator i = aspects.iterator(); i.hasNext();) {
  +            Aspect aspect = (Aspect) i.next();
  +            Object context = aspect.preExecuteTask(task);
  +            aspectContexts.put(aspect, context);
  +        }
  +        if (aspectContexts.size() != 0) {
  +            aspectContextsMap.put(task, aspectContexts);
  +        }
  +        
  +        AntContext context = task.getAntContext();
  +
  +        if (!(context instanceof ExecutionContext)) {
  +            throw new ExecutionException("The Task was not configured with an"
  +                 + " appropriate context");
  +        }
  +        ExecutionContext execContext = (ExecutionContext) context;
  +
  +        eventSupport.fireTaskStarted(task);
  +
  +        Throwable failureCause = null;
  +
  +        try {
  +            ClassLoader currentLoader
  +                 = LoaderUtils.setContextLoader(execContext.getClassLoader());
  +
  +            task.execute();
  +            LoaderUtils.setContextLoader(currentLoader);
  +        } catch (Throwable e) {
  +            failureCause = e;
  +        }
  +
  +        // Now call back the aspects that registered interest
  +        Set activeAspects = aspectContexts.keySet();
  +        for (Iterator i = activeAspects.iterator(); i.hasNext();) {
  +            Aspect aspect = (Aspect) i.next();
  +            Object aspectContext = aspectContexts.get(aspect);
  +            failureCause 
  +                = aspect.postExecuteTask(aspectContext, failureCause);
  +        }
  +        eventSupport.fireTaskFinished(task, failureCause);
  +        if (aspectContexts.size() != 0) {
  +            aspectContextsMap.remove(task);
  +        }
  +        
  +        if (failureCause != null) {
  +            if (failureCause instanceof ExecutionException) {
  +                throw (ExecutionException) failureCause;
  +            }
  +            throw new ExecutionException(failureCause);
  +        }
  +    }
  +    
   
       /**
        * Run the tasks returned by the given iterator
  @@ -860,22 +931,25 @@
        */
       protected void executeTasks(Iterator taskIterator)
            throws ExecutionException {
  +        
           while (taskIterator.hasNext()) {
               BuildElement model = (BuildElement) taskIterator.next();
   
               // what sort of element is this.
  +            List aspects = componentManager.getAspects();
               try {
                   Object component = componentManager.createComponent(model);
  +                for (Iterator i = aspects.iterator(); i.hasNext();) {
  +                    Aspect aspect = (Aspect) i.next();
  +                    Object replacement 
  +                        = aspect.postCreateComponent(component, model);
  +                    if (replacement != null) {
  +                        component = replacement;
  +                    }
  +                }
   
                   if (component instanceof Task) {
  -                    execService.executeTask((Task) component);
  -                } else {
  -                    String typeId
  -                         = model.getAspectValue(Constants.ANT_ASPECT, "id");
  -
  -                    if (typeId != null) {
  -                        setDataValue(typeId, component, true);
  -                    }
  +                    executeTask((Task) component);
                   }
               } catch (ExecutionException e) {
                   e.setLocation(model.getLocation(), false);
  @@ -1009,8 +1083,11 @@
       /**
        * Configure the services that the frame makes available to its library
        * components
  +     *
  +     * @exception ExecutionException if the services required by the core 
  +     * could not be configured.
        */
  -    private void configureServices() {
  +    private void configureServices() throws ExecutionException {
           // create services and make them available in our services map
           fileService = new CoreFileService(this);
           componentManager = new ComponentManager(this);
  
  
  
  1.5       +8 -0      jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ImportInfo.java
  
  Index: ImportInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ImportInfo.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -u -r1.4 -r1.5
  --- ImportInfo.java	18 Mar 2002 02:44:24 -0000	1.4
  +++ ImportInfo.java	14 May 2002 15:11:09 -0000	1.5
  @@ -116,5 +116,13 @@
           return libDefinition.getDefinitionName();
       }
   
  +    /**
  +     * Get the definition of the imported component.
  +     *
  +     * @return the component's library definition.
  +     */
  +    public AntLibDefinition getDefinition() {
  +        return libDefinition;
  +    }
   }
   
  
  
  
  1.11      +18 -18    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.10
  retrieving revision 1.11
  diff -u -w -u -r1.10 -r1.11
  --- Ant1Factory.java	7 Apr 2002 14:38:06 -0000	1.10
  +++ Ant1Factory.java	14 May 2002 15:11:09 -0000	1.11
  @@ -53,7 +53,6 @@
    */
   package org.apache.tools.ant;
   import org.apache.ant.common.antlib.AntContext;
  -import org.apache.ant.common.antlib.Converter;
   import org.apache.ant.common.antlib.StandardLibFactory;
   import org.apache.ant.common.service.EventService;
   import org.apache.ant.common.util.ExecutionException;
  @@ -145,40 +144,41 @@
       }
   
       /**
  -     * Create a converter.
  +     * Create an instance of the given class
        *
  -     * @param converterClass the class of the converter.
  -     * @return an instance of the requested converter class
  -     * @exception InstantiationException if the converter cannot be
  -     *      instantiated
  -     * @exception IllegalAccessException if the converter cannot be accessed
  -     * @exception ExecutionException if the converter cannot be created
  +     * @param requiredClass the class for which an instance is
  +     *      required
  +     * @return a instance of the required class
  +     * @exception InstantiationException if the class cannot be instantiated
  +     * @exception IllegalAccessException if the instance cannot be accessed
  +     * @exception ExecutionException if there is a problem creating the
  +     *      converter
        */
  -    public Converter createConverter(Class converterClass)
  +    public Object createInstance(Class requiredClass)
            throws InstantiationException, IllegalAccessException,
           ExecutionException {
   
           java.lang.reflect.Constructor c = null;
   
  -        Converter converter = null;
  +        Object instance = null;
           try {
               try {
  -                c = converterClass.getConstructor(new Class[0]);
  -                converter = (Converter) c.newInstance(new Object[0]);
  +                c = requiredClass.getConstructor(new Class[0]);
  +                instance = c.newInstance(new Object[0]);
               } catch (NoSuchMethodException nse) {
  -                c = converterClass.getConstructor(new Class[]{Project.class});
  -                converter = (Converter) c.newInstance(new Object[]{project});
  +                c = requiredClass.getConstructor(new Class[]{Project.class});
  +                instance = c.newInstance(new Object[]{project});
               }
   
  -            return converter;
  +            return instance;
           } catch (java.lang.reflect.InvocationTargetException ite) {
               Throwable t = ite.getTargetException();
  -            String msg = "Could not create converter of type: "
  -                 + converterClass.getName() + " due to " + t;
  +            String msg = "Could not create instance of type: "
  +                 + requiredClass.getName() + " due to " + t;
               throw new ExecutionException(msg, t);
           } catch (NoSuchMethodException e) {
               throw new ExecutionException("Unable to find an appropriate "
  -                 + "constructor for converter " + converterClass.getName(), e);
  +                 + "constructor for class " + requiredClass.getName(), e);
           }
       }
   
  
  
  
  1.23      +2 -5      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.22
  retrieving revision 1.23
  diff -u -w -u -r1.22 -r1.23
  --- Project.java	30 Apr 2002 07:00:51 -0000	1.22
  +++ Project.java	14 May 2002 15:11:09 -0000	1.23
  @@ -1058,8 +1058,7 @@
           }
   
           try {
  -            Object taskObject = componentService.createComponent(factory,
  -                context.getClassLoader(), taskClass, false, taskType);
  +            Object taskObject = componentService.createComponent(taskType);
               if (taskObject instanceof Task) {
                   task = (Task) taskObject;
               } else {
  @@ -1093,9 +1092,7 @@
           }
   
           try {
  -            Object dataInstance = componentService.createComponent(factory,
  -                context.getClassLoader(), typeClass, false, typeName);
  -            return dataInstance;
  +            return componentService.createComponent(typeName);
           } catch (Throwable e) {
               throw new BuildException(e);
           }
  
  
  
  1.8       +1 -3      jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- Ant.java	7 Apr 2002 14:38:06 -0000	1.7
  +++ Ant.java	14 May 2002 15:11:09 -0000	1.8
  @@ -146,9 +146,7 @@
               ComponentService componentService = getComponentService();
               AntLibFactory factory = getProject().getFactory();
               realAnt = (org.apache.ant.antlib.system.Ant)
  -                componentService.createComponent(factory,
  -                context.getClassLoader(),
  -                org.apache.ant.antlib.system.Ant.class, false, "antcall");
  +                componentService.createComponent("ant.system", "ant");
           } catch (ExecutionException e) {
               throw new BuildException(e);
           }
  
  
  
  1.7       +2 -2      jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java
  
  Index: CallTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -u -r1.6 -r1.7
  --- CallTarget.java	7 Apr 2002 14:38:06 -0000	1.6
  +++ CallTarget.java	14 May 2002 15:11:09 -0000	1.7
  @@ -102,8 +102,8 @@
           try {
               ComponentService componentService = getComponentService();
               AntLibFactory factory = getProject().getFactory();
  -            antCall = (AntCall) componentService.createComponent(factory,
  -                context.getClassLoader(), AntCall.class, false, "antcall");
  +            antCall = (AntCall) componentService.createComponent("ant.system",
  +                "antcall");
           } catch (ExecutionException e) {
               throw new BuildException(e);
           }
  
  
  
  1.8       +3 -1      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.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- antlib.xml	17 Apr 2002 15:51:06 -0000	1.7
  +++ antlib.xml	14 May 2002 15:11:09 -0000	1.8
  @@ -16,4 +16,6 @@
     <converter classname="org.apache.ant.antlib.system.FileConverter"/>          
     <converter classname="org.apache.ant.antlib.system.URLConverter"/>          
     <converter classname="org.apache.ant.antlib.system.PrimitiveConverter"/>          
  +
  +  <aspect classname="org.apache.ant.antlib.system.AntAspect"/>         
   </antlib>
  
  
  
  1.1                  jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntAspect.java
  
  Index: AntAspect.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.antlib.system;
  import org.apache.ant.common.antlib.AbstractAspect;
  import org.apache.ant.common.antlib.AntContext;
  import org.apache.ant.common.service.DataService;
  import org.apache.ant.common.util.ExecutionException;
  import org.apache.ant.common.model.BuildElement;
  
  /**
   * The Ant aspect - handles all ant aspects
   *
   * @author Conor MacNeill
   */
  public class AntAspect extends AbstractAspect {
      /** The Ant aspect used to identify Ant metadata */
      public static final String ANT_ASPECT = "ant";
      
      /** The core's data service implementation */
      private DataService dataService = null;
  
      /**
       * Initialise the aspect with a context. 
       *
       * @param context the aspect's context
       * @exception ExecutionException if the aspect cannot be initialised
       */
      public void init(AntContext context) throws ExecutionException {
          super.init(context);
          dataService = (DataService) context.getCoreService(DataService.class);
      }
      
      /**
       * This join point is activated after a component has been created and
       * configured. If the aspect wishes, an object can be returned in place
       * of the one created by Ant. 
       *
       * @param component the component that has been created.
       * @param model the Build model used to create the component.
       *
       * @return a replacement for the component if desired. If null is returned
       *         the current component is used.
       * @exception ExecutionException if the component cannot be processed.
       */         
      public Object postCreateComponent(Object component, BuildElement model) 
           throws ExecutionException {
          String typeId = model.getAspectValue(ANT_ASPECT, "id");
      
          if (typeId != null) {
              dataService.setMutableDataValue(typeId, component);
          }
          
          return null;
      }
  }
  
  
  
  
  1.7       +4 -4      jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java
  
  Index: AntLibFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -u -r1.6 -r1.7
  --- AntLibFactory.java	18 Mar 2002 02:44:27 -0000	1.6
  +++ AntLibFactory.java	14 May 2002 15:11:10 -0000	1.7
  @@ -88,17 +88,17 @@
           ExecutionException;
   
       /**
  -     * Create an instance of the given converter class
  +     * Create an instance of the given class
        *
  -     * @param converterClass the converter class for which an instance is
  +     * @param requiredClass the class for which an instance is
        *      required
  -     * @return a converter instance
  +     * @return a instance of the required class
        * @exception InstantiationException if the class cannot be instantiated
        * @exception IllegalAccessException if the instance cannot be accessed
        * @exception ExecutionException if there is a problem creating the
        *      converter
        */
  -    Converter createConverter(Class converterClass)
  +    Object createInstance(Class requiredClass)
            throws InstantiationException, IllegalAccessException,
           ExecutionException;
   
  
  
  
  1.5       +2 -2      jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/ExecutionComponent.java
  
  Index: ExecutionComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/ExecutionComponent.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -u -r1.4 -r1.5
  --- ExecutionComponent.java	18 Mar 2002 02:44:27 -0000	1.4
  +++ ExecutionComponent.java	14 May 2002 15:11:10 -0000	1.5
  @@ -63,10 +63,10 @@
    */
   public interface ExecutionComponent {
       /**
  -     * Initialise the task. The task may use the AntContext to request
  +     * Initialise the component. The component may use the AntContext to request
        * services from the Ant core.
        *
  -     * @param context the Task's context
  +     * @param context the Component's context
        * @param componentType the type of the component
        * @exception ExecutionException if the component cannot be initialised
        */
  
  
  
  1.8       +5 -5      jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java
  
  Index: StandardLibFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- StandardLibFactory.java	7 Apr 2002 14:38:07 -0000	1.7
  +++ StandardLibFactory.java	14 May 2002 15:11:10 -0000	1.8
  @@ -93,20 +93,20 @@
       }
   
       /**
  -     * Create an instance of the given converter class
  +     * Create an instance of the given class
        *
  -     * @param converterClass the converter class for which an instance is
  +     * @param requiredClass the class for which an instance is
        *      required
  -     * @return a converter instance
  +     * @return a instance of the required class
        * @exception InstantiationException if the class cannot be instantiated
        * @exception IllegalAccessException if the instance cannot be accessed
        * @exception ExecutionException if there is a problem creating the
        *      converter
        */
  -    public Converter createConverter(Class converterClass)
  +    public Object createInstance(Class requiredClass)
            throws InstantiationException, IllegalAccessException,
           ExecutionException {
  -        return (Converter) converterClass.newInstance();
  +        return requiredClass.newInstance();
       }
   
       /**
  
  
  
  1.1                  jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/AbstractAspect.java
  
  Index: AbstractAspect.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.antlib;
  
  import org.apache.ant.common.util.ExecutionException;
  import org.apache.ant.common.model.BuildElement;
  
  /**
   * An implementation of the Aspect interface providing default behaviour.
   *
   * @author Conor MacNeill
   */
  public class AbstractAspect implements Aspect {
      /** 
       * The Ant context for this aspect which can be used to access core 
       * services.
       */
      private AntContext context;
      
      /**
       * Initialise the aspect with a context. 
       *
       * @param context the aspect's context
       * @exception ExecutionException if the aspect cannot be initialised
       */
      public void init(AntContext context) throws ExecutionException {
          this.context = context;
      }
  
      /**
       * Get this aspect's context
       *
       * @return the aspect context
       */
      protected AntContext getAntContext() {
          return context;
      }
  
           
      /**
       * This join point is activated after a component has been created and
       * configured. If the aspect wishes, an object can be returned in place
       * of the one created by Ant. 
       *
       * @param component the component that has been created.
       * @param model the Build model used to create the component.
       *
       * @return a replacement for the component if desired. If null is returned
       *         the current component is used.
       * @exception ExecutionException if the aspect cannot process the component.
       */         
      public Object postCreateComponent(Object component, BuildElement model) 
           throws ExecutionException {
          return null;
      }
  
      /**
       * This join point is activated just prior to task execution.
       *
       * @param task the task being executed.
       *
       * @return an objectwhich indicates that this aspect wishes to 
       * be notified after execution has been completed, in which case the obkect
       * is returned to provide the aspect its context. If this returns null
       * the aspect's postExecuteTask method will not be invoked.
       * @exception ExecutionException if the aspect cannot process the task.
       */
      public Object preExecuteTask(Task task) throws ExecutionException {
          return null;
      }
      
      /**
       * This join point is activated after a task has executed. The aspect
       * may override the task's failure cause by returning a new failure.
       *
       * @param context the context the aspect provided in preExecuteTask.
       * @param failureCause the current failure reason for the task.
       *
       * @return a new failure reason or null if the task is not to fail.
       */
      public Throwable postExecuteTask(Object context, Throwable failureCause) {
          return failureCause;
      }
  
      /**
       * This point is activated when the task is to receive output that has
       * been sent to output stream and redirected into the task.
       *
       * @param context the context the aspect provided in preExecuteTask.
       * @param line the content sent to the output stream.
       *
       * @return the line to be forwarded onto the task.
       */
      public String taskOutput(Object context, String line) {
          return line;
      }
  
      /**
       * This point is activated when the task is to receive error content that 
       * has been sent to error stream and redirected into the task.
       *
       * @param context the context the aspect provided in preExecuteTask.
       * @param line the content sent to the error stream.
       *
       * @return the line to be forwarded onto the task.
       */
      public String taskError(Object context, String line) {
          return line;
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/Aspect.java
  
  Index: Aspect.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.antlib;
  
  import org.apache.ant.common.util.ExecutionException;
  import org.apache.ant.common.model.BuildElement;
  
  /**
   * An aspect is a component which is activated across all task and 
   * component operations. It allows a single implmentation to be applied
   * to a number of tasks without requiring changes to the task implementations. 
   *
   * @author Conor MacNeill
   */
  public interface Aspect {
      /**
       * Initialise the aspect with a context. 
       *
       * @param context the aspect's context
       * @exception ExecutionException if the aspect cannot be initialised
       */
      void init(AntContext context)
           throws ExecutionException;
  
           
      /**
       * This join point is activated after a component has been created and
       * configured. If the aspect wishes, an object can be returned in place
       * of the one created by Ant. 
       *
       * @param component the component that has been created.
       * @param model the Build model used to create the component.
       *
       * @return a replacement for the component if desired. If null is returned
       *         the current component is used.
       * @exception ExecutionException if the aspect cannot process the component.
       */         
      Object postCreateComponent(Object component, BuildElement model)
          throws ExecutionException;
  
      /**
       * This join point is activated just prior to task execution.
       *
       * @param task the task being executed.
       *
       * @return an objectwhich indicates that this aspect wishes to 
       * be notified after execution has been completed, in which case the obkect
       * is returned to provide the aspect its context. If this returns null
       * the aspect's postExecuteTask method will not be invoked.
       * @exception ExecutionException if the aspect cannot process the task.
       */
      Object preExecuteTask(Task task) throws ExecutionException;
      
      /**
       * This join point is activated after a task has executed. The aspect
       * may override the task's failure cause by returning a new failure.
       *
       * @param context the context the aspect provided in preExecuteTask.
       * @param failureCause the current failure reason for the task.
       *
       * @return a new failure reason or null if the task is not to fail.
       */
      Throwable postExecuteTask(Object context, Throwable failureCause);
  
      /**
       * This point is activated when the task is to receive output that has
       * been sent to output stream and redirected into the task.
       *
       * @param context the context the aspect provided in preExecuteTask.
       * @param line the content sent to the output stream.
       *
       * @return the line to be forwarded onto the task.
       */
      String taskOutput(Object context, String line);
  
      /**
       * This point is activated when the task is to receive error content that 
       * has been sent to error stream and redirected into the task.
       *
       * @param context the context the aspect provided in preExecuteTask.
       * @param line the content sent to the error stream.
       *
       * @return the line to be forwarded onto the task.
       */
      String taskError(Object context, String line);
  }
  
  
  
  
  1.13      +7 -12     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.12
  retrieving revision 1.13
  diff -u -w -u -r1.12 -r1.13
  --- ComponentService.java	1 May 2002 07:19:30 -0000	1.12
  +++ ComponentService.java	14 May 2002 15:11:10 -0000	1.13
  @@ -174,22 +174,17 @@
       Object createComponent(String componentName) throws ExecutionException;
   
       /**
  -     * Create a component given its class. The component will have a context
  -     * but will not be configured. It should be configured using the
  -     * appropriate set methods and then validated before being used.
  +     * Create a component given its libraryId and local name within the 
  +     * library. This method is unambiguous in the face of imports, aliases and
  +     * taskdefs performed in the build.
        *
  -     * @param componentClass the component's class
  -     * @param factory the factory to create the component
  -     * @param loader the classloader associated with the component
  -     * @param addTaskAdapter whenther the returned component should be a
  -     *      task, potentially being wrapped in an adapter
  -     * @param componentName the name of the component type
  +     * @param libraryId the component's library identifier.
  +     * @param localName the name component within the library.
        * @return the created component. The return type of this method depends
        *      on the component type.
        * @exception ExecutionException if the component cannot be created
        */
  -    Object createComponent(AntLibFactory factory, ClassLoader loader,
  -                           Class componentClass, boolean addTaskAdapter,
  -                           String componentName) throws ExecutionException;
  +    Object createComponent(String libraryId, String localName)
  +        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