[seam-commits] Seam SVN: r15007 - branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/init.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Jul 30 08:46:35 EDT 2012
Author: manaRH
Date: 2012-07-30 08:46:34 -0400 (Mon, 30 Jul 2012)
New Revision: 15007
Modified:
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/init/Initialization.java
Log:
JBPAPP-8159 second fixing attempt after extended testcase
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/init/Initialization.java 2012-07-27 14:49:01 UTC (rev 15006)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/init/Initialization.java 2012-07-30 12:46:34 UTC (rev 15007)
@@ -16,6 +16,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -503,6 +504,30 @@
throw new IllegalArgumentException("must specify either class or name in <component/> declaration");
}
+ // if there is the same component with highest precedence do not set properties for it
+ ComponentDescriptor highestPriorityComponent = getHighestPriorityDescriptor(name);
+
+ if (highestPriorityComponent != null)
+ {
+ if (precedence < highestPriorityComponent.getPrecedence())
+ {
+ return;
+ }
+ else
+ {
+ // have to remove all properties for lower priority component
+ Iterator<String> iterator = properties.keySet().iterator();
+ while (iterator.hasNext())
+ {
+ String qualifiedPropName = iterator.next();
+ if (qualifiedPropName.startsWith(name+"."))
+ {
+ iterator.remove();
+ }
+ }
+ }
+ }
+
for ( Element prop : (List<Element>) component.elements() )
{
String propName = prop.attributeValue("name");
@@ -511,12 +536,11 @@
propName = prop.getQName().getName();
}
String qualifiedPropName = name + '.' + toCamelCase(propName, false);
- log.info("qualifiedPropName " + qualifiedPropName);
- //properties.put( qualifiedPropName, getPropertyValue(prop, qualifiedPropName, replacements) );
if (properties.containsKey(qualifiedPropName))
{
if (isSetProperties(name, precedence))
{
+
properties.put(qualifiedPropName, getPropertyValue(prop, qualifiedPropName, replacements));
}
}
@@ -536,7 +560,6 @@
try
{
propValue = getPropertyValue(prop, replacements);
-// properties.put( qualifiedPropName, propValue );
if (isSetProperties(name, precedence))
{
properties.put(qualifiedPropName, propValue);
@@ -553,21 +576,33 @@
}
}
- private boolean isSetProperties(String name, int precedence)
+ /**
+ * Get the highest priority component for the component name
+ * @param componentName
+ * @return
+ */
+ private ComponentDescriptor getHighestPriorityDescriptor(String componentName)
{
- TreeSet<ComponentDescriptor> currentSet = (TreeSet<ComponentDescriptor>) componentDescriptors.get(name);
+ TreeSet<ComponentDescriptor> currentSet = (TreeSet<ComponentDescriptor>) componentDescriptors.get(componentName);
if (currentSet != null)
{
- ComponentDescriptor highestPriorityDescriptor = currentSet.first();
- if (highestPriorityDescriptor == null)
- {
- return true;
- }
+ return currentSet.first();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private boolean isSetProperties(String name, int precedence)
+ {
+ ComponentDescriptor highestPriorityDescriptor = getHighestPriorityDescriptor(name);
+ if ( highestPriorityDescriptor != null)
+ {
return precedence >= highestPriorityDescriptor.getPrecedence();
}
else
{
- log.info("Component is not in componentDescriptory " + name + " precedence " + precedence);
return true;
}
}
More information about the seam-commits
mailing list