incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r979454 - /incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/Parser.java
Date Mon, 26 Jul 2010 21:38:25 GMT
Author: linsun
Date: Mon Jul 26 21:38:25 2010
New Revision: 979454

URL: http://svn.apache.org/viewvc?rev=979454&view=rev
Log:
ARIES-370 Ensure custom element are parsed after blueprint element in Parser.loadComponents

Modified:
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/Parser.java

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/Parser.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/Parser.java?rev=979454&r1=979453&r2=979454&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/Parser.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/Parser.java
Mon Jul 26 21:38:25 2010
@@ -313,6 +313,9 @@ public class Parser {
         handleCustomAttributes(root.getAttributes(), null);
 
         // Parse elements
+        // Break into 2 loops to ensure we scan the blueprint elements before
+        // This is needed so that when we process the custom element, we know
+        // the component definition registry has populated all blueprint components.
         NodeList nl = root.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {
             Node node = nl.item(i);
@@ -321,7 +324,16 @@ public class Parser {
                 String namespaceUri = element.getNamespaceURI();
                 if (isBlueprintNamespace(namespaceUri)) {
                     parseBlueprintElement(element);
-                } else {
+                } 
+            }
+        }
+        
+        for (int i = 0; i < nl.getLength(); i++) {
+            Node node = nl.item(i);
+            if (node instanceof Element) {
+                Element element = (Element) node;
+                String namespaceUri = element.getNamespaceURI();
+                if (!isBlueprintNamespace(namespaceUri)) {
                     Metadata component = parseCustomElement(element, null);
                     if (component != null) {
                         if (!(component instanceof ComponentMetadata)) {
@@ -329,7 +341,7 @@ public class Parser {
                         }
                         registry.registerComponentDefinition((ComponentMetadata) component);
                     }
-                }
+                } 
             }
         }
     }



Mime
View raw message