jvanzyl 02/05/30 10:41:58
Modified: src/java/org/apache/maven/project Project.java
Log:
Have to lazily initialize the distributionMap because when the distribution
is added to the project it is not yet complete, at least it appears not
to be. This allows us to lookup distributions by id for the dist target.
Revision Changes Path
1.19 +20 -9
jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java
Index: Project.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Project.java 27 May 2002 21:23:32 -0000 1.18
+++ Project.java 30 May 2002 17:41:58 -0000 1.19
@@ -58,13 +58,14 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="[EMAIL PROTECTED]">Vincent Massol</a>
- * @version $Id: Project.java,v 1.18 2002/05/27 21:23:32 vmassol Exp $
+ * @version $Id: Project.java,v 1.19 2002/05/30 17:41:58 jvanzyl Exp $
*/
public class Project
extends BaseObject
@@ -180,7 +181,7 @@
* Distributions map that associates the distribution ids
* with the distribution objects.
*/
- private HashMap distributionsMap;
+ private HashMap distributionMap;
/**
* Default constructor.
@@ -191,7 +192,7 @@
mailingLists = new ArrayList();
developers = new ArrayList();
distributions = new ArrayList();
- distributionsMap = new HashMap();
+ //distributionMap = new HashMap();
}
/**
@@ -568,10 +569,6 @@
public void addDistribution(Distribution distribution)
{
distributions.add(distribution);
-
- //System.out.println("!!!!!!!!!!!!!!! " + distribution.getId());
-
- //distributionsMap.put(distribution.getId(), distribution);
}
/**
@@ -589,9 +586,23 @@
*
* @return List of distributions.
*/
- public Map getDistributionsMap()
+ public Distribution getDistributionById(String distId)
{
- return distributionsMap;
+ // We have to lazily initialize this because of betwixt/digester
+ // behavior where an objects addXXX() method is called but
+ // the parameter object is not yet fully populated.
+ if (distributionMap == null)
+ {
+ distributionMap = new HashMap();
+
+ for (Iterator i = distributions.iterator(); i.hasNext();)
+ {
+ Distribution d = (Distribution) i.next();
+ distributionMap.put(d.getId(), d);
+ }
+ }
+
+ return (Distribution) distributionMap.get(distId);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>