Skip to content

Commit 3f885d0

Browse files
committed
Added DomUtils.getChildElements() method. Also refactored ConfigBeanDefinitionParser.parse() to use it.
1 parent 9f9a27a commit 3f885d0

6 files changed

Lines changed: 33 additions & 17 deletions

File tree

org.springframework.aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,17 @@ public BeanDefinition parse(Element element, ParserContext parserContext) {
102102

103103
configureAutoProxyCreator(parserContext, element);
104104

105-
NodeList childNodes = element.getChildNodes();
106-
for (int i = 0; i < childNodes.getLength(); i++) {
107-
Node node = childNodes.item(i);
108-
if (node.getNodeType() == Node.ELEMENT_NODE) {
109-
String localName = parserContext.getDelegate().getLocalName(node);
110-
if (POINTCUT.equals(localName)) {
111-
parsePointcut((Element) node, parserContext);
112-
}
113-
else if (ADVISOR.equals(localName)) {
114-
parseAdvisor((Element) node, parserContext);
115-
}
116-
else if (ASPECT.equals(localName)) {
117-
parseAspect((Element) node, parserContext);
118-
}
105+
List<Element> childElts = DomUtils.getChildElements(element);
106+
for (Element elt: childElts) {
107+
String localName = parserContext.getDelegate().getLocalName(elt);
108+
if (POINTCUT.equals(localName)) {
109+
parsePointcut(elt, parserContext);
110+
}
111+
else if (ADVISOR.equals(localName)) {
112+
parseAdvisor(elt, parserContext);
113+
}
114+
else if (ASPECT.equals(localName)) {
115+
parseAspect(elt, parserContext);
119116
}
120117
}
121118

org.springframework.core/build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
</ivy:makepom>
2323
</target>
2424
</project>
25+

org.springframework.core/src/main/java/org/springframework/util/xml/DomUtils.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* @author Rob Harrop
3939
* @author Costin Leau
4040
* @author Arjen Poutsma
41+
* @author Luke Taylor
4142
* @see org.w3c.dom.Node
4243
* @see org.w3c.dom.Element
4344
* @since 1.2
@@ -117,6 +118,25 @@ public static String getChildElementValueByTagName(Element ele, String childEleN
117118
return (child != null ? getTextValue(child) : null);
118119
}
119120

121+
/**
122+
* Retrieve all child elements of the given DOM element
123+
124+
* @param ele the DOM element to analyze
125+
* @return a List of child <code>org.w3c.dom.Element</code> instances
126+
*/
127+
public static List<Element> getChildElements(Element ele) {
128+
Assert.notNull(ele, "Element must not be null");
129+
NodeList nl = ele.getChildNodes();
130+
List<Element> childEles = new ArrayList<Element>();
131+
for (int i = 0; i < nl.getLength(); i++) {
132+
Node node = nl.item(i);
133+
if (node instanceof Element) {
134+
childEles.add((Element) node);
135+
}
136+
}
137+
return childEles;
138+
}
139+
120140
/**
121141
* Extract the text value from the given DOM element, ignoring XML comments. <p>Appends all CharacterData nodes and
122142
* EntityReference nodes into a single String value, excluding Comment nodes.

org.springframework.oxm/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<classpathentry kind="src" path="src/test/java"/>
66
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
77
<classpathentry kind="lib" path="target/artifacts/org.springframework.oxm-sources.jar"/>
8-
<classpathentry kind="lib" path="target/artifacts/org.springframework.oxm.jar"/>
8+
<classpathentry exported="true" kind="lib" path="target/artifacts/org.springframework.oxm.jar"/>
99
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
1010
<classpathentry kind="var" path="IVY_CACHE/com.thoughtworks.xstream/com.springsource.com.thoughtworks.xstream/1.3.1/com.springsource.com.thoughtworks.xstream-1.3.1.jar" sourcepath="/IVY_CACHE/com.thoughtworks.xstream/com.springsource.com.thoughtworks.xstream/1.3.1/com.springsource.com.thoughtworks.xstream-sources-1.3.1.jar"/>
1111
<classpathentry kind="var" path="IVY_CACHE/javax.xml.bind/com.springsource.javax.xml.bind/2.1.7/com.springsource.javax.xml.bind-2.1.7.jar" sourcepath="/IVY_CACHE/javax.xml.bind/com.springsource.javax.xml.bind/2.1.7/com.springsource.javax.xml.bind-sources-2.1.7.jar"/>

org.springframework.web.servlet/.classpath

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.core"/>
1313
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.jdbc"/>
1414
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.orm"/>
15-
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.oxm"/>
1615
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.transaction"/>
1716
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.web"/>
1817
<classpathentry kind="var" path="IVY_CACHE/com.lowagie.text/com.springsource.com.lowagie.text/2.0.8/com.springsource.com.lowagie.text-2.0.8.jar" sourcepath="/IVY_CACHE/com.lowagie.text/com.springsource.com.lowagie.text/2.0.8/com.springsource.com.lowagie.text-sources-2.0.8.jar"/>

org.springframework.web/.classpath

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.beans"/>
1010
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.context"/>
1111
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.core"/>
12-
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.oxm"/>
1312
<classpathentry kind="var" path="IVY_CACHE/com.caucho/com.springsource.com.caucho/3.2.1/com.springsource.com.caucho-3.2.1.jar" sourcepath="/IVY_CACHE/com.caucho/com.springsource.com.caucho/3.2.1/com.springsource.com.caucho-sources-3.2.1.jar"/>
1413
<classpathentry kind="var" path="IVY_CACHE/javax.el/com.springsource.javax.el/1.0.0/com.springsource.javax.el-1.0.0.jar" sourcepath="/IVY_CACHE/javax.el/com.springsource.javax.el/1.0.0/com.springsource.javax.el-sources-1.0.0.jar"/>
1514
<classpathentry kind="var" path="IVY_CACHE/javax.faces/com.springsource.javax.faces/1.2.0.08/com.springsource.javax.faces-1.2.0.08.jar" sourcepath="/IVY_CACHE/javax.faces/com.springsource.javax.faces/1.2.0.08/com.springsource.javax.faces-sources-1.2.0.08.jar"/>

0 commit comments

Comments
 (0)