git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272820 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -96,6 +96,8 @@ | |||||
| <exclude name="org/apache/tools/ant/taskdefs/JavaTest.java"/> | <exclude name="org/apache/tools/ant/taskdefs/JavaTest.java"/> | ||||
| <exclude name="org/apache/tools/ant/taskdefs/JavacTest.java"/> | <exclude name="org/apache/tools/ant/taskdefs/JavacTest.java"/> | ||||
| <exclude name="org/apache/tools/ant/taskdefs/TStampTest.java"/> | <exclude name="org/apache/tools/ant/taskdefs/TStampTest.java"/> | ||||
| <exclude name="org/apache/tools/ant/taskdefs/TaskdefTest.java"/> | |||||
| <exclude name="org/apache/tools/ant/taskdefs/TypedefTest.java"/> | |||||
| </patternset> | </patternset> | ||||
| <fileset id="ant1src_tocopy" dir="${ant1java.dir}"> | <fileset id="ant1src_tocopy" dir="${ant1java.dir}"> | ||||
| @@ -1,4 +1,4 @@ | |||||
| <project name="build-site" default="docs" basedir="."> | |||||
| <project name="build-site" default="docs" basedir=".."> | |||||
| <!-- Initialization properties --> | <!-- Initialization properties --> | ||||
| <property name="project.name" value="mutant"/> | <property name="project.name" value="mutant"/> | ||||
| @@ -15,8 +15,8 @@ | |||||
| </fileset> | </fileset> | ||||
| </path> | </path> | ||||
| <target name="prepare"> | |||||
| <available classname="org.apache.velocity.anakia.AnakiaTask" | |||||
| <target name="prepare"> | |||||
| <available classname="org.apache.velocity.anakia.AnakiaTask" | |||||
| property="AnakiaTask.present"> | property="AnakiaTask.present"> | ||||
| <classpath refid="anakia.classpath"/> | <classpath refid="anakia.classpath"/> | ||||
| </available> | </available> | ||||
| @@ -24,7 +24,7 @@ | |||||
| <target depends="prepare" name="prepare-error" unless="AnakiaTask.present"> | <target depends="prepare" name="prepare-error" unless="AnakiaTask.present"> | ||||
| <echo> | <echo> | ||||
| AnakiaTask is not present! Please check to make sure that | |||||
| AnakiaTask is not present! Please check to make sure that | |||||
| velocity.jar is in your classpath. | velocity.jar is in your classpath. | ||||
| </echo> | </echo> | ||||
| </target> | </target> | ||||
| @@ -33,7 +33,7 @@ | |||||
| <taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask"> | <taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask"> | ||||
| <classpath refid="anakia.classpath"/> | <classpath refid="anakia.classpath"/> | ||||
| </taskdef> | </taskdef> | ||||
| <anakia basedir="${docs.src}" destdir="${docs.dest}/" | <anakia basedir="${docs.src}" destdir="${docs.dest}/" | ||||
| extension=".html" style="./site.vsl" | extension=".html" style="./site.vsl" | ||||
| projectFile="${project.file}" | projectFile="${project.file}" | ||||
| @@ -44,6 +44,6 @@ | |||||
| velocityPropertiesFile="${velocity.props}"> | velocityPropertiesFile="${velocity.props}"> | ||||
| </anakia> | </anakia> | ||||
| </target> | </target> | ||||
| <target name="all" depends="docs"/> | <target name="all" depends="docs"/> | ||||
| </project> | </project> | ||||
| @@ -9,6 +9,7 @@ | |||||
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> | ||||
| <meta name="author" value="Conor MacNeill"> | <meta name="author" value="Conor MacNeill"> | ||||
| <meta name="email" value=""> | |||||
| <title>The Jakarta Site - Mutant Design Notes</title> | <title>The Jakarta Site - Mutant Design Notes</title> | ||||
| </head> | </head> | ||||
| @@ -53,6 +53,7 @@ | |||||
| */ | */ | ||||
| package org.apache.ant.antcore.antlib; | package org.apache.ant.antcore.antlib; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.File; | |||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| @@ -248,7 +249,6 @@ public class AntLibManager { | |||||
| */ | */ | ||||
| public void addLibPath(String libraryId, URL libPath) | public void addLibPath(String libraryId, URL libPath) | ||||
| throws AntLibException { | throws AntLibException { | ||||
| System.out.println("Adding path " + libPath + " for " + libraryId); | |||||
| if (!libPath.getProtocol().equals("file") | if (!libPath.getProtocol().equals("file") | ||||
| && !remoteAllowed) { | && !remoteAllowed) { | ||||
| throw new AntLibException("Remote libpaths are not" | throw new AntLibException("Remote libpaths are not" | ||||
| @@ -260,11 +260,31 @@ public class AntLibManager { | |||||
| libPaths = new ArrayList(); | libPaths = new ArrayList(); | ||||
| libPathsMap.put(libraryId, libPaths); | libPathsMap.put(libraryId, libPaths); | ||||
| } | } | ||||
| libPaths.add(libPath); | |||||
| List newPaths = new ArrayList(); | |||||
| newPaths.add(libPath); | |||||
| if (libPath.getProtocol().equals("file")) { | |||||
| File dir = new File(libPath.getFile()); | |||||
| if (dir.isDirectory()) { | |||||
| try { | |||||
| URL[] pathURLs = LoaderUtils.getLocationURLs(libPath, | |||||
| null, ANTLIB_EXTENSIONS); | |||||
| for (int i = 0; i < pathURLs.length; ++i) { | |||||
| newPaths.add(pathURLs[i]); | |||||
| } | |||||
| } catch (MalformedURLException e) { | |||||
| // ignore and just use what we were given | |||||
| } | |||||
| } | |||||
| } | |||||
| AntLibrary antLibrary = getLibrary(libraryId); | AntLibrary antLibrary = getLibrary(libraryId); | ||||
| if (antLibrary != null) { | |||||
| antLibrary.addLibraryURL(libPath); | |||||
| for (Iterator i = newPaths.iterator(); i.hasNext();) { | |||||
| URL newPath = (URL) i.next(); | |||||
| libPaths.add(newPath); | |||||
| if (antLibrary != null) { | |||||
| antLibrary.addLibraryURL(newPath); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -435,37 +435,18 @@ public class ComponentManager implements ComponentService { | |||||
| private Object createComponent(String componentName, BuildElement model) | private Object createComponent(String componentName, BuildElement model) | ||||
| throws AntException { | throws AntException { | ||||
| Object component = null; | |||||
| if (model != null) { | |||||
| for (Iterator i = aspects.iterator(); i.hasNext();) { | |||||
| Aspect aspect = (Aspect) i.next(); | |||||
| component = aspect.preCreateComponent(component, model); | |||||
| } | |||||
| ImportInfo importInfo = getImport(componentName); | |||||
| if (importInfo == null) { | |||||
| throw new ExecutionException("There is no definition of the <" | |||||
| + componentName + "> component"); | |||||
| } | } | ||||
| String className = importInfo.getClassName(); | |||||
| if (component == null) { | |||||
| ImportInfo importInfo = getImport(componentName); | |||||
| if (importInfo == null) { | |||||
| throw new ExecutionException("There is no definition of the <" | |||||
| + componentName + "> component"); | |||||
| } | |||||
| String className = importInfo.getClassName(); | |||||
| ComponentLibrary componentLibrary | |||||
| ComponentLibrary componentLibrary | |||||
| = importInfo.getComponentLibrary(); | = importInfo.getComponentLibrary(); | ||||
| component = createComponentFromDef(componentName, componentLibrary, | |||||
| importInfo.getDefinition(), model); | |||||
| } | |||||
| if (model != null) { | |||||
| for (Iterator i = aspects.iterator(); i.hasNext();) { | |||||
| Aspect aspect = (Aspect) i.next(); | |||||
| component = aspect.postCreateComponent(component, model); | |||||
| } | |||||
| } | |||||
| return component; | |||||
| return createComponentFromDef(componentName, componentLibrary, | |||||
| importInfo.getDefinition(), model); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -486,22 +467,36 @@ public class ComponentManager implements ComponentService { | |||||
| throws AntException { | throws AntException { | ||||
| Location location = Location.UNKNOWN_LOCATION; | 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(); | |||||
| String className = null; | |||||
| try { | try { | ||||
| ClassLoader componentLoader = componentLibrary.getClassLoader(); | |||||
| Class componentClass | |||||
| = Class.forName(className, true, componentLoader); | |||||
| boolean isTask | |||||
| = libDefinition.getDefinitionType() == AntLibrary.TASKDEF; | |||||
| Object component = null; | |||||
| if (model != null) { | |||||
| location = model.getLocation(); | |||||
| for (Iterator i = aspects.iterator(); i.hasNext();) { | |||||
| Aspect aspect = (Aspect) i.next(); | |||||
| component = aspect.preCreateComponent(component, model); | |||||
| } | |||||
| } | |||||
| AntLibFactory libFactory = getLibFactory(componentLibrary); | AntLibFactory libFactory = getLibFactory(componentLibrary); | ||||
| // create the component using the factory | |||||
| Object component | |||||
| = libFactory.createComponent(componentClass, localName); | |||||
| ClassLoader componentLoader = null; | |||||
| if (component == null) { | |||||
| String localName = libDefinition.getDefinitionName(); | |||||
| className = libDefinition.getClassName(); | |||||
| componentLoader = componentLibrary.getClassLoader(); | |||||
| Class componentClass | |||||
| = Class.forName(className, true, componentLoader); | |||||
| // create the component using the factory | |||||
| component | |||||
| = libFactory.createComponent(componentClass, localName); | |||||
| } else { | |||||
| className = component.getClass().getName(); | |||||
| componentLoader = component.getClass().getClassLoader(); | |||||
| } | |||||
| // wrap the component in an adapter if required. | // wrap the component in an adapter if required. | ||||
| ExecutionComponent execComponent = null; | ExecutionComponent execComponent = null; | ||||
| @@ -522,10 +517,13 @@ public class ComponentManager implements ComponentService { | |||||
| // if the component is an execution component create a context and | // if the component is an execution component create a context and | ||||
| // initialise the component with it. | // initialise the component with it. | ||||
| if (execComponent != null) { | if (execComponent != null) { | ||||
| ExecutionContext context | |||||
| = new ExecutionContext(frame, execComponent, model); | |||||
| context.setClassLoader(componentLoader); | |||||
| execComponent.init(context, componentName); | |||||
| // give it a context unless it already has one | |||||
| if (execComponent.getAntContext() == null) { | |||||
| ExecutionContext context | |||||
| = new ExecutionContext(frame, execComponent, model); | |||||
| context.setClassLoader(componentLoader); | |||||
| execComponent.init(context, componentName); | |||||
| } | |||||
| } | } | ||||
| // if we have a model, use it to configure the component. Otherwise | // if we have a model, use it to configure the component. Otherwise | ||||
| @@ -537,6 +535,10 @@ public class ComponentManager implements ComponentService { | |||||
| if (execComponent != null) { | if (execComponent != null) { | ||||
| execComponent.validateComponent(); | execComponent.validateComponent(); | ||||
| } | } | ||||
| for (Iterator i = aspects.iterator(); i.hasNext();) { | |||||
| Aspect aspect = (Aspect) i.next(); | |||||
| component = aspect.postCreateComponent(component, model); | |||||
| } | |||||
| } | } | ||||
| // reset the loader | // reset the loader | ||||
| @@ -175,7 +175,7 @@ public class ExecutionContext implements AntContext { | |||||
| * | * | ||||
| * @return the build model or null if there is no build model. | * @return the build model or null if there is no build model. | ||||
| */ | */ | ||||
| protected BuildElement getModel() { | |||||
| public BuildElement getModel() { | |||||
| return model; | return model; | ||||
| } | } | ||||
| } | } | ||||
| @@ -973,14 +973,15 @@ public class Frame implements DemuxOutputReceiver { | |||||
| failureCause | failureCause | ||||
| = aspect.postExecuteTask(aspectContext, failureCause); | = aspect.postExecuteTask(aspectContext, failureCause); | ||||
| } | } | ||||
| eventSupport.fireTaskFinished(task, failureCause); | eventSupport.fireTaskFinished(task, failureCause); | ||||
| if (aspectContexts.size() != 0) { | if (aspectContexts.size() != 0) { | ||||
| aspectContextsMap.remove(task); | aspectContextsMap.remove(task); | ||||
| } | } | ||||
| if (failureCause != null) { | if (failureCause != null) { | ||||
| if (failureCause instanceof ExecutionException) { | |||||
| throw (ExecutionException) failureCause; | |||||
| if (failureCause instanceof AntException) { | |||||
| throw (AntException) failureCause; | |||||
| } | } | ||||
| throw new ExecutionException(failureCause); | throw new ExecutionException(failureCause); | ||||
| } | } | ||||
| @@ -1156,7 +1157,8 @@ public class Frame implements DemuxOutputReceiver { | |||||
| // load system ant lib | // load system ant lib | ||||
| URL systemLibs | URL systemLibs | ||||
| = new URL(initConfig.getLibraryURL(), "syslibs/"); | = new URL(initConfig.getLibraryURL(), "syslibs/"); | ||||
| componentManager.loadLib(systemLibs, true); | |||||
| componentManager.loadLib(systemLibs, false); | |||||
| importStandardComponents(); | |||||
| executeTasks(config.getGlobalTasks()); | executeTasks(config.getGlobalTasks()); | ||||
| @@ -1164,12 +1166,12 @@ public class Frame implements DemuxOutputReceiver { | |||||
| URL antLibs = new URL(initConfig.getLibraryURL(), "antlibs/"); | URL antLibs = new URL(initConfig.getLibraryURL(), "antlibs/"); | ||||
| componentManager.loadLib(antLibs, false); | componentManager.loadLib(antLibs, false); | ||||
| } catch (MalformedURLException e) { | |||||
| throw new ExecutionException("Unable to initialize antlibs", e); | |||||
| } | |||||
| try { | |||||
| runBuild(targets); | runBuild(targets); | ||||
| } catch (MalformedURLException e) { | |||||
| ExecutionException ee = | |||||
| new ExecutionException("Unable to initialize antlibs", e); | |||||
| buildFailureCause = ee; | |||||
| throw ee; | |||||
| } catch (RuntimeException e) { | } catch (RuntimeException e) { | ||||
| buildFailureCause = e; | buildFailureCause = e; | ||||
| throw e; | throw e; | ||||
| @@ -57,7 +57,7 @@ import org.apache.ant.common.antlib.StandardLibFactory; | |||||
| import org.apache.ant.common.service.EventService; | import org.apache.ant.common.service.EventService; | ||||
| import org.apache.ant.common.util.AntException; | import org.apache.ant.common.util.AntException; | ||||
| import org.apache.ant.init.LoaderUtils; | import org.apache.ant.init.LoaderUtils; | ||||
| import java.lang.reflect.InvocationTargetException; | |||||
| /** | /** | ||||
| * The factory object for the Ant1 compatability Ant library | * The factory object for the Ant1 compatability Ant library | ||||
| * | * | ||||
| @@ -132,7 +132,7 @@ public class Ant1Factory extends StandardLibFactory { | |||||
| ((ProjectComponent) component).setProject(project); | ((ProjectComponent) component).setProject(project); | ||||
| } | } | ||||
| return component; | return component; | ||||
| } catch (java.lang.reflect.InvocationTargetException ite) { | |||||
| } catch (InvocationTargetException ite) { | |||||
| Throwable t = ite.getTargetException(); | Throwable t = ite.getTargetException(); | ||||
| String msg = "Could not create component of type: " | String msg = "Could not create component of type: " | ||||
| + componentClass.getName() + " due to " + t; | + componentClass.getName() + " due to " + t; | ||||
| @@ -55,6 +55,7 @@ package org.apache.ant.antlib.monitor; | |||||
| import org.apache.ant.common.antlib.AbstractAspect; | import org.apache.ant.common.antlib.AbstractAspect; | ||||
| import org.apache.ant.common.antlib.Task; | import org.apache.ant.common.antlib.Task; | ||||
| import org.apache.ant.common.antlib.AntContext; | |||||
| import org.apache.ant.common.model.BuildElement; | import org.apache.ant.common.model.BuildElement; | ||||
| import org.apache.ant.common.model.AspectValueCollection; | import org.apache.ant.common.model.AspectValueCollection; | ||||
| import org.apache.ant.common.util.AntException; | import org.apache.ant.common.util.AntException; | ||||
| @@ -71,70 +72,25 @@ import java.io.IOException; | |||||
| * @author Conor MacNeill | * @author Conor MacNeill | ||||
| */ | */ | ||||
| public class MonitorAspect extends AbstractAspect { | public class MonitorAspect extends AbstractAspect { | ||||
| /** The log into which monitoring info is written */ | |||||
| private static PrintStream monitorLog; | private static PrintStream monitorLog; | ||||
| private static long lastMessageTime; | |||||
| public MonitorAspect() { | |||||
| if (monitorLog == null) { | |||||
| try { | |||||
| monitorLog | |||||
| = new PrintStream(new FileOutputStream("monitor.log")); | |||||
| monitorLog.println("Logging started at " + new Date()); | |||||
| lastMessageTime = System.currentTimeMillis(); | |||||
| } catch (IOException e) { | |||||
| log("Unable to open monitor log", MessageLevel.MSG_WARN); | |||||
| } | |||||
| } | |||||
| } | |||||
| private void monitor(String message) { | |||||
| Runtime rt = Runtime.getRuntime(); | |||||
| synchronized (monitorLog) { | |||||
| long now = System.currentTimeMillis(); | |||||
| long diff = now - lastMessageTime; | |||||
| lastMessageTime = now; | |||||
| long freeMem = rt.freeMemory(); | |||||
| long usedMem = rt.totalMemory() - freeMem; | |||||
| monitorLog.println("+" + diff + " (" + usedMem + "/" | |||||
| + freeMem + "): " + message); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * This join point is activated before a component is to be created. | |||||
| * The aspect can return an object to be used rather than the core creating | |||||
| * the object. | |||||
| * | |||||
| * @param component the component that has been created. This will be null | |||||
| * unless another aspect has created the component | |||||
| * @param model the Build model that applies to the component | |||||
| * | |||||
| * @return a component to use. | |||||
| * @exception AntException if the aspect cannot process the component. | |||||
| */ | |||||
| public Object preCreateComponent(Object component, BuildElement model) | |||||
| throws AntException { | |||||
| monitor("Creating component " + "from <" + model.getType() + ">"); | |||||
| return component; | |||||
| } | |||||
| /** | /** | ||||
| * 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 AntException if the aspect cannot process the component. | |||||
| * Create a monitoring aspect instance. There will be one instance per | |||||
| * active frame but they all share the same log output. | |||||
| */ | */ | ||||
| public Object postCreateComponent(Object component, BuildElement model) | |||||
| throws AntException { | |||||
| monitor("Created component " | |||||
| + component.getClass().getName() | |||||
| + " from <" + model.getType() + ">"); | |||||
| return component; | |||||
| public MonitorAspect() { | |||||
| synchronized (MonitorAspect.class) { | |||||
| if (monitorLog == null) { | |||||
| try { | |||||
| monitorLog | |||||
| = new PrintStream(new FileOutputStream("monitor.log")); | |||||
| monitorLog.println("Logging started at " + new Date()); | |||||
| } catch (IOException e) { | |||||
| log("Unable to open monitor log", MessageLevel.MSG_WARN); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -152,9 +108,12 @@ public class MonitorAspect extends AbstractAspect { | |||||
| */ | */ | ||||
| public Object preExecuteTask(Task task, AspectValueCollection aspectValues) | public Object preExecuteTask(Task task, AspectValueCollection aspectValues) | ||||
| throws AntException { | throws AntException { | ||||
| String taskName = task.getClass().getName(); | |||||
| MonitorRecord record = new MonitorRecord(taskName); | |||||
| return record; | |||||
| System.gc(); | |||||
| AntContext taskContext = task.getAntContext(); | |||||
| BuildElement model = taskContext.getModel(); | |||||
| String name = (model == null) ? task.getClass().getName() | |||||
| : model.getType(); | |||||
| return new MonitorRecord(name, taskContext.getLocation()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -167,10 +126,9 @@ public class MonitorAspect extends AbstractAspect { | |||||
| * @return a new failure reason or null if the task is not to fail. | * @return a new failure reason or null if the task is not to fail. | ||||
| */ | */ | ||||
| public Throwable postExecuteTask(Object context, Throwable failureCause) { | public Throwable postExecuteTask(Object context, Throwable failureCause) { | ||||
| MonitorRecord record = (MonitorRecord)context; | |||||
| record.print(monitorLog); | |||||
| MonitorRecord record = (MonitorRecord) context; | |||||
| System.gc(); | System.gc(); | ||||
| record.print(monitorLog); | |||||
| return failureCause; | return failureCause; | ||||
| } | } | ||||
| } | } | ||||
| @@ -53,16 +53,8 @@ | |||||
| */ | */ | ||||
| package org.apache.ant.antlib.monitor; | package org.apache.ant.antlib.monitor; | ||||
| import org.apache.ant.common.antlib.AbstractAspect; | |||||
| import org.apache.ant.common.antlib.Task; | |||||
| import org.apache.ant.common.model.BuildElement; | |||||
| import org.apache.ant.common.model.AspectValueCollection; | |||||
| import org.apache.ant.common.util.AntException; | |||||
| import org.apache.ant.common.event.MessageLevel; | |||||
| import java.util.Date; | |||||
| import org.apache.ant.common.util.Location; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | |||||
| /** | /** | ||||
| * A record of some performance values at a particular time | * A record of some performance values at a particular time | ||||
| @@ -70,25 +62,51 @@ import java.io.IOException; | |||||
| * @author Conor MacNeill | * @author Conor MacNeill | ||||
| */ | */ | ||||
| public class MonitorRecord { | public class MonitorRecord { | ||||
| private String recordName; | |||||
| /** The element name being monitored */ | |||||
| private String elementName; | |||||
| /** The location in the build file */ | |||||
| private Location location; | |||||
| /** System clock when task started */ | |||||
| private long startMillis; | private long startMillis; | ||||
| /** Starting memory when task started */ | |||||
| private long startMemory; | private long startMemory; | ||||
| /** | |||||
| * Get the current used memory from the runtime | |||||
| * | |||||
| * @return the amount of memory in use. | |||||
| */ | |||||
| private long getMemoryUsage() { | private long getMemoryUsage() { | ||||
| Runtime rt = Runtime.getRuntime(); | Runtime rt = Runtime.getRuntime(); | ||||
| return rt.totalMemory() - rt.freeMemory(); | return rt.totalMemory() - rt.freeMemory(); | ||||
| } | } | ||||
| public MonitorRecord(String recordName) { | |||||
| this.recordName = recordName; | |||||
| /** | |||||
| * Create a monitoring record. | |||||
| * | |||||
| * @param elementName the name of the element. | |||||
| * @param location the build file location of the element. | |||||
| */ | |||||
| public MonitorRecord(String elementName, Location location) { | |||||
| this.elementName = elementName; | |||||
| this.location = location; | |||||
| startMillis = System.currentTimeMillis(); | startMillis = System.currentTimeMillis(); | ||||
| startMemory = getMemoryUsage(); | startMemory = getMemoryUsage(); | ||||
| } | } | ||||
| /** | |||||
| * Print a summary of the monitor | |||||
| * | |||||
| * @param stream the stream onto which the summary is printed. | |||||
| */ | |||||
| public void print(PrintStream stream) { | public void print(PrintStream stream) { | ||||
| long timeDiff = System.currentTimeMillis() - startMillis; | long timeDiff = System.currentTimeMillis() - startMillis; | ||||
| long memDiff = getMemoryUsage() - startMemory; | long memDiff = getMemoryUsage() - startMemory; | ||||
| stream.println(recordName + " took " + timeDiff | |||||
| + " milliseconds and memory used changed by " + memDiff); | |||||
| stream.println(location + elementName + " took " + timeDiff | |||||
| + " milliseconds, memory used at start " + startMemory | |||||
| + " which changed by " + memDiff); | |||||
| } | } | ||||
| } | } | ||||
| @@ -54,6 +54,7 @@ | |||||
| package org.apache.ant.common.antlib; | package org.apache.ant.common.antlib; | ||||
| import org.apache.ant.common.util.AntException; | import org.apache.ant.common.util.AntException; | ||||
| import org.apache.ant.common.util.Location; | import org.apache.ant.common.util.Location; | ||||
| import org.apache.ant.common.model.BuildElement; | |||||
| /** | /** | ||||
| * The AntContext is the interface through which the Ant container and the | * The AntContext is the interface through which the Ant container and the | ||||
| @@ -91,5 +92,13 @@ public interface AntContext { | |||||
| * @return the location which may be the unknown location | * @return the location which may be the unknown location | ||||
| */ | */ | ||||
| Location getLocation(); | Location getLocation(); | ||||
| /** | |||||
| * Get the build model associated with this context if any | |||||
| * | |||||
| * @return the build model which may be null if there is no associated | |||||
| * model | |||||
| */ | |||||
| BuildElement getModel(); | |||||
| } | } | ||||
| @@ -80,6 +80,10 @@ public class BuildEvent extends EventObject { | |||||
| public static final int TASK_FINISHED = 6; | public static final int TASK_FINISHED = 6; | ||||
| /** message event type */ | /** message event type */ | ||||
| public static final int MESSAGE = 7; | public static final int MESSAGE = 7; | ||||
| /** Project started event type */ | |||||
| public static final int PROJECT_STARTED = 8; | |||||
| /** Project finished event type */ | |||||
| public static final int PROJECT_FINISHED = 9; | |||||
| /** The type of this event */ | /** The type of this event */ | ||||
| private int eventType; | private int eventType; | ||||
| @@ -57,6 +57,7 @@ import java.io.PrintStream; | |||||
| import org.apache.ant.common.antlib.ExecutionComponent; | import org.apache.ant.common.antlib.ExecutionComponent; | ||||
| import org.apache.ant.common.antlib.Task; | import org.apache.ant.common.antlib.Task; | ||||
| import org.apache.ant.common.event.BuildEvent; | import org.apache.ant.common.event.BuildEvent; | ||||
| import org.apache.ant.common.event.BuildListenerAdapter; | |||||
| import org.apache.ant.common.event.MessageLevel; | import org.apache.ant.common.event.MessageLevel; | ||||
| import org.apache.ant.common.model.Target; | import org.apache.ant.common.model.Target; | ||||
| import org.apache.ant.common.util.AntException; | import org.apache.ant.common.util.AntException; | ||||
| @@ -69,7 +70,7 @@ import org.apache.ant.common.util.Location; | |||||
| * @author Conor MacNeill | * @author Conor MacNeill | ||||
| * @created 15 January 2002 | * @created 15 January 2002 | ||||
| */ | */ | ||||
| public class DefaultLogger implements BuildLogger { | |||||
| public class DefaultLogger extends BuildListenerAdapter implements BuildLogger { | |||||
| /** Standard field separator */ | /** Standard field separator */ | ||||
| private static String lSep = System.getProperty("line.separator"); | private static String lSep = System.getProperty("line.separator"); | ||||