Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Meiracle
spring-framework
提交
e3344898
S
spring-framework
项目概览
Meiracle
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e3344898
编写于
1月 03, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support varargs for DomUtils.getChildElementsByTagName
Issue: SPR-11272
上级
2e123b01
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
12 deletion
+14
-12
spring-core/src/main/java/org/springframework/util/xml/DomUtils.java
.../src/main/java/org/springframework/util/xml/DomUtils.java
+5
-4
spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java
.../web/servlet/config/InterceptorsBeanDefinitionParser.java
+9
-8
未找到文件。
spring-core/src/main/java/org/springframework/util/xml/DomUtils.java
浏览文件 @
e3344898
...
...
@@ -32,7 +32,8 @@ import org.xml.sax.ContentHandler;
import
org.springframework.util.Assert
;
/**
* Convenience methods for working with the DOM API, in particular for working with DOM Nodes and DOM Elements.
* Convenience methods for working with the DOM API,
* in particular for working with DOM Nodes and DOM Elements.
*
* @author Juergen Hoeller
* @author Rob Harrop
...
...
@@ -55,7 +56,7 @@ public abstract class DomUtils {
* @see org.w3c.dom.Element
* @see org.w3c.dom.Element#getElementsByTagName
*/
public
static
List
<
Element
>
getChildElementsByTagName
(
Element
ele
,
String
[]
childEleNames
)
{
public
static
List
<
Element
>
getChildElementsByTagName
(
Element
ele
,
String
...
childEleNames
)
{
Assert
.
notNull
(
ele
,
"Element must not be null"
);
Assert
.
notNull
(
childEleNames
,
"Element names collection must not be null"
);
List
<
String
>
childEleNameList
=
Arrays
.
asList
(
childEleNames
);
...
...
@@ -81,7 +82,7 @@ public abstract class DomUtils {
* @see org.w3c.dom.Element#getElementsByTagName
*/
public
static
List
<
Element
>
getChildElementsByTagName
(
Element
ele
,
String
childEleName
)
{
return
getChildElementsByTagName
(
ele
,
new
String
[]{
childEleName
});
return
getChildElementsByTagName
(
ele
,
new
String
[]
{
childEleName
});
}
/**
...
...
@@ -184,7 +185,7 @@ public abstract class DomUtils {
/**
* Matches the given node's name and local name against the given desired names.
*/
private
static
boolean
nodeNameMatch
(
Node
node
,
Collection
desiredNames
)
{
private
static
boolean
nodeNameMatch
(
Node
node
,
Collection
<?>
desiredNames
)
{
return
(
desiredNames
.
contains
(
node
.
getNodeName
())
||
desiredNames
.
contains
(
node
.
getLocalName
()));
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java
浏览文件 @
e3344898
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -18,6 +18,8 @@ package org.springframework.web.servlet.config;
import
java.util.List
;
import
org.w3c.dom.Element
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.parsing.BeanComponentDefinition
;
import
org.springframework.beans.factory.parsing.CompositeComponentDefinition
;
...
...
@@ -27,11 +29,10 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
import
org.springframework.beans.factory.xml.ParserContext
;
import
org.springframework.util.xml.DomUtils
;
import
org.springframework.web.servlet.handler.MappedInterceptor
;
import
org.w3c.dom.Element
;
/**
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a
{@code interceptors} element to register
* a set of {@link MappedInterceptor} definitions.
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a
*
{@code interceptors} element to register
a set of {@link MappedInterceptor} definitions.
*
* @author Keith Donald
* @since 3.0
...
...
@@ -42,7 +43,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
CompositeComponentDefinition
compDefinition
=
new
CompositeComponentDefinition
(
element
.
getTagName
(),
parserContext
.
extractSource
(
element
));
parserContext
.
pushContainingComponent
(
compDefinition
);
List
<
Element
>
interceptors
=
DomUtils
.
getChildElementsByTagName
(
element
,
new
String
[]
{
"bean"
,
"ref"
,
"interceptor"
}
);
List
<
Element
>
interceptors
=
DomUtils
.
getChildElementsByTagName
(
element
,
"bean"
,
"ref"
,
"interceptor"
);
for
(
Element
interceptor
:
interceptors
)
{
RootBeanDefinition
mappedInterceptorDef
=
new
RootBeanDefinition
(
MappedInterceptor
.
class
);
mappedInterceptorDef
.
setSource
(
parserContext
.
extractSource
(
interceptor
));
...
...
@@ -54,7 +55,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
if
(
"interceptor"
.
equals
(
interceptor
.
getLocalName
()))
{
includePatterns
=
getIncludePatterns
(
interceptor
,
"mapping"
);
excludePatterns
=
getIncludePatterns
(
interceptor
,
"exclude-mapping"
);
Element
beanElem
=
DomUtils
.
getChildElementsByTagName
(
interceptor
,
new
String
[]
{
"bean"
,
"ref"
}
).
get
(
0
);
Element
beanElem
=
DomUtils
.
getChildElementsByTagName
(
interceptor
,
"bean"
,
"ref"
).
get
(
0
);
interceptorBean
=
parserContext
.
getDelegate
().
parsePropertySubElement
(
beanElem
,
null
);
}
else
{
...
...
@@ -75,8 +76,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
private
ManagedList
<
String
>
getIncludePatterns
(
Element
interceptor
,
String
elementName
)
{
List
<
Element
>
paths
=
DomUtils
.
getChildElementsByTagName
(
interceptor
,
elementName
);
ManagedList
<
String
>
patterns
=
new
ManagedList
<
String
>(
paths
.
size
());
for
(
int
i
=
0
;
i
<
paths
.
size
();
i
++
)
{
patterns
.
add
(
path
s
.
get
(
i
)
.
getAttribute
(
"path"
));
for
(
Element
path
:
paths
)
{
patterns
.
add
(
path
.
getAttribute
(
"path"
));
}
return
patterns
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录