You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2001/07/11 11:58:12 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant AntClassLoader.java IntrospectionHelper.java ProjectHelper.java
bodewig 01/07/11 02:58:12
Modified: src/main/org/apache/tools/ant AntClassLoader.java
IntrospectionHelper.java ProjectHelper.java
Log:
help the garbage collector by cleaning out references in
AntClassLoader and IntrospectionHelper after the build has finished.
This helps applications that run Ant in the same VM over and over
again like CruiseControl or wrappers that run Ant in incremental mode.
PR: 2568
Submitted by: robert.watkins@qsipayments.com (Robert Watkins)
Revision Changes Path
1.25 +24 -1 jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java
Index: AntClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- AntClassLoader.java 2001/07/11 06:50:45 1.24
+++ AntClassLoader.java 2001/07/11 09:58:07 1.25
@@ -70,7 +70,7 @@
* @author <a href="mailto:conor@cortexebusiness.com.au">Conor MacNeill</a>
* @author <a href="mailto:Jesse.Glick@netbeans.com">Jesse Glick</a>
*/
-public class AntClassLoader extends ClassLoader {
+public class AntClassLoader extends ClassLoader implements BuildListener {
/**
* An enumeration of all resources of a given name found within the
@@ -228,6 +228,7 @@
*/
public AntClassLoader(Project project, Path classpath) {
this.project = project;
+ this.project.addBuildListener(this);
this.classpath = classpath.concatSystemClasspath("ignore");
}
@@ -838,5 +839,27 @@
else {
return base.loadClass(name);
}
+ }
+
+ public void buildStarted(BuildEvent event) {}
+
+ public void buildFinished(BuildEvent event) {
+ classpath = null;
+ project = null;
+ }
+
+ public void targetStarted(BuildEvent event) {
+ }
+
+ public void targetFinished(BuildEvent event) {
+ }
+
+ public void taskStarted(BuildEvent event) {
+ }
+
+ public void taskFinished(BuildEvent event) {
+ }
+
+ public void messageLogged(BuildEvent event) {
}
}
1.16 +17 -1 jakarta-ant/src/main/org/apache/tools/ant/IntrospectionHelper.java
Index: IntrospectionHelper.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- IntrospectionHelper.java 2001/07/04 19:02:43 1.15
+++ IntrospectionHelper.java 2001/07/11 09:58:08 1.16
@@ -68,7 +68,7 @@
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
-public class IntrospectionHelper {
+public class IntrospectionHelper implements BuildListener {
/**
* holds the types of the attributes that could be set.
@@ -552,4 +552,20 @@
throws InvocationTargetException, IllegalAccessException,
BuildException;
}
+
+ public void buildStarted(BuildEvent event) {}
+ public void buildFinished(BuildEvent event) {
+ attributeTypes.clear();
+ attributeSetters.clear();
+ nestedTypes.clear();
+ nestedCreators.clear();
+ addText = null;
+ helpers.clear();
+ }
+
+ public void targetStarted(BuildEvent event) {}
+ public void targetFinished(BuildEvent event) {}
+ public void taskStarted(BuildEvent event) {}
+ public void taskFinished(BuildEvent event) {}
+ public void messageLogged(BuildEvent event) {}
}
1.54 +2 -0 jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
Index: ProjectHelper.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- ProjectHelper.java 2001/07/10 15:40:00 1.53
+++ ProjectHelper.java 2001/07/11 09:58:09 1.54
@@ -628,6 +628,8 @@
IntrospectionHelper ih =
IntrospectionHelper.getHelper(target.getClass());
+ project.addBuildListener(ih);
+
for (int i = 0; i < attrs.getLength(); i++) {
// reflect these into the target
String value=replaceProperties(project, attrs.getValue(i),