Browse Source

Add a new method to get an IntrospectionHelper.

If one already exists, it'll be returned.
The method will register itself for projectEnd notifications.
( this avoids multiple IH and listeners )

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273702 13f79535-47bb-0310-9956-ffa450edef68
master
Costin Manolache 23 years ago
parent
commit
87118181a6
1 changed files with 24 additions and 0 deletions
  1. +24
    -0
      src/main/org/apache/tools/ant/IntrospectionHelper.java

+ 24
- 0
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -385,6 +385,30 @@ public class IntrospectionHelper implements BuildListener {
return ih;
}

/**
* Returns a helper for the given class, either from the cache
* or by creating a new instance.
*
* The method will make sure the helper will be cleaned up at the end of
* the project, and only one instance will be created for each class.
*
* @param c The class for which a helper is required.
* Must not be <code>null</code>.
*
* @return a helper for the specified class
*/
public static synchronized IntrospectionHelper getHelper(Project p, Class c)
{
IntrospectionHelper ih = (IntrospectionHelper) helpers.get(c);
if (ih == null) {
ih = new IntrospectionHelper(c);
helpers.put(c, ih);
// Cleanup at end of project
p.addBuildListener(ih);
}
return ih;
}

/**
* Sets the named attribute in the given element, which is part of the
* given project.


Loading…
Cancel
Save