Renamed a few classes git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271219 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -158,7 +158,7 @@ | |||||
| <path id="checkstyle.path"> | <path id="checkstyle.path"> | ||||
| <fileset dir="${checkstyle.bin}"/> | <fileset dir="${checkstyle.bin}"/> | ||||
| </path> | </path> | ||||
| <taskdef name="checkstyle" reverseloader="true" | |||||
| <taskdef name="checkstyle" | |||||
| classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"> | classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"> | ||||
| <classpath refid="checkstyle.path"/> | <classpath refid="checkstyle.path"/> | ||||
| </taskdef> | </taskdef> | ||||
| @@ -55,10 +55,10 @@ package org.apache.ant.antcore.antlib; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashMap; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import org.apache.ant.common.antlib.AntContext; | |||||
| import org.apache.ant.common.antlib.AntLibFactory; | import org.apache.ant.common.antlib.AntLibFactory; | ||||
| import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
| @@ -68,12 +68,7 @@ import org.apache.ant.common.util.ExecutionException; | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | ||||
| * @created 14 January 2002 | * @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; | |||||
| public class AntLibrary implements ComponentLibrary { | |||||
| /** A counter for generating unique ids */ | /** A counter for generating unique ids */ | ||||
| private static int implicitLibCount = 0; | private static int implicitLibCount = 0; | ||||
| @@ -128,25 +123,6 @@ public class AntLibrary { | |||||
| this.definitionURL = spec.getLibraryURL(); | 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(); | |||||
| } | |||||
| /** | /** | ||||
| * Sets the Library which this library extends | * Sets the Library which this library extends | ||||
| * | * | ||||
| @@ -191,10 +167,21 @@ public class AntLibrary { | |||||
| /** | /** | ||||
| * Gets the definitions (taskdefs and typedefs) of the AntLibrary | * Gets the definitions (taskdefs and typedefs) of the AntLibrary | ||||
| * | * | ||||
| * @return the definitions map | |||||
| * @return an iterator over the definition names | |||||
| */ | |||||
| public Iterator getDefinitionNames() { | |||||
| return definitions.keySet().iterator(); | |||||
| } | |||||
| /** | |||||
| * Get the definition of a particular component | |||||
| * | |||||
| * @param definitionName the name of the component within the library | |||||
| * @return an AntLibDefinition instance with information about the | |||||
| * component's definition | |||||
| */ | */ | ||||
| public Map getDefinitions() { | |||||
| return definitions; | |||||
| public AntLibDefinition getDefinition(String definitionName) { | |||||
| return (AntLibDefinition)definitions.get(definitionName); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -220,11 +207,14 @@ public class AntLibrary { | |||||
| * Gat an instance of a factory object for creating objects in this | * Gat an instance of a factory object for creating objects in this | ||||
| * library. | * library. | ||||
| * | * | ||||
| * @param context the context to use for the factory creation if | |||||
| * required | |||||
| * @return an instance of the factory, or null if this library does not | * @return an instance of the factory, or null if this library does not | ||||
| * support a factory | * support a factory | ||||
| * @exception ExecutionException if the factory cannot be created | * @exception ExecutionException if the factory cannot be created | ||||
| */ | */ | ||||
| public AntLibFactory getFactory() throws ExecutionException { | |||||
| public AntLibFactory getFactory(AntContext context) | |||||
| throws ExecutionException { | |||||
| try { | try { | ||||
| AntLibFactory libFactory = null; | AntLibFactory libFactory = null; | ||||
| if (factoryClassName != null) { | if (factoryClassName != null) { | ||||
| @@ -232,6 +222,7 @@ public class AntLibrary { | |||||
| true, getClassLoader()); | true, getClassLoader()); | ||||
| libFactory | libFactory | ||||
| = (AntLibFactory)factoryClass.newInstance(); | = (AntLibFactory)factoryClass.newInstance(); | ||||
| libFactory.init(context); | |||||
| } | } | ||||
| return libFactory; | return libFactory; | ||||
| } catch (ClassNotFoundException e) { | } catch (ClassNotFoundException e) { | ||||
| @@ -0,0 +1,106 @@ | |||||
| /* | |||||
| * 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.antlib; | |||||
| import org.apache.ant.common.antlib.AntContext; | |||||
| import org.apache.ant.common.antlib.AntLibFactory; | |||||
| import org.apache.ant.common.util.ExecutionException; | |||||
| /** | |||||
| * A Component Library supplies components to the Ant core. | |||||
| * | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||||
| * @created 8 February 2002 | |||||
| */ | |||||
| public interface ComponentLibrary { | |||||
| /** constant indicating a taskdef definition */ | |||||
| final static int TASKDEF = 1; | |||||
| /** constant indicating a typedef definition */ | |||||
| final static int TYPEDEF = 2; | |||||
| /** | |||||
| * Gets the ClassLoader of the AntLibrary | |||||
| * | |||||
| * @return The ClassLoader value | |||||
| */ | |||||
| ClassLoader getClassLoader(); | |||||
| /** | |||||
| * Gat an instance of a factory object for creating objects in this | |||||
| * library. | |||||
| * | |||||
| * @param context the context to use for the factory creation if | |||||
| * required | |||||
| * @return an instance of the factory, or null if this library does not | |||||
| * support a factory | |||||
| * @exception ExecutionException if the factory cannot be created | |||||
| */ | |||||
| AntLibFactory getFactory(AntContext context) throws ExecutionException; | |||||
| /** | |||||
| * Gets the libraryId of the AntLibrary | |||||
| * | |||||
| * @return the libraryId value | |||||
| */ | |||||
| String getLibraryId(); | |||||
| /** | |||||
| * Get the definition of a particular component | |||||
| * | |||||
| * @param definitionName the name of the component within the library | |||||
| * @return an AntLibDefinition instance with information about the | |||||
| * component's definition | |||||
| */ | |||||
| AntLibDefinition getDefinition(String definitionName); | |||||
| } | |||||
| @@ -0,0 +1,165 @@ | |||||
| /* | |||||
| * 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.antlib; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import org.apache.ant.common.antlib.AntContext; | |||||
| import org.apache.ant.common.antlib.AntLibFactory; | |||||
| /** | |||||
| * A dynamic library is created at runtime to hold newly defined components. | |||||
| * | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||||
| * @created 8 February 2002 | |||||
| */ | |||||
| public class DynamicLibrary implements ComponentLibrary { | |||||
| /** The name profix for naming dynamic libraries */ | |||||
| public final static String DYNAMIC_LIB_PREFIX = "_internal"; | |||||
| /** A static field used to uniquely name dynamic libraries */ | |||||
| private static int dynamicIdCounter = 0; | |||||
| /** | |||||
| * the factory this dynamic library will use to create instances of its | |||||
| * components | |||||
| */ | |||||
| private AntLibFactory factory; | |||||
| /** | |||||
| * the classloader that will be used to create new instances of the | |||||
| * library's components | |||||
| */ | |||||
| private ClassLoader loader; | |||||
| /** the library's unique id */ | |||||
| private String libraryId; | |||||
| /** | |||||
| * the component definitions of this library. This map contains | |||||
| * AntLibDefinition instances indexed on the definition names. | |||||
| */ | |||||
| private Map definitions = new HashMap(); | |||||
| /** | |||||
| * Constructor for the DynamicLibrary object | |||||
| * | |||||
| * @param factory the factory to use to create instances. May be null | |||||
| * @param loader the loader to use to load the instance classes | |||||
| */ | |||||
| public DynamicLibrary(AntLibFactory factory, ClassLoader loader) { | |||||
| int dynamicId = 0; | |||||
| synchronized (DynamicLibrary.class) { | |||||
| dynamicId = dynamicIdCounter++; | |||||
| } | |||||
| this.libraryId = DYNAMIC_LIB_PREFIX + dynamicId; | |||||
| this.loader = loader; | |||||
| this.factory = factory; | |||||
| } | |||||
| /** | |||||
| * Gets the ClassLoader of the AntLibrary | |||||
| * | |||||
| * @return The ClassLoader value | |||||
| */ | |||||
| public ClassLoader getClassLoader() { | |||||
| return loader; | |||||
| } | |||||
| /** | |||||
| * Gat an instance of a factory object for creating objects in this | |||||
| * library. | |||||
| * | |||||
| * @param context the context to use for the factory creation if | |||||
| * required | |||||
| * @return an instance of the factory, or null if this library does not | |||||
| * support a factory | |||||
| */ | |||||
| public AntLibFactory getFactory(AntContext context) { | |||||
| return factory; | |||||
| } | |||||
| /** | |||||
| * Gets the libraryId of the AntLibrary | |||||
| * | |||||
| * @return the libraryId value | |||||
| */ | |||||
| public String getLibraryId() { | |||||
| return libraryId; | |||||
| } | |||||
| /** | |||||
| * Get the definition of a particular component | |||||
| * | |||||
| * @param definitionName the name of the component within the library | |||||
| * @return an AntLibDefinition instance with information about the | |||||
| * component's definition | |||||
| */ | |||||
| public AntLibDefinition getDefinition(String definitionName) { | |||||
| return (AntLibDefinition)definitions.get(definitionName); | |||||
| } | |||||
| /** | |||||
| * Add a new component definition to this library | |||||
| * | |||||
| * @param componentType the type of the component | |||||
| * @param componentName the name of the component | |||||
| * @param componentClassName the component's class | |||||
| */ | |||||
| public void addComponent(int componentType, String componentName, | |||||
| String componentClassName) { | |||||
| AntLibDefinition newDefinition | |||||
| = new AntLibDefinition(componentType, componentName, | |||||
| componentClassName); | |||||
| definitions.put(componentName, newDefinition); | |||||
| } | |||||
| } | |||||
| @@ -52,24 +52,20 @@ | |||||
| * <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
| */ | */ | ||||
| package org.apache.ant.antcore.execution; | package org.apache.ant.antcore.execution; | ||||
| import java.io.File; | |||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import org.apache.ant.antcore.antlib.AntLibDefinition; | import org.apache.ant.antcore.antlib.AntLibDefinition; | ||||
| import org.apache.ant.antcore.antlib.AntLibManager; | import org.apache.ant.antcore.antlib.AntLibManager; | ||||
| import org.apache.ant.antcore.antlib.AntLibrary; | import org.apache.ant.antcore.antlib.AntLibrary; | ||||
| import org.apache.ant.antcore.modelparser.XMLProjectParser; | |||||
| import org.apache.ant.antcore.xml.XMLParseException; | |||||
| import org.apache.ant.antcore.antlib.ComponentLibrary; | |||||
| import org.apache.ant.antcore.antlib.DynamicLibrary; | |||||
| import org.apache.ant.common.antlib.AntLibFactory; | import org.apache.ant.common.antlib.AntLibFactory; | ||||
| import org.apache.ant.common.antlib.Converter; | import org.apache.ant.common.antlib.Converter; | ||||
| import org.apache.ant.common.antlib.StandardLibFactory; | import org.apache.ant.common.antlib.StandardLibFactory; | ||||
| import org.apache.ant.common.model.Project; | |||||
| import org.apache.ant.common.service.ComponentService; | import org.apache.ant.common.service.ComponentService; | ||||
| import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
| import org.apache.ant.init.InitUtils; | |||||
| /** | /** | ||||
| * The instance of the ComponentServices made available by the core to the | * The instance of the ComponentServices made available by the core to the | ||||
| @@ -83,16 +79,16 @@ public class ComponentManager implements ComponentService { | |||||
| public final static String ANT_LIB_PREFIX = "ant."; | public final static String ANT_LIB_PREFIX = "ant."; | ||||
| /** | /** | ||||
| * Type converters for this executionFrame. Converters are used when | |||||
| * configuring Tasks to handle special type conversions. | |||||
| * Type converters for this frame. Converters are used when configuring | |||||
| * Tasks to handle special type conversions. | |||||
| */ | */ | ||||
| private Map converters = new HashMap(); | private Map converters = new HashMap(); | ||||
| /** The factory objects for each library, indexed by the library Id */ | /** The factory objects for each library, indexed by the library Id */ | ||||
| private Map libFactories = new HashMap(); | private Map libFactories = new HashMap(); | ||||
| /** The ExecutionFrame this service instance is working for */ | |||||
| private ExecutionFrame frame; | |||||
| /** The Frame this service instance is working for */ | |||||
| private Frame frame; | |||||
| /** The library manager instance used to configure libraries. */ | /** The library manager instance used to configure libraries. */ | ||||
| private AntLibManager libManager; | private AntLibManager libManager; | ||||
| @@ -102,20 +98,25 @@ public class ComponentManager implements ComponentService { | |||||
| * manager | * manager | ||||
| */ | */ | ||||
| private Map antLibraries; | private Map antLibraries; | ||||
| /** dynamic libraries which have been defined */ | |||||
| private Map dynamicLibraries; | |||||
| /** The definitions which have been imported into this frame. */ | /** The definitions which have been imported into this frame. */ | ||||
| private Map definitions = new HashMap(); | private Map definitions = new HashMap(); | ||||
| /** | /** | ||||
| * Constructor | * Constructor | ||||
| * | * | ||||
| * @param executionFrame the frame containing this context | |||||
| * @param frame the frame containing this context | |||||
| * @param allowRemoteLibs true if remote libraries can be loaded though | * @param allowRemoteLibs true if remote libraries can be loaded though | ||||
| * this service. | * this service. | ||||
| */ | */ | ||||
| protected ComponentManager(ExecutionFrame executionFrame, | |||||
| protected ComponentManager(Frame frame, | |||||
| boolean allowRemoteLibs) { | boolean allowRemoteLibs) { | ||||
| this.frame = executionFrame; | |||||
| this.frame = frame; | |||||
| libManager = new AntLibManager(allowRemoteLibs); | libManager = new AntLibManager(allowRemoteLibs); | ||||
| dynamicLibraries = new HashMap(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -148,78 +149,38 @@ public class ComponentManager implements ComponentService { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param antFile the file containing the XML description of the model | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| public void runBuild(File antFile, Map properties, List targets) | |||||
| throws ExecutionException { | |||||
| try { | |||||
| // Parse the build file into a project | |||||
| XMLProjectParser parser = new XMLProjectParser(); | |||||
| Project project | |||||
| = parser.parseBuildFile(InitUtils.getFileURL(antFile)); | |||||
| runBuild(project, properties, targets); | |||||
| } catch (MalformedURLException e) { | |||||
| throw new ExecutionException(e); | |||||
| } catch (XMLParseException e) { | |||||
| throw new ExecutionException(e); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param model the project model to be used for the build | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| public void runBuild(Project model, Map properties, List targets) | |||||
| throws ExecutionException { | |||||
| ExecutionFrame newFrame = frame.createFrame(model); | |||||
| newFrame.setInitialProperties(properties); | |||||
| newFrame.runBuild(targets); | |||||
| } | |||||
| /** | |||||
| * Run a sub-build using the current frame's project model | |||||
| * | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| public void callTarget(Map properties, List targets) | |||||
| throws ExecutionException { | |||||
| runBuild(frame.getProject(), properties, targets); | |||||
| } | |||||
| /** | /** | ||||
| * Experimental - define a new task | * Experimental - define a new task | ||||
| * | * | ||||
| * @param taskName the name by which this task will be referred | * @param taskName the name by which this task will be referred | ||||
| * @param taskClass the class of the task | |||||
| * @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 | * @exception ExecutionException if the task cannot be defined | ||||
| */ | */ | ||||
| public void taskdef(String taskName, Class taskClass) | |||||
| public void taskdef(AntLibFactory factory, ClassLoader loader, | |||||
| String taskName, String className) | |||||
| throws ExecutionException { | throws ExecutionException { | ||||
| defineComponent(AntLibrary.TASKDEF, taskName, taskClass); | |||||
| defineComponent(factory, loader, ComponentLibrary.TASKDEF, | |||||
| taskName, className); | |||||
| } | } | ||||
| /** | /** | ||||
| * Experimental - define a new type | * Experimental - define a new type | ||||
| * | * | ||||
| * @param typeName the name by which this type will be referred | * @param typeName the name by which this type will be referred | ||||
| * @param typeClass the class of the type | |||||
| * @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 | * @exception ExecutionException if the type cannot be defined | ||||
| */ | */ | ||||
| public void typedef(String typeName, Class typeClass) | |||||
| public void typedef(AntLibFactory factory, ClassLoader loader, | |||||
| String typeName, String className) | |||||
| throws ExecutionException { | throws ExecutionException { | ||||
| defineComponent(AntLibrary.TYPEDEF, typeName, typeClass); | |||||
| defineComponent(factory, loader, ComponentLibrary.TYPEDEF, | |||||
| typeName, className); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -233,6 +194,7 @@ public class ComponentManager implements ComponentService { | |||||
| */ | */ | ||||
| protected void setStandardLibraries(Map standardLibs) | protected void setStandardLibraries(Map standardLibs) | ||||
| throws ExecutionException { | throws ExecutionException { | ||||
| antLibraries = new HashMap(standardLibs); | antLibraries = new HashMap(standardLibs); | ||||
| // go through the libraries and import all standard ant libraries | // go through the libraries and import all standard ant libraries | ||||
| @@ -256,33 +218,26 @@ public class ComponentManager implements ComponentService { | |||||
| } | } | ||||
| /** | /** | ||||
| * Get the collection of Ant Libraries defined for this frame | |||||
| * | |||||
| * @return a map of Ant Libraries indexed by thier library Id | |||||
| */ | |||||
| protected Map getAntLibraries() { | |||||
| return antLibraries; | |||||
| } | |||||
| /** | |||||
| * Gets the factory object for the given library | |||||
| * Get the collection of Ant Libraries defined for this frame Gets the | |||||
| * factory object for the given library | |||||
| * | * | ||||
| * @param antLibrary the library for which the factory is required | |||||
| * @param componentLibrary the compnent library for which a factory | |||||
| * objetc is required | |||||
| * @return the library's factory object | * @return the library's factory object | ||||
| * @exception ExecutionException if the factory cannot be initialised | |||||
| * @exception ExecutionException if the factory cannot be created | |||||
| */ | */ | ||||
| protected AntLibFactory getLibFactory(AntLibrary antLibrary) | |||||
| protected AntLibFactory getLibFactory(ComponentLibrary componentLibrary) | |||||
| throws ExecutionException { | throws ExecutionException { | ||||
| String libraryId = antLibrary.getLibraryId(); | |||||
| String libraryId = componentLibrary.getLibraryId(); | |||||
| if (libFactories.containsKey(libraryId)) { | if (libFactories.containsKey(libraryId)) { | ||||
| return (AntLibFactory)libFactories.get(libraryId); | return (AntLibFactory)libFactories.get(libraryId); | ||||
| } | } | ||||
| AntLibFactory libFactory = antLibrary.getFactory(); | |||||
| AntLibFactory libFactory | |||||
| = componentLibrary.getFactory(new ExecutionContext(frame)); | |||||
| if (libFactory == null) { | if (libFactory == null) { | ||||
| libFactory = new StandardLibFactory(); | libFactory = new StandardLibFactory(); | ||||
| } | } | ||||
| libFactories.put(libraryId, libFactory); | libFactories.put(libraryId, libFactory); | ||||
| libFactory.init(new ExecutionContext(frame)); | |||||
| return libFactory; | return libFactory; | ||||
| } | } | ||||
| @@ -309,32 +264,53 @@ public class ComponentManager implements ComponentService { | |||||
| throw new ExecutionException("Unable to import library " + libraryId | throw new ExecutionException("Unable to import library " + libraryId | ||||
| + " as it has not been loaded"); | + " as it has not been loaded"); | ||||
| } | } | ||||
| Map libDefs = library.getDefinitions(); | |||||
| for (Iterator i = libDefs.keySet().iterator(); i.hasNext(); ) { | |||||
| for (Iterator i = library.getDefinitionNames(); i.hasNext(); ) { | |||||
| String defName = (String)i.next(); | String defName = (String)i.next(); | ||||
| AntLibDefinition libdef | |||||
| = (AntLibDefinition)libDefs.get(defName); | |||||
| definitions.put(defName, new ImportInfo(library, libdef)); | |||||
| importLibraryDef(library, defName, null); | |||||
| } | } | ||||
| addLibraryConverters(library); | addLibraryConverters(library); | ||||
| } | } | ||||
| /** | /** | ||||
| * Experimental - define a new component | |||||
| * Import a single component from the given library | |||||
| * | |||||
| * @param library the library which provides the component | |||||
| * @param defName the name of the component in the library | |||||
| * @param alias the name to be used for the component in build files. If | |||||
| * this is null, the component's name within its library is used. | |||||
| */ | |||||
| protected void importLibraryDef(ComponentLibrary library, String defName, | |||||
| String alias) { | |||||
| String label = alias; | |||||
| if (label == null) { | |||||
| label = defName; | |||||
| } | |||||
| AntLibDefinition libDef = library.getDefinition(defName); | |||||
| definitions.put(label, new ImportInfo(library, libDef)); | |||||
| } | |||||
| /** | |||||
| * Define a new component | |||||
| * | * | ||||
| * @param componentName the name this component will take | * @param componentName the name this component will take | ||||
| * @param componentClass the component's class | |||||
| * @param defType the type of component being defined | * @param defType the type of component being defined | ||||
| * @param factory the library factory object to create the component | |||||
| * instances | |||||
| * @param loader the class loader to use to create the particular | |||||
| * components | |||||
| * @param className the name of the class implementing the component | |||||
| * @exception ExecutionException if the component cannot be defined | * @exception ExecutionException if the component cannot be defined | ||||
| */ | */ | ||||
| private void defineComponent(int defType, String componentName, | |||||
| Class componentClass) | |||||
| private void defineComponent(AntLibFactory factory, ClassLoader loader, | |||||
| int defType, String componentName, | |||||
| String className) | |||||
| throws ExecutionException { | throws ExecutionException { | ||||
| AntLibrary wrapperLibrary | |||||
| = new AntLibrary(defType, componentName, componentClass); | |||||
| String libraryId = wrapperLibrary.getLibraryId(); | |||||
| antLibraries.put(libraryId, wrapperLibrary); | |||||
| importLibrary(libraryId); | |||||
| DynamicLibrary dynamicLibrary | |||||
| = new DynamicLibrary(factory, loader); | |||||
| dynamicLibrary.addComponent(defType, componentName, className); | |||||
| dynamicLibraries.put(dynamicLibrary.getLibraryId(), dynamicLibrary); | |||||
| importLibraryDef(dynamicLibrary, componentName, null); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -63,14 +63,14 @@ import org.apache.ant.common.util.PropertyUtils; | |||||
| /** | /** | ||||
| * This is the core's implementation of the DataService service interface. | * This is the core's implementation of the DataService service interface. | ||||
| * It gives Ant libraries access to property values maintained in the | * It gives Ant libraries access to property values maintained in the | ||||
| * ExecutionFrame. | |||||
| * Frame. | |||||
| * | * | ||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | ||||
| * @created 31 January 2002 | * @created 31 January 2002 | ||||
| */ | */ | ||||
| public class ExecutionDataService implements DataService { | |||||
| /** The ExecutionFrame this service instance is working for */ | |||||
| private ExecutionFrame frame; | |||||
| public class CoreDataService implements DataService { | |||||
| /** The Frame this service instance is working for */ | |||||
| private Frame frame; | |||||
| /** all properties to be unset without throwing an exception */ | /** all properties to be unset without throwing an exception */ | ||||
| private boolean allowUnsetProperties; | private boolean allowUnsetProperties; | ||||
| @@ -82,7 +82,7 @@ public class ExecutionDataService implements DataService { | |||||
| * @param allowUnsetProperties true if the reference to an unset | * @param allowUnsetProperties true if the reference to an unset | ||||
| * property should not throw an exception | * property should not throw an exception | ||||
| */ | */ | ||||
| public ExecutionDataService(ExecutionFrame frame, | |||||
| public CoreDataService(Frame frame, | |||||
| boolean allowUnsetProperties) { | boolean allowUnsetProperties) { | ||||
| this.frame = frame; | this.frame = frame; | ||||
| this.allowUnsetProperties = allowUnsetProperties; | this.allowUnsetProperties = allowUnsetProperties; | ||||
| @@ -63,15 +63,15 @@ import org.apache.ant.common.util.ExecutionException; | |||||
| * @created 7 February 2002 | * @created 7 February 2002 | ||||
| */ | */ | ||||
| public class CoreEventService implements EventService { | public class CoreEventService implements EventService { | ||||
| /** The ExecutionFrame this service instance is working for */ | |||||
| private ExecutionFrame frame; | |||||
| /** The Frame this service instance is working for */ | |||||
| private Frame frame; | |||||
| /** | /** | ||||
| * Constructor | * Constructor | ||||
| * | * | ||||
| * @param frame the frame for which this instance is providing service | * @param frame the frame for which this instance is providing service | ||||
| */ | */ | ||||
| public CoreEventService(ExecutionFrame frame) { | |||||
| public CoreEventService(Frame frame) { | |||||
| this.frame = frame; | this.frame = frame; | ||||
| } | } | ||||
| @@ -0,0 +1,136 @@ | |||||
| /* | |||||
| * 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 java.io.File; | |||||
| import java.net.MalformedURLException; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import org.apache.ant.antcore.modelparser.XMLProjectParser; | |||||
| import org.apache.ant.antcore.xml.XMLParseException; | |||||
| 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; | |||||
| /** | |||||
| *This is the core's implementation of the Execution Service. | |||||
| * | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||||
| * @created 8 February 2002 | |||||
| */ | |||||
| public class CoreExecService implements ExecService { | |||||
| /** The Frame this service instance is working for */ | |||||
| private Frame frame; | |||||
| /** | |||||
| * Constructor | |||||
| * | |||||
| * @param frame the frame containing this context | |||||
| */ | |||||
| protected CoreExecService(Frame frame) { | |||||
| this.frame = frame; | |||||
| } | |||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param antFile the file containing the XML description of the model | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| public void runBuild(File antFile, Map properties, List targets) | |||||
| throws ExecutionException { | |||||
| try { | |||||
| // Parse the build file into a project | |||||
| XMLProjectParser parser = new XMLProjectParser(); | |||||
| Project project | |||||
| = parser.parseBuildFile(InitUtils.getFileURL(antFile)); | |||||
| runBuild(project, properties, targets); | |||||
| } catch (MalformedURLException e) { | |||||
| throw new ExecutionException(e); | |||||
| } catch (XMLParseException e) { | |||||
| throw new ExecutionException(e); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param model the project model to be used for the build | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| public void runBuild(Project model, Map properties, List targets) | |||||
| throws ExecutionException { | |||||
| Frame newFrame = frame.createFrame(model); | |||||
| newFrame.setInitialProperties(properties); | |||||
| newFrame.runBuild(targets); | |||||
| } | |||||
| /** | |||||
| * Run a sub-build using the current frame's project model | |||||
| * | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| public void callTarget(Map properties, List targets) | |||||
| throws ExecutionException { | |||||
| runBuild(frame.getProject(), properties, targets); | |||||
| } | |||||
| } | |||||
| @@ -64,9 +64,9 @@ import org.apache.ant.common.util.FileUtils; | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | ||||
| * @created 27 January 2002 | * @created 27 January 2002 | ||||
| */ | */ | ||||
| public class ExecutionFileService implements FileService { | |||||
| /** The ExecutionFrame this service instance is working for */ | |||||
| private ExecutionFrame executionFrame; | |||||
| public class CoreFileService implements FileService { | |||||
| /** The Frame this service instance is working for */ | |||||
| private Frame frame; | |||||
| /** General file utilities */ | /** General file utilities */ | ||||
| private FileUtils fileUtils = new FileUtils(); | private FileUtils fileUtils = new FileUtils(); | ||||
| @@ -74,10 +74,10 @@ public class ExecutionFileService implements FileService { | |||||
| /** | /** | ||||
| * Constructor | * Constructor | ||||
| * | * | ||||
| * @param executionFrame the frame containing this context | |||||
| * @param frame the frame containing this context | |||||
| */ | */ | ||||
| public ExecutionFileService(ExecutionFrame executionFrame) { | |||||
| this.executionFrame = executionFrame; | |||||
| public CoreFileService(Frame frame) { | |||||
| this.frame = frame; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -89,7 +89,7 @@ public class ExecutionFileService implements FileService { | |||||
| * @exception ExecutionException if the file cannot be resolved. | * @exception ExecutionException if the file cannot be resolved. | ||||
| */ | */ | ||||
| public File resolveFile(String fileName) throws ExecutionException { | public File resolveFile(String fileName) throws ExecutionException { | ||||
| File base = executionFrame.getBaseDir(); | |||||
| File base = frame.getBaseDir(); | |||||
| return fileUtils.resolveFile(fileUtils.normalize(base.getPath()), | return fileUtils.resolveFile(fileUtils.normalize(base.getPath()), | ||||
| fileName); | fileName); | ||||
| } | } | ||||
| @@ -65,8 +65,8 @@ import org.apache.ant.common.util.ExecutionException; | |||||
| * @created 20 January 2002 | * @created 20 January 2002 | ||||
| */ | */ | ||||
| public class ExecutionContext implements AntContext { | public class ExecutionContext implements AntContext { | ||||
| /** The ExecutionFrame containing this context */ | |||||
| private ExecutionFrame frame; | |||||
| /** The Frame containing this context */ | |||||
| private Frame frame; | |||||
| /** the event support instance used to manage build events */ | /** the event support instance used to manage build events */ | ||||
| private BuildEventSupport eventSupport; | private BuildEventSupport eventSupport; | ||||
| @@ -79,7 +79,7 @@ public class ExecutionContext implements AntContext { | |||||
| * | * | ||||
| * @param frame the frame containing this context | * @param frame the frame containing this context | ||||
| */ | */ | ||||
| public ExecutionContext(ExecutionFrame frame) { | |||||
| public ExecutionContext(Frame frame) { | |||||
| this.frame = frame; | this.frame = frame; | ||||
| this.eventSupport = frame.getEventSupport(); | this.eventSupport = frame.getEventSupport(); | ||||
| } | } | ||||
| @@ -70,7 +70,7 @@ import org.apache.ant.init.InitConfig; | |||||
| /** | /** | ||||
| * The ExecutionManager is used to manage the execution of a build. The | * The ExecutionManager is used to manage the execution of a build. The | ||||
| * Execution manager is responsible for loading the Ant task libraries, | * Execution manager is responsible for loading the Ant task libraries, | ||||
| * creating ExecutionFrames for each project that is part of the build and | |||||
| * creating Frames for each project that is part of the build and | |||||
| * then executing the tasks within those Execution Frames. | * then executing the tasks within those Execution Frames. | ||||
| * | * | ||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | ||||
| @@ -84,7 +84,7 @@ public class ExecutionManager { | |||||
| private BuildEventSupport eventSupport = new BuildEventSupport(); | private BuildEventSupport eventSupport = new BuildEventSupport(); | ||||
| /** The Execution Frame for the top level project being executed */ | /** The Execution Frame for the top level project being executed */ | ||||
| private ExecutionFrame mainFrame; | |||||
| private Frame mainFrame; | |||||
| /** | /** | ||||
| * The configuration to be used in this execution of Ant. It is formed | * The configuration to be used in this execution of Ant. It is formed | ||||
| @@ -136,7 +136,7 @@ public class ExecutionManager { | |||||
| addConfigLibPaths(); | addConfigLibPaths(); | ||||
| mainFrame = new ExecutionFrame(antLibraries, initConfig, config); | |||||
| mainFrame = new Frame(antLibraries, initConfig, config); | |||||
| } catch (MalformedURLException e) { | } catch (MalformedURLException e) { | ||||
| throw new ExecutionException("Unable to load Ant libraries", e); | throw new ExecutionException("Unable to load Ant libraries", e); | ||||
| } | } | ||||
| @@ -60,6 +60,7 @@ import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import org.apache.ant.antcore.antlib.AntLibrary; | import org.apache.ant.antcore.antlib.AntLibrary; | ||||
| import org.apache.ant.antcore.antlib.ComponentLibrary; | |||||
| import org.apache.ant.antcore.config.AntConfig; | import org.apache.ant.antcore.config.AntConfig; | ||||
| import org.apache.ant.common.antlib.AntLibFactory; | import org.apache.ant.common.antlib.AntLibFactory; | ||||
| import org.apache.ant.common.antlib.ExecutionComponent; | import org.apache.ant.common.antlib.ExecutionComponent; | ||||
| @@ -80,16 +81,17 @@ import org.apache.ant.common.util.ExecutionException; | |||||
| import org.apache.ant.common.util.FileUtils; | import org.apache.ant.common.util.FileUtils; | ||||
| import org.apache.ant.common.util.MessageLevel; | import org.apache.ant.common.util.MessageLevel; | ||||
| import org.apache.ant.init.InitConfig; | import org.apache.ant.init.InitConfig; | ||||
| import org.apache.ant.common.service.ExecService; | |||||
| /** | /** | ||||
| * An ExecutionFrame maintains the state of a project during an execution. | |||||
| * The ExecutionFrame contains the data values set by Ant tasks as they are | |||||
| * An Frame maintains the state of a project during an execution. | |||||
| * The Frame contains the data values set by Ant tasks as they are | |||||
| * executed, including task definitions, property values, etc. | * executed, including task definitions, property values, etc. | ||||
| * | * | ||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | ||||
| * @created 14 January 2002 | * @created 14 January 2002 | ||||
| */ | */ | ||||
| public class ExecutionFrame { | |||||
| public class Frame { | |||||
| /** The Ant aspect used to identify Ant metadata */ | /** The Ant aspect used to identify Ant metadata */ | ||||
| public final static String ANT_ASPECT = "ant"; | public final static String ANT_ASPECT = "ant"; | ||||
| @@ -162,7 +164,7 @@ public class ExecutionFrame { | |||||
| * @exception ExecutionException if a component of the library cannot be | * @exception ExecutionException if a component of the library cannot be | ||||
| * imported | * imported | ||||
| */ | */ | ||||
| protected ExecutionFrame(Map standardLibs, InitConfig initConfig, | |||||
| protected Frame(Map standardLibs, InitConfig initConfig, | |||||
| AntConfig config) throws ExecutionException { | AntConfig config) throws ExecutionException { | ||||
| this.standardLibs = standardLibs; | this.standardLibs = standardLibs; | ||||
| this.config = config; | this.config = config; | ||||
| @@ -184,7 +186,7 @@ public class ExecutionFrame { | |||||
| } | } | ||||
| /** | /** | ||||
| * Sets the Project of the ExecutionFrame | |||||
| * Sets the Project of the Frame | |||||
| * | * | ||||
| * @param project The new Project value | * @param project The new Project value | ||||
| * @exception ExecutionException if any required sub-frames cannot be | * @exception ExecutionException if any required sub-frames cannot be | ||||
| @@ -198,7 +200,7 @@ public class ExecutionFrame { | |||||
| String referenceName = (String)i.next(); | String referenceName = (String)i.next(); | ||||
| Project referencedProject | Project referencedProject | ||||
| = project.getReferencedProject(referenceName); | = project.getReferencedProject(referenceName); | ||||
| ExecutionFrame referencedFrame = createFrame(referencedProject); | |||||
| Frame referencedFrame = createFrame(referencedProject); | |||||
| referencedFrames.put(referenceName, referencedFrame); | referencedFrames.put(referenceName, referencedFrame); | ||||
| } | } | ||||
| @@ -218,7 +220,7 @@ public class ExecutionFrame { | |||||
| */ | */ | ||||
| protected void setDataValue(String name, Object value, boolean mutable) | protected void setDataValue(String name, Object value, boolean mutable) | ||||
| throws ExecutionException { | throws ExecutionException { | ||||
| ExecutionFrame frame = getContainingFrame(name); | |||||
| Frame frame = getContainingFrame(name); | |||||
| if (frame == this) { | if (frame == this) { | ||||
| if (dataValues.containsKey(name) && !mutable) { | if (dataValues.containsKey(name) && !mutable) { | ||||
| log("Ignoring oveeride for data value " + name, | log("Ignoring oveeride for data value " + name, | ||||
| @@ -282,7 +284,7 @@ public class ExecutionFrame { | |||||
| Iterator i = referencedFrames.keySet().iterator(); | Iterator i = referencedFrames.keySet().iterator(); | ||||
| while (i.hasNext()) { | while (i.hasNext()) { | ||||
| String refName = (String)i.next(); | String refName = (String)i.next(); | ||||
| ExecutionFrame refFrame = getReferencedFrame(refName); | |||||
| Frame refFrame = getReferencedFrame(refName); | |||||
| Map refProperties = refFrame.getAllProperties(); | Map refProperties = refFrame.getAllProperties(); | ||||
| Iterator j = refProperties.keySet().iterator(); | Iterator j = refProperties.keySet().iterator(); | ||||
| while (j.hasNext()) { | while (j.hasNext()) { | ||||
| @@ -345,7 +347,7 @@ public class ExecutionFrame { | |||||
| } | } | ||||
| /** | /** | ||||
| * Gets the baseDir of the ExecutionFrame | |||||
| * Gets the baseDir of the Frame | |||||
| * | * | ||||
| * @return the baseDir value | * @return the baseDir value | ||||
| */ | */ | ||||
| @@ -357,11 +359,11 @@ public class ExecutionFrame { | |||||
| * Get a referenced frame by its reference name | * Get a referenced frame by its reference name | ||||
| * | * | ||||
| * @param referenceName the name under which the frame was imported. | * @param referenceName the name under which the frame was imported. | ||||
| * @return the ExecutionFrame asscociated with the given reference name | |||||
| * @return the Frame asscociated with the given reference name | |||||
| * or null if there is no such project. | * or null if there is no such project. | ||||
| */ | */ | ||||
| protected ExecutionFrame getReferencedFrame(String referenceName) { | |||||
| return (ExecutionFrame)referencedFrames.get(referenceName); | |||||
| protected Frame getReferencedFrame(String referenceName) { | |||||
| return (Frame)referencedFrames.get(referenceName); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -396,7 +398,7 @@ public class ExecutionFrame { | |||||
| * @exception ExecutionException if the value is not defined | * @exception ExecutionException if the value is not defined | ||||
| */ | */ | ||||
| protected Object getDataValue(String name) throws ExecutionException { | protected Object getDataValue(String name) throws ExecutionException { | ||||
| ExecutionFrame frame = getContainingFrame(name); | |||||
| Frame frame = getContainingFrame(name); | |||||
| if (frame == this) { | if (frame == this) { | ||||
| return dataValues.get(name); | return dataValues.get(name); | ||||
| } else { | } else { | ||||
| @@ -414,7 +416,7 @@ public class ExecutionFrame { | |||||
| * does not exist | * does not exist | ||||
| */ | */ | ||||
| protected boolean isDataValueSet(String name) throws ExecutionException { | protected boolean isDataValueSet(String name) throws ExecutionException { | ||||
| ExecutionFrame frame = getContainingFrame(name); | |||||
| Frame frame = getContainingFrame(name); | |||||
| if (frame == this) { | if (frame == this) { | ||||
| return dataValues.containsKey(name); | return dataValues.containsKey(name); | ||||
| } else { | } else { | ||||
| @@ -441,13 +443,13 @@ public class ExecutionFrame { | |||||
| * Create a new frame for a given project | * Create a new frame for a given project | ||||
| * | * | ||||
| * @param project the project model the frame will deal with | * @param project the project model the frame will deal with | ||||
| * @return an ExecutionFrame ready to build the project | |||||
| * @return an Frame ready to build the project | |||||
| * @exception ExecutionException if the frame cannot be created. | * @exception ExecutionException if the frame cannot be created. | ||||
| */ | */ | ||||
| protected ExecutionFrame createFrame(Project project) | |||||
| protected Frame createFrame(Project project) | |||||
| throws ExecutionException { | throws ExecutionException { | ||||
| ExecutionFrame newFrame | |||||
| = new ExecutionFrame(standardLibs, initConfig, config); | |||||
| Frame newFrame | |||||
| = new Frame(standardLibs, initConfig, config); | |||||
| newFrame.setProject(project); | newFrame.setProject(project); | ||||
| for (Iterator j = eventSupport.getListeners(); j.hasNext(); ) { | for (Iterator j = eventSupport.getListeners(); j.hasNext(); ) { | ||||
| BuildListener listener = (BuildListener)j.next(); | BuildListener listener = (BuildListener)j.next(); | ||||
| @@ -473,7 +475,7 @@ public class ExecutionFrame { | |||||
| */ | */ | ||||
| protected void addBuildListener(BuildListener listener) { | protected void addBuildListener(BuildListener listener) { | ||||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | ||||
| ExecutionFrame referencedFrame = (ExecutionFrame)i.next(); | |||||
| Frame referencedFrame = (Frame)i.next(); | |||||
| referencedFrame.addBuildListener(listener); | referencedFrame.addBuildListener(listener); | ||||
| } | } | ||||
| eventSupport.addBuildListener(listener); | eventSupport.addBuildListener(listener); | ||||
| @@ -486,7 +488,7 @@ public class ExecutionFrame { | |||||
| */ | */ | ||||
| protected void removeBuildListener(BuildListener listener) { | protected void removeBuildListener(BuildListener listener) { | ||||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | ||||
| ExecutionFrame subFrame = (ExecutionFrame)i.next(); | |||||
| Frame subFrame = (Frame)i.next(); | |||||
| subFrame.removeBuildListener(listener); | subFrame.removeBuildListener(listener); | ||||
| } | } | ||||
| eventSupport.removeBuildListener(listener); | eventSupport.removeBuildListener(listener); | ||||
| @@ -536,7 +538,7 @@ public class ExecutionFrame { | |||||
| List dependencyOrder = project.getTargetDependencies(targetName); | List dependencyOrder = project.getTargetDependencies(targetName); | ||||
| for (Iterator i = dependencyOrder.iterator(); i.hasNext(); ) { | for (Iterator i = dependencyOrder.iterator(); i.hasNext(); ) { | ||||
| String fullTargetName = (String)i.next(); | String fullTargetName = (String)i.next(); | ||||
| ExecutionFrame frame = getContainingFrame(fullTargetName); | |||||
| Frame frame = getContainingFrame(fullTargetName); | |||||
| String localTargetName = getNameInFrame(fullTargetName); | String localTargetName = getNameInFrame(fullTargetName); | ||||
| frame.executeTargetTasks(localTargetName); | frame.executeTargetTasks(localTargetName); | ||||
| } | } | ||||
| @@ -661,7 +663,7 @@ public class ExecutionFrame { | |||||
| */ | */ | ||||
| protected void initialize() throws ExecutionException { | protected void initialize() throws ExecutionException { | ||||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | ||||
| ExecutionFrame referencedFrame = (ExecutionFrame)i.next(); | |||||
| Frame referencedFrame = (Frame)i.next(); | |||||
| referencedFrame.initialize(); | referencedFrame.initialize(); | ||||
| } | } | ||||
| Iterator taskIterator = project.getTasks(); | Iterator taskIterator = project.getTasks(); | ||||
| @@ -695,13 +697,13 @@ public class ExecutionFrame { | |||||
| * @return the execution frame for the project that contains the given | * @return the execution frame for the project that contains the given | ||||
| * target | * target | ||||
| */ | */ | ||||
| private ExecutionFrame getContainingFrame(String targetName) { | |||||
| private Frame getContainingFrame(String targetName) { | |||||
| int index = targetName.lastIndexOf(Project.REF_DELIMITER); | int index = targetName.lastIndexOf(Project.REF_DELIMITER); | ||||
| if (index == -1) { | if (index == -1) { | ||||
| return this; | return this; | ||||
| } | } | ||||
| ExecutionFrame currentFrame = this; | |||||
| Frame currentFrame = this; | |||||
| String relativeName = targetName.substring(0, index); | String relativeName = targetName.substring(0, index); | ||||
| StringTokenizer tokenizer | StringTokenizer tokenizer | ||||
| = new StringTokenizer(relativeName, Project.REF_DELIMITER); | = new StringTokenizer(relativeName, Project.REF_DELIMITER); | ||||
| @@ -745,7 +747,7 @@ public class ExecutionFrame { | |||||
| setDataValue(MagicProperties.BASEDIR, baseDir.getAbsolutePath(), true); | setDataValue(MagicProperties.BASEDIR, baseDir.getAbsolutePath(), true); | ||||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | ||||
| ExecutionFrame refFrame = (ExecutionFrame)i.next(); | |||||
| Frame refFrame = (Frame)i.next(); | |||||
| refFrame.determineBaseDirs(); | refFrame.determineBaseDirs(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -756,16 +758,17 @@ public class ExecutionFrame { | |||||
| */ | */ | ||||
| private void configureServices() { | private void configureServices() { | ||||
| // create services and make them available in our services map | // create services and make them available in our services map | ||||
| fileService = new ExecutionFileService(this); | |||||
| fileService = new CoreFileService(this); | |||||
| componentManager | componentManager | ||||
| = new ComponentManager(this, config.isRemoteLibAllowed()); | = new ComponentManager(this, config.isRemoteLibAllowed()); | ||||
| dataService = new ExecutionDataService(this, | |||||
| dataService = new CoreDataService(this, | |||||
| config.isUnsetPropertiesAllowed()); | config.isUnsetPropertiesAllowed()); | ||||
| services.put(FileService.class, fileService); | services.put(FileService.class, fileService); | ||||
| services.put(ComponentService.class, componentManager); | services.put(ComponentService.class, componentManager); | ||||
| services.put(DataService.class, dataService); | services.put(DataService.class, dataService); | ||||
| services.put(EventService.class, new CoreEventService(this)); | services.put(EventService.class, new CoreEventService(this)); | ||||
| services.put(ExecService.class, new CoreExecService(this)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -986,14 +989,15 @@ public class ExecutionFrame { | |||||
| } | } | ||||
| String className = taskDefInfo.getClassName(); | String className = taskDefInfo.getClassName(); | ||||
| AntLibrary antLibrary = taskDefInfo.getAntLibrary(); | |||||
| ComponentLibrary componentLibrary | |||||
| = taskDefInfo.getComponentLibrary(); | |||||
| try { | try { | ||||
| ClassLoader taskClassLoader = antLibrary.getClassLoader(); | |||||
| ClassLoader taskClassLoader = componentLibrary.getClassLoader(); | |||||
| Class elementClass | Class elementClass | ||||
| = Class.forName(className, true, taskClassLoader); | = Class.forName(className, true, taskClassLoader); | ||||
| AntLibFactory libFactory | AntLibFactory libFactory | ||||
| = componentManager.getLibFactory(antLibrary); | |||||
| = componentManager.getLibFactory(componentLibrary); | |||||
| Object element = libFactory.createTaskInstance(elementClass); | Object element = libFactory.createTaskInstance(elementClass); | ||||
| Task task = null; | Task task = null; | ||||
| @@ -1058,16 +1062,17 @@ public class ExecutionFrame { | |||||
| } | } | ||||
| String className = typeDefInfo.getClassName(); | String className = typeDefInfo.getClassName(); | ||||
| AntLibrary antLibrary = typeDefInfo.getAntLibrary(); | |||||
| ComponentLibrary componentLibrary | |||||
| = typeDefInfo.getComponentLibrary(); | |||||
| try { | try { | ||||
| ClassLoader typeClassLoader = antLibrary.getClassLoader(); | |||||
| ClassLoader typeClassLoader = componentLibrary.getClassLoader(); | |||||
| Class typeClass | Class typeClass | ||||
| = Class.forName(className, true, typeClassLoader); | = Class.forName(className, true, typeClassLoader); | ||||
| ClassLoader currentLoader = setContextLoader(typeClassLoader); | ClassLoader currentLoader = setContextLoader(typeClassLoader); | ||||
| AntLibFactory libFactory | AntLibFactory libFactory | ||||
| = componentManager.getLibFactory(antLibrary); | |||||
| = componentManager.getLibFactory(componentLibrary); | |||||
| Object typeInstance | Object typeInstance | ||||
| = createTypeInstance(typeClass, libFactory, model); | = createTypeInstance(typeClass, libFactory, model); | ||||
| setContextLoader(currentLoader); | setContextLoader(currentLoader); | ||||
| @@ -54,7 +54,7 @@ | |||||
| package org.apache.ant.antcore.execution; | package org.apache.ant.antcore.execution; | ||||
| import org.apache.ant.antcore.antlib.AntLibDefinition; | import org.apache.ant.antcore.antlib.AntLibDefinition; | ||||
| import org.apache.ant.antcore.antlib.AntLibrary; | |||||
| import org.apache.ant.antcore.antlib.ComponentLibrary; | |||||
| /** | /** | ||||
| * This class is used to maintain information about imports | * This class is used to maintain information about imports | ||||
| @@ -63,8 +63,8 @@ import org.apache.ant.antcore.antlib.AntLibrary; | |||||
| * @created 16 January 2002 | * @created 16 January 2002 | ||||
| */ | */ | ||||
| public class ImportInfo { | public class ImportInfo { | ||||
| /** the ant library from which the import is made */ | |||||
| private AntLibrary library; | |||||
| /** the component library from which the import is made */ | |||||
| private ComponentLibrary library; | |||||
| /** the library definition information */ | /** the library definition information */ | ||||
| private AntLibDefinition libDefinition; | private AntLibDefinition libDefinition; | ||||
| @@ -74,7 +74,8 @@ public class ImportInfo { | |||||
| * @param library The library from which the import was made | * @param library The library from which the import was made | ||||
| * @param libDefinition the library definition information | * @param libDefinition the library definition information | ||||
| */ | */ | ||||
| public ImportInfo(AntLibrary library, AntLibDefinition libDefinition) { | |||||
| public ImportInfo(ComponentLibrary library, | |||||
| AntLibDefinition libDefinition) { | |||||
| this.library = library; | this.library = library; | ||||
| this.libDefinition = libDefinition; | this.libDefinition = libDefinition; | ||||
| } | } | ||||
| @@ -93,7 +94,7 @@ public class ImportInfo { | |||||
| * | * | ||||
| * @return the library from which the import was made | * @return the library from which the import was made | ||||
| */ | */ | ||||
| public AntLibrary getAntLibrary() { | |||||
| public ComponentLibrary getComponentLibrary() { | |||||
| return library; | return library; | ||||
| } | } | ||||
| @@ -78,7 +78,7 @@ public class TaskContext extends ExecutionContext { | |||||
| * | * | ||||
| * @param frame the frame containing this context | * @param frame the frame containing this context | ||||
| */ | */ | ||||
| public TaskContext(ExecutionFrame frame) { | |||||
| public TaskContext(Frame frame) { | |||||
| super(frame); | super(frame); | ||||
| } | } | ||||
| @@ -82,13 +82,17 @@ public class Ant1Factory extends StandardLibFactory { | |||||
| * @exception ExecutionException if the factory cannot be initialised. | * @exception ExecutionException if the factory cannot be initialised. | ||||
| */ | */ | ||||
| public void init(AntContext context) throws ExecutionException { | public void init(AntContext context) throws ExecutionException { | ||||
| if (project != null) { | |||||
| return; | |||||
| } | |||||
| this.context = context; | this.context = context; | ||||
| // set the system classpath. In Ant2, the system classpath will not | // set the system classpath. In Ant2, the system classpath will not | ||||
| // in general, have any useful information. For Ant1 compatability | // in general, have any useful information. For Ant1 compatability | ||||
| // we set it now to include the Ant1 facade classes | // we set it now to include the Ant1 facade classes | ||||
| System.setProperty("java.class.path", getAnt1Classpath()); | System.setProperty("java.class.path", getAnt1Classpath()); | ||||
| project = new Project(); | |||||
| project = new Project(this); | |||||
| project.init(context); | project.init(context); | ||||
| EventService eventService = | EventService eventService = | ||||
| @@ -63,6 +63,7 @@ import java.util.Properties; | |||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.ant.common.antlib.AntContext; | import org.apache.ant.common.antlib.AntContext; | ||||
| import org.apache.ant.common.antlib.AntLibFactory; | |||||
| import org.apache.ant.common.service.ComponentService; | import org.apache.ant.common.service.ComponentService; | ||||
| import org.apache.ant.common.service.DataService; | import org.apache.ant.common.service.DataService; | ||||
| import org.apache.ant.common.service.FileService; | import org.apache.ant.common.service.FileService; | ||||
| @@ -116,6 +117,10 @@ public class Project implements org.apache.ant.common.event.BuildListener { | |||||
| /** The java version detected that Ant is running on */ | /** The java version detected that Ant is running on */ | ||||
| private static String javaVersion; | private static String javaVersion; | ||||
| /** the factory which created this project instance. This is used to | |||||
| define new types and tasks */ | |||||
| private AntLibFactory factory; | |||||
| /** Collection of Ant1 type definitions */ | /** Collection of Ant1 type definitions */ | ||||
| private Hashtable dataClassDefinitions = new Hashtable(); | private Hashtable dataClassDefinitions = new Hashtable(); | ||||
| /** Collection of Ant1 task definitions */ | /** Collection of Ant1 task definitions */ | ||||
| @@ -175,8 +180,13 @@ public class Project implements org.apache.ant.common.event.BuildListener { | |||||
| } | } | ||||
| } | } | ||||
| /** Create the project */ | |||||
| public Project() { | |||||
| /** | |||||
| * Create the project | |||||
| * | |||||
| * @param factory the factory object creating this project | |||||
| */ | |||||
| public Project(AntLibFactory factory) { | |||||
| this.factory = factory; | |||||
| fileUtils = FileUtils.newFileUtils(); | fileUtils = FileUtils.newFileUtils(); | ||||
| } | } | ||||
| @@ -468,6 +478,8 @@ public class Project implements org.apache.ant.common.event.BuildListener { | |||||
| * @param event target finished event | * @param event target finished event | ||||
| */ | */ | ||||
| public void targetFinished(org.apache.ant.common.event.BuildEvent event) { | public void targetFinished(org.apache.ant.common.event.BuildEvent event) { | ||||
| org.apache.ant.common.model.Target realTarget = | |||||
| (org.apache.ant.common.model.Target)event.getModelElement(); | |||||
| Target currentTarget = (Target)targetStack.pop(); | Target currentTarget = (Target)targetStack.pop(); | ||||
| fireTargetFinished(currentTarget, event.getCause()); | fireTargetFinished(currentTarget, event.getCause()); | ||||
| currentTarget = null; | currentTarget = null; | ||||
| @@ -818,7 +830,8 @@ public class Project implements org.apache.ant.common.event.BuildListener { | |||||
| public void addTaskDefinition(String taskName, Class taskClass) | public void addTaskDefinition(String taskName, Class taskClass) | ||||
| throws BuildException { | throws BuildException { | ||||
| try { | try { | ||||
| componentService.taskdef(taskName, taskClass); | |||||
| componentService.taskdef(factory, taskClass.getClassLoader(), | |||||
| taskName, taskClass.getName()); | |||||
| taskClassDefinitions.put(taskName, taskClass); | taskClassDefinitions.put(taskName, taskClass); | ||||
| } catch (ExecutionException e) { | } catch (ExecutionException e) { | ||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| @@ -833,7 +846,8 @@ public class Project implements org.apache.ant.common.event.BuildListener { | |||||
| */ | */ | ||||
| public void addDataTypeDefinition(String typeName, Class typeClass) { | public void addDataTypeDefinition(String typeName, Class typeClass) { | ||||
| try { | try { | ||||
| componentService.typedef(typeName, typeClass); | |||||
| componentService.typedef(factory, typeClass.getClassLoader(), | |||||
| typeName, typeClass.getName()); | |||||
| dataClassDefinitions.put(typeName, typeClass); | dataClassDefinitions.put(typeName, typeClass); | ||||
| } catch (ExecutionException e) { | } catch (ExecutionException e) { | ||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| @@ -53,7 +53,7 @@ | |||||
| */ | */ | ||||
| package org.apache.ant.antlib.system; | package org.apache.ant.antlib.system; | ||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.ant.common.service.ComponentService; | |||||
| import org.apache.ant.common.service.ExecService; | |||||
| import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
| /** | /** | ||||
| @@ -113,10 +113,10 @@ public class Ant extends AntBase { | |||||
| } | } | ||||
| } | } | ||||
| ComponentService componentService | |||||
| = (ComponentService)getCoreService(ComponentService.class); | |||||
| ExecService execService | |||||
| = (ExecService)getCoreService(ExecService.class); | |||||
| componentService.runBuild(antFile, getProperties(), getTargets()); | |||||
| execService.runBuild(antFile, getProperties(), getTargets()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -52,7 +52,7 @@ | |||||
| * <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
| */ | */ | ||||
| package org.apache.ant.antlib.system; | package org.apache.ant.antlib.system; | ||||
| import org.apache.ant.common.service.ComponentService; | |||||
| import org.apache.ant.common.service.ExecService; | |||||
| import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
| /** | /** | ||||
| @@ -68,10 +68,10 @@ public class AntCall extends AntBase { | |||||
| * @exception ExecutionException if the build fails | * @exception ExecutionException if the build fails | ||||
| */ | */ | ||||
| public void execute() throws ExecutionException { | public void execute() throws ExecutionException { | ||||
| ComponentService componentService | |||||
| = (ComponentService)getCoreService(ComponentService.class); | |||||
| componentService.callTarget(getProperties(), getTargets()); | |||||
| ExecService execService | |||||
| = (ExecService)getCoreService(ExecService.class); | |||||
| execService.callTarget(getProperties(), getTargets()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -58,7 +58,7 @@ import org.apache.ant.common.model.ModelElement; | |||||
| /** | /** | ||||
| * A BuildEvent indicates the occurence of a significant event in the build. | * A BuildEvent indicates the occurence of a significant event in the build. | ||||
| * All build events come from an ExecutionFrame or an ExecutionManager. | |||||
| * All build events come from an Frame or an ExecutionManager. | |||||
| * There are a number of different types of event and they will generally be | * There are a number of different types of event and they will generally be | ||||
| * associated with some build element from the build model. | * associated with some build element from the build model. | ||||
| * | * | ||||
| @@ -52,10 +52,7 @@ | |||||
| * <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
| */ | */ | ||||
| package org.apache.ant.common.service; | package org.apache.ant.common.service; | ||||
| import java.io.File; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import org.apache.ant.common.model.Project; | |||||
| import org.apache.ant.common.antlib.AntLibFactory; | |||||
| import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
| /** | /** | ||||
| @@ -85,56 +82,30 @@ public interface ComponentService { | |||||
| void loadLib(String libLocation, boolean importAll) | void loadLib(String libLocation, boolean importAll) | ||||
| throws ExecutionException; | throws ExecutionException; | ||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param antFile the file containing the XML description of the model | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| void runBuild(File antFile, Map properties, List targets) | |||||
| throws ExecutionException; | |||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param model the project model to be used for the build | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| void runBuild(Project model, Map properties, List targets) | |||||
| throws ExecutionException; | |||||
| /** | |||||
| * Run a sub-build using the current frame's project model | |||||
| * | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| void callTarget(Map properties, List targets) | |||||
| throws ExecutionException; | |||||
| /** | /** | ||||
| * Experimental - define a new type | * Experimental - define a new type | ||||
| * | * | ||||
| * @param typeName the name by which this type will be referred | * @param typeName the name by which this type will be referred | ||||
| * @param typeClass the class of the type | |||||
| * @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 | * @exception ExecutionException if the type cannot be defined | ||||
| */ | */ | ||||
| void typedef(String typeName, Class typeClass) | |||||
| void typedef(AntLibFactory factory, ClassLoader loader, | |||||
| String typeName, String className) | |||||
| throws ExecutionException; | throws ExecutionException; | ||||
| /** | /** | ||||
| * Experimental - define a new task | * Experimental - define a new task | ||||
| * | * | ||||
| * @param taskName the name by which this task will be referred | * @param taskName the name by which this task will be referred | ||||
| * @param taskClass the class of the task | |||||
| * @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 | * @exception ExecutionException if the task cannot be defined | ||||
| */ | */ | ||||
| void taskdef(String taskName, Class taskClass) | |||||
| void taskdef(AntLibFactory factory, ClassLoader loader, | |||||
| String taskName, String className) | |||||
| throws ExecutionException; | throws ExecutionException; | ||||
| } | } | ||||
| @@ -0,0 +1,101 @@ | |||||
| /* | |||||
| * 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 java.io.File; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import org.apache.ant.common.model.Project; | |||||
| import org.apache.ant.common.util.ExecutionException; | |||||
| /** | |||||
| * The ExecService provides executiuon services to tasks | |||||
| * | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||||
| * @created 8 February 2002 | |||||
| */ | |||||
| public interface ExecService { | |||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param antFile the file containing the XML description of the model | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| void runBuild(File antFile, Map properties, List targets) | |||||
| throws ExecutionException; | |||||
| /** | |||||
| * Run a sub-build. | |||||
| * | |||||
| * @param model the project model to be used for the build | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| void runBuild(Project model, Map properties, List targets) | |||||
| throws ExecutionException; | |||||
| /** | |||||
| * Run a sub-build using the current frame's project model | |||||
| * | |||||
| * @param targets A list of targets to be run | |||||
| * @param properties the initiali properties to be used in the build | |||||
| * @exception ExecutionException if the subbuild cannot be run | |||||
| */ | |||||
| void callTarget(Map properties, List targets) | |||||
| throws ExecutionException; | |||||
| } | |||||