costin      2002/12/27 10:01:14

  Modified:    src/main/org/apache/tools/ant IntrospectionHelper.java
  Log:
  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 )
  
  Revision  Changes    Path
  1.45      +24 -0     
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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- IntrospectionHelper.java  25 Jul 2002 15:21:01 -0000      1.44
  +++ IntrospectionHelper.java  27 Dec 2002 18:01:14 -0000      1.45
  @@ -386,6 +386,30 @@
       }
   
       /**
  +     * 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.
        * 
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to