Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
6f2e61b1
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
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,发现更多精彩内容 >>
提交
6f2e61b1
编写于
4月 28, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
(cherry picked from commit
c97c2469
)
上级
63733c48
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
47 deletion
+57
-47
spring-context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java
...context/annotation/ComponentScanBeanDefinitionParser.java
+3
-3
spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
...ework/core/LocalVariableTableParameterNameDiscoverer.java
+33
-31
spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.java
.../org/springframework/oxm/xmlbeans/XmlBeansMarshaller.java
+15
-7
spring-web/src/main/java/org/springframework/web/filter/OncePerRequestFilter.java
.../org/springframework/web/filter/OncePerRequestFilter.java
+6
-6
未找到文件。
spring-context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java
浏览文件 @
6f2e61b1
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -258,7 +258,7 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
@SuppressWarnings
(
"unchecked"
)
private
Object
instantiateUserDefinedStrategy
(
String
className
,
Class
<?>
strategyType
,
ClassLoader
classLoader
)
{
Object
result
=
null
;
Object
result
;
try
{
result
=
classLoader
.
loadClass
(
className
).
newInstance
();
}
...
...
@@ -268,7 +268,7 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
}
catch
(
Exception
ex
)
{
throw
new
IllegalArgumentException
(
"Unable to instantiate class ["
+
className
+
"] for strategy ["
+
strategyType
.
getName
()
+
"]
. A
zero-argument constructor is required"
,
ex
);
strategyType
.
getName
()
+
"]
: a
zero-argument constructor is required"
,
ex
);
}
if
(!
strategyType
.
isAssignableFrom
(
result
.
getClass
()))
{
...
...
spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
浏览文件 @
6f2e61b1
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -103,8 +103,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
// We couldn't load the class file, which is not fatal as it
// simply means this method of discovering parameter names won't work.
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Cannot find '.class' file for class ["
+
clazz
+
"] - unable to determine constructors/methods
parameter names"
);
logger
.
debug
(
"Cannot find '.class' file for class ["
+
clazz
+
"] - unable to determine constructor/method
parameter names"
);
}
return
NO_DEBUG_INFO_MAP
;
}
...
...
@@ -117,14 +117,14 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
catch
(
IOException
ex
)
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Exception thrown while reading '.class' file for class ["
+
clazz
+
"] - unable to determine constructor
s/methods
parameter names"
,
ex
);
"] - unable to determine constructor
/method
parameter names"
,
ex
);
}
}
catch
(
IllegalArgumentException
ex
)
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"ASM ClassReader failed to parse class file ["
+
clazz
+
"], probably due to a new Java class file version that isn't supported yet "
+
"- unable to determine constructor
s/methods
parameter names"
,
ex
);
"- unable to determine constructor
/method
parameter names"
,
ex
);
}
}
finally
{
...
...
@@ -148,6 +148,7 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
private
static
final
String
STATIC_CLASS_INIT
=
"<clinit>"
;
private
final
Class
<?>
clazz
;
private
final
Map
<
Member
,
String
[]>
memberMap
;
public
ParameterNameDiscoveringVisitor
(
Class
<?>
clazz
,
Map
<
Member
,
String
[]>
memberMap
)
{
...
...
@@ -180,12 +181,17 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
private
static
final
String
CONSTRUCTOR
=
"<init>"
;
private
final
Class
<?>
clazz
;
private
final
Map
<
Member
,
String
[]>
memberMap
;
private
final
String
name
;
private
final
Type
[]
args
;
private
final
String
[]
parameterNames
;
private
final
boolean
isStatic
;
private
String
[]
parameterNames
;
private
boolean
hasLvtInfo
=
false
;
/*
...
...
@@ -194,25 +200,22 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
*/
private
final
int
[]
lvtSlotIndex
;
public
LocalVariableTableVisitor
(
Class
<?>
clazz
,
Map
<
Member
,
String
[]>
map
,
String
name
,
String
desc
,
boolean
isStatic
)
{
public
LocalVariableTableVisitor
(
Class
<?>
clazz
,
Map
<
Member
,
String
[]>
map
,
String
name
,
String
desc
,
boolean
isStatic
)
{
super
(
SpringAsmInfo
.
ASM_VERSION
);
this
.
clazz
=
clazz
;
this
.
memberMap
=
map
;
this
.
name
=
name
;
// determine args
args
=
Type
.
getArgumentTypes
(
desc
);
this
.
parameterNames
=
new
String
[
args
.
length
];
this
.
args
=
Type
.
getArgumentTypes
(
desc
);
this
.
parameterNames
=
new
String
[
this
.
args
.
length
];
this
.
isStatic
=
isStatic
;
this
.
lvtSlotIndex
=
computeLvtSlotIndices
(
isStatic
,
args
);
this
.
lvtSlotIndex
=
computeLvtSlotIndices
(
isStatic
,
this
.
args
);
}
@Override
public
void
visitLocalVariable
(
String
name
,
String
description
,
String
signature
,
Label
start
,
Label
end
,
int
index
)
{
public
void
visitLocalVariable
(
String
name
,
String
description
,
String
signature
,
Label
start
,
Label
end
,
int
index
)
{
this
.
hasLvtInfo
=
true
;
for
(
int
i
=
0
;
i
<
lvtSlotIndex
.
length
;
i
++)
{
if
(
lvtSlotIndex
[
i
]
==
index
)
{
for
(
int
i
=
0
;
i
<
this
.
lvtSlotIndex
.
length
;
i
++)
{
if
(
this
.
lvtSlotIndex
[
i
]
==
index
)
{
this
.
parameterNames
[
i
]
=
name
;
}
}
...
...
@@ -225,27 +228,25 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
// which doesn't use any local variables.
// This means that hasLvtInfo could be false for that kind of methods
// even if the class has local variable info.
memberMap
.
put
(
resolveMember
(),
parameterNames
);
this
.
memberMap
.
put
(
resolveMember
(),
this
.
parameterNames
);
}
}
private
Member
resolveMember
()
{
ClassLoader
loader
=
clazz
.
getClassLoader
();
Class
<?>[]
classes
=
new
Class
<?>[
args
.
length
];
// resolve args
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
classes
[
i
]
=
ClassUtils
.
resolveClassName
(
args
[
i
].
getClassName
(),
loader
);
ClassLoader
loader
=
this
.
clazz
.
getClassLoader
();
Class
<?>[]
argTypes
=
new
Class
<?>[
this
.
args
.
length
];
for
(
int
i
=
0
;
i
<
this
.
args
.
length
;
i
++)
{
argTypes
[
i
]
=
ClassUtils
.
resolveClassName
(
this
.
args
[
i
].
getClassName
(),
loader
);
}
try
{
if
(
CONSTRUCTOR
.
equals
(
name
))
{
return
clazz
.
getDeclaredConstructor
(
class
es
);
if
(
CONSTRUCTOR
.
equals
(
this
.
name
))
{
return
this
.
clazz
.
getDeclaredConstructor
(
argTyp
es
);
}
return
clazz
.
getDeclaredMethod
(
name
,
classes
);
}
catch
(
NoSuchMethodException
ex
)
{
throw
new
IllegalStateException
(
"Method ["
+
name
+
"] was discovered in the .class file but cannot be resolved in the class object"
,
ex
);
return
this
.
clazz
.
getDeclaredMethod
(
this
.
name
,
argTypes
);
}
catch
(
NoSuchMethodException
ex
)
{
throw
new
IllegalStateException
(
"Method ["
+
this
.
name
+
"] was discovered in the .class file but cannot be resolved in the class object"
,
ex
);
}
}
...
...
@@ -256,7 +257,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
lvtIndex
[
i
]
=
nextIndex
;
if
(
isWideType
(
paramTypes
[
i
]))
{
nextIndex
+=
2
;
}
else
{
}
else
{
nextIndex
++;
}
}
...
...
spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.java
浏览文件 @
6f2e61b1
...
...
@@ -125,7 +125,7 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
@Override
protected
void
marshalDomNode
(
Object
graph
,
Node
node
)
throws
XmlMappingException
{
Document
document
=
node
.
getNodeType
()
==
Node
.
DOCUMENT_NODE
?
(
Document
)
node
:
node
.
getOwnerDocument
(
);
Document
document
=
(
node
.
getNodeType
()
==
Node
.
DOCUMENT_NODE
?
(
Document
)
node
:
node
.
getOwnerDocument
()
);
Node
xmlBeansNode
=
((
XmlObject
)
graph
).
newDomNode
(
getXmlOptions
());
NodeList
xmlBeansChildNodes
=
xmlBeansNode
.
getChildNodes
();
for
(
int
i
=
0
;
i
<
xmlBeansChildNodes
.
getLength
();
i
++)
{
...
...
@@ -277,19 +277,27 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
*/
protected
void
validate
(
XmlObject
object
)
throws
ValidationFailureException
{
if
(
isValidating
()
&&
object
!=
null
)
{
// create a temporary xmlOptions just for validation
XmlOptions
validateOptions
=
getXmlOptions
()
!=
null
?
getXmlOptions
()
:
new
XmlOptions
();
XmlOptions
validateOptions
=
getXmlOptions
();
if
(
validateOptions
==
null
)
{
// Create temporary XmlOptions just for validation
validateOptions
=
new
XmlOptions
();
}
List
<
XmlError
>
errorsList
=
new
ArrayList
<
XmlError
>();
validateOptions
.
setErrorListener
(
errorsList
);
if
(!
object
.
validate
(
validateOptions
))
{
StringBuilder
builder
=
new
StringBuilder
(
"Could not validate XmlObject :"
);
StringBuilder
sb
=
new
StringBuilder
(
"Failed to validate XmlObject: "
);
boolean
first
=
true
;
for
(
XmlError
error
:
errorsList
)
{
if
(
error
instanceof
XmlValidationError
)
{
builder
.
append
(
error
.
toString
());
if
(!
first
)
{
sb
.
append
(
"; "
);
}
sb
.
append
(
error
.
toString
());
first
=
false
;
}
}
throw
new
ValidationFailureException
(
"XMLBeans validation failure"
,
new
XmlException
(
builder
.
toString
(),
null
,
errorsList
));
new
XmlException
(
sb
.
toString
(),
null
,
errorsList
));
}
}
}
...
...
@@ -306,7 +314,7 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
*/
protected
XmlMappingException
convertXmlBeansException
(
Exception
ex
,
boolean
marshalling
)
{
if
(
ex
instanceof
XMLStreamValidationException
)
{
return
new
ValidationFailureException
(
"X
ml
Beans validation exception"
,
ex
);
return
new
ValidationFailureException
(
"X
ML
Beans validation exception"
,
ex
);
}
else
if
(
ex
instanceof
XmlException
||
ex
instanceof
SAXException
)
{
if
(
marshalling
)
{
...
...
spring-web/src/main/java/org/springframework/web/filter/OncePerRequestFilter.java
浏览文件 @
6f2e61b1
...
...
@@ -45,14 +45,14 @@ import org.springframework.web.util.WebUtils;
* and so on. This mechanism complements and does not replace the need to
* configure a filter in {@code web.xml} with dispatcher types.
*
* <p>Sub
-
classes may use {@link #isAsyncDispatch(HttpServletRequest)} to
* determine when a filter is invoked as part of an async dispatch, and
*
use {@link #isAsyncStarted(HttpServletRequest)} to determine when the
*
request has been placed in async mode and therefore the current dispatch
*
won't be the last one
.
* <p>Subclasses may use {@link #isAsyncDispatch(HttpServletRequest)} to
* determine when a filter is invoked as part of an async dispatch, and
use
*
{@link #isAsyncStarted(HttpServletRequest)} to determine when the request
*
has been placed in async mode and therefore the current dispatch won't be
*
the last one for the given request
.
*
* <p>Yet another dispatch type that also occurs in its own thread is
* {@link javax.servlet.DispatcherType#ERROR ERROR}. Sub
-
classes can override
* {@link javax.servlet.DispatcherType#ERROR ERROR}. Subclasses can override
* {@link #shouldNotFilterErrorDispatch()} if they wish to declare statically
* if they should be invoked <em>once</em> during error dispatches.
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录