Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
14e5a028
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,发现更多精彩内容 >>
提交
14e5a028
编写于
2月 14, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Mixed polishing along with recent changes
上级
9c6df766
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
285 addition
and
291 deletion
+285
-291
spring-context/src/main/java/org/springframework/cache/CacheManager.java
...src/main/java/org/springframework/cache/CacheManager.java
+3
-3
spring-expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java
...ringframework/expression/spel/ast/CompoundExpression.java
+9
-10
spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
...java/org/springframework/expression/spel/ast/Indexer.java
+220
-231
spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
...org/springframework/expression/spel/ast/SpelNodeImpl.java
+9
-9
spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java
...a/org/springframework/expression/spel/MapAccessTests.java
+13
-3
spring-messaging/src/main/java/org/springframework/messaging/simp/user/UserDestinationMessageHandler.java
...rk/messaging/simp/user/UserDestinationMessageHandler.java
+13
-15
spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java
...mework/transaction/interceptor/RollbackRuleAttribute.java
+6
-6
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolver.java
...thod/annotation/ServletRequestMethodArgumentResolver.java
+6
-7
spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java
...va/org/springframework/web/servlet/tags/form/FormTag.java
+6
-7
未找到文件。
spring-context/src/main/java/org/springframework/cache/CacheManager.java
浏览文件 @
14e5a028
/*
* Copyright 2002-201
1
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.
...
...
@@ -29,13 +29,13 @@ public interface CacheManager {
/**
* Return the cache associated with the given name.
* @param name cache identifier (must not be {@code null})
* @return associated cache, or {@code null} if none is found
* @return
the
associated cache, or {@code null} if none is found
*/
Cache
getCache
(
String
name
);
/**
* Return a collection of the caches known by this cache manager.
* @return names of caches known by the cache manager
.
* @return names of caches known by the cache manager
*/
Collection
<
String
>
getCacheNames
();
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java
浏览文件 @
14e5a028
/*
* 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.
...
...
@@ -30,9 +30,10 @@ import org.springframework.expression.spel.SpelEvaluationException;
public
class
CompoundExpression
extends
SpelNodeImpl
{
public
CompoundExpression
(
int
pos
,
SpelNodeImpl
...
expressionComponents
)
{
super
(
pos
,
expressionComponents
);
if
(
expressionComponents
.
length
<
2
)
{
throw
new
IllegalStateException
(
"Dont build compound expression less than one entry: "
+
expressionComponents
.
length
);
super
(
pos
,
expressionComponents
);
if
(
expressionComponents
.
length
<
2
)
{
throw
new
IllegalStateException
(
"Do not build compound expression less than one entry: "
+
expressionComponents
.
length
);
}
}
...
...
@@ -42,11 +43,9 @@ public class CompoundExpression extends SpelNodeImpl {
if
(
getChildCount
()
==
1
)
{
return
this
.
children
[
0
].
getValueRef
(
state
);
}
TypedValue
result
=
null
;
SpelNodeImpl
nextNode
=
null
;
SpelNodeImpl
nextNode
=
this
.
children
[
0
];
try
{
nextNode
=
this
.
children
[
0
];
result
=
nextNode
.
getValueInternal
(
state
);
TypedValue
result
=
nextNode
.
getValueInternal
(
state
);
int
cc
=
getChildCount
();
for
(
int
i
=
1
;
i
<
cc
-
1
;
i
++)
{
try
{
...
...
@@ -75,8 +74,8 @@ public class CompoundExpression extends SpelNodeImpl {
}
/**
* Evaluates a compound expression. This involves evaluating each piece in turn and the
return value from each piece
* is the active context object for the subsequent piece.
* Evaluates a compound expression. This involves evaluating each piece in turn and the
*
return value from each piece
is the active context object for the subsequent piece.
* @param state the state in which the expression is being evaluated
* @return the final value from the last piece of the compound expression
*/
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
浏览文件 @
14e5a028
此差异已折叠。
点击以展开。
spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
浏览文件 @
14e5a028
/*
* 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.
...
...
@@ -37,6 +37,7 @@ public abstract class SpelNodeImpl implements SpelNode {
private
static
SpelNodeImpl
[]
NO_CHILDREN
=
new
SpelNodeImpl
[
0
];
protected
int
pos
;
// start = top 16bits, end = bottom 16bits
protected
SpelNodeImpl
[]
children
=
SpelNodeImpl
.
NO_CHILDREN
;
...
...
@@ -152,22 +153,21 @@ public abstract class SpelNodeImpl implements SpelNode {
return
ExpressionUtils
.
convertTypedValue
(
state
.
getEvaluationContext
(),
getValueInternal
(
state
),
desiredReturnType
);
}
public
abstract
TypedValue
getValueInternal
(
ExpressionState
expressionState
)
throws
EvaluationException
;
@Override
public
abstract
String
toStringAST
();
@Override
public
int
getStartPosition
()
{
return
(
this
.
pos
>>
16
);
return
(
this
.
pos
>>
16
);
}
@Override
public
int
getEndPosition
()
{
return
(
this
.
pos
&
0xffff
);
return
(
this
.
pos
&
0xffff
);
}
protected
ValueRef
getValueRef
(
ExpressionState
state
)
throws
EvaluationException
{
throw
new
SpelEvaluationException
(
this
.
pos
,
SpelMessage
.
NOT_ASSIGNABLE
,
toStringAST
());
throw
new
SpelEvaluationException
(
this
.
pos
,
SpelMessage
.
NOT_ASSIGNABLE
,
toStringAST
());
}
public
abstract
TypedValue
getValueInternal
(
ExpressionState
expressionState
)
throws
EvaluationException
;
}
spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java
浏览文件 @
14e5a028
...
...
@@ -81,9 +81,19 @@ public class MapAccessTests extends AbstractExpressionTests {
Object
bean
=
new
TestBean
(
"name1"
,
new
TestBean
(
"name2"
,
null
,
"Description 2"
,
15
,
props1
),
"description 1"
,
6
,
props1
);
ExpressionParser
parser
=
new
SpelExpressionParser
();
Expression
exp
=
parser
.
parseExpression
(
"testBean.properties['key2']"
);
String
key
=
(
String
)
exp
.
getValue
(
bean
);
assertNotNull
(
key
);
Expression
expr
=
parser
.
parseExpression
(
"testBean.properties['key2']"
);
assertEquals
(
"value2"
,
expr
.
getValue
(
bean
));
}
@Test
public
void
testGetValueFromRootMap
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"key"
,
"value"
);
EvaluationContext
context
=
new
StandardEvaluationContext
(
map
);
ExpressionParser
spelExpressionParser
=
new
SpelExpressionParser
();
Expression
expr
=
spelExpressionParser
.
parseExpression
(
"#root['key']"
);
assertEquals
(
"value"
,
expr
.
getValue
(
map
));
}
...
...
spring-messaging/src/main/java/org/springframework/messaging/simp/user/UserDestinationMessageHandler.java
浏览文件 @
14e5a028
...
...
@@ -31,9 +31,7 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import
org.springframework.messaging.simp.SimpMessageType
;
import
org.springframework.messaging.simp.SimpMessagingTemplate
;
import
org.springframework.messaging.support.MessageBuilder
;
import
org.springframework.messaging.support.MessageHeaderAccessor
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
/**
* Provides support for messages sent to "user" destinations, translating the
...
...
@@ -60,7 +58,7 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
private
final
UserDestinationResolver
userDestinationResolver
;
private
Object
lifecycleMonitor
=
new
Object
();
private
final
Object
lifecycleMonitor
=
new
Object
();
private
volatile
boolean
running
=
false
;
...
...
@@ -85,12 +83,6 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
this
.
userDestinationResolver
=
userDestinationResolver
;
}
/**
* Return the configured {@link UserDestinationResolver}.
*/
public
UserDestinationResolver
getUserDestinationResolver
()
{
return
this
.
userDestinationResolver
;
}
/**
* Return the configured messaging template for sending messages with
...
...
@@ -100,16 +92,24 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
return
this
.
brokerMessagingTemplate
;
}
@Override
public
boolean
isAutoStartup
()
{
return
true
;
/**
* Return the configured {@link UserDestinationResolver}.
*/
public
UserDestinationResolver
getUserDestinationResolver
()
{
return
this
.
userDestinationResolver
;
}
@Override
public
int
getPhase
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
public
boolean
isAutoStartup
()
{
return
true
;
}
@Override
public
final
boolean
isRunning
()
{
synchronized
(
this
.
lifecycleMonitor
)
{
...
...
@@ -143,9 +143,9 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
}
}
@Override
public
void
handleMessage
(
Message
<?>
message
)
throws
MessagingException
{
UserDestinationResult
result
=
this
.
userDestinationResolver
.
resolveDestination
(
message
);
if
(
result
==
null
)
{
return
;
...
...
@@ -154,13 +154,11 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
if
(
destinations
.
isEmpty
())
{
return
;
}
SimpMessageHeaderAccessor
headerAccessor
=
SimpMessageHeaderAccessor
.
wrap
(
message
);
if
(
SimpMessageType
.
MESSAGE
.
equals
(
headerAccessor
.
getMessageType
()))
{
headerAccessor
.
setHeader
(
SUBSCRIBE_DESTINATION
,
result
.
getSubscribeDestination
());
message
=
MessageBuilder
.
withPayload
(
message
.
getPayload
()).
setHeaders
(
headerAccessor
).
build
();
}
for
(
String
targetDestination
:
destinations
)
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Sending message to resolved destination="
+
targetDestination
);
...
...
spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java
浏览文件 @
14e5a028
/*
* 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.
...
...
@@ -16,10 +16,10 @@
package
org.springframework.transaction.interceptor
;
import
org.springframework.util.Assert
;
import
java.io.Serializable
;
import
org.springframework.util.Assert
;
/**
* Rule determining whether or not a given exception (and any subclasses)
* should cause a rollback.
...
...
@@ -60,7 +60,7 @@ public class RollbackRuleAttribute implements Serializable{
* not a {@code Throwable} type or is {@code null}
*/
public
RollbackRuleAttribute
(
Class
<?>
clazz
)
{
Assert
.
notNull
(
clazz
,
"'clazz' cannot be null
.
"
);
Assert
.
notNull
(
clazz
,
"'clazz' cannot be null"
);
if
(!
Throwable
.
class
.
isAssignableFrom
(
clazz
))
{
throw
new
IllegalArgumentException
(
"Cannot construct rollback rule from ["
+
clazz
.
getName
()
+
"]: it's not a Throwable"
);
...
...
@@ -87,7 +87,7 @@ public class RollbackRuleAttribute implements Serializable{
* {@code exceptionName} is {@code null} or empty
*/
public
RollbackRuleAttribute
(
String
exceptionName
)
{
Assert
.
hasText
(
exceptionName
,
"'exceptionName' cannot be null or empty
.
"
);
Assert
.
hasText
(
exceptionName
,
"'exceptionName' cannot be null or empty"
);
this
.
exceptionName
=
exceptionName
;
}
...
...
@@ -111,7 +111,7 @@ public class RollbackRuleAttribute implements Serializable{
private
int
getDepth
(
Class
<?>
exceptionClass
,
int
depth
)
{
if
(
exceptionClass
.
getName
().
indexOf
(
this
.
exceptionName
)
!=
-
1
)
{
if
(
exceptionClass
.
getName
().
contains
(
this
.
exceptionName
)
)
{
// Found it!
return
depth
;
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolver.java
浏览文件 @
14e5a028
...
...
@@ -19,7 +19,6 @@ package org.springframework.web.servlet.mvc.method.annotation;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.Reader
;
import
java.lang.reflect.Method
;
import
java.security.Principal
;
import
java.time.ZoneId
;
import
java.util.Locale
;
...
...
@@ -101,6 +100,9 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
else
if
(
HttpSession
.
class
.
isAssignableFrom
(
paramType
))
{
return
request
.
getSession
();
}
else
if
(
HttpMethod
.
class
.
equals
(
paramType
))
{
return
((
ServletWebRequest
)
webRequest
).
getHttpMethod
();
}
else
if
(
Principal
.
class
.
isAssignableFrom
(
paramType
))
{
return
request
.
getUserPrincipal
();
}
...
...
@@ -120,13 +122,10 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
else
if
(
Reader
.
class
.
isAssignableFrom
(
paramType
))
{
return
request
.
getReader
();
}
else
if
(
HttpMethod
.
class
.
equals
(
paramType
))
{
return
((
ServletWebRequest
)
webRequest
).
getHttpMethod
();
}
else
{
// should never happen..
Method
method
=
parameter
.
getMethod
();
throw
new
UnsupportedOperationException
(
"Unknown parameter type: "
+
paramType
+
" in method: "
+
method
);
// should never happen..
.
throw
new
UnsupportedOperationException
(
"Unknown parameter type: "
+
paramType
+
" in method: "
+
parameter
.
getMethod
()
);
}
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java
浏览文件 @
14e5a028
...
...
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.tags.form;
import
java.io.UnsupportedEncodingException
;
import
java.util.Map
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -424,7 +423,6 @@ public class FormTag extends AbstractHtmlElementTag {
* with the context and servlet paths, and the result is used. Otherwise, the
* {@link org.springframework.web.servlet.support.RequestContext#getRequestUri()
* originating URI} is used.
*
* @return the value that is to be used for the '{@code action}' attribute
*/
protected
String
resolveAction
()
throws
JspException
{
...
...
@@ -436,7 +434,8 @@ public class FormTag extends AbstractHtmlElementTag {
}
else
if
(
StringUtils
.
hasText
(
servletRelativeAction
))
{
String
pathToServlet
=
getRequestContext
().
getPathToServlet
();
if
(
servletRelativeAction
.
startsWith
(
"/"
)
&&
!
servletRelativeAction
.
startsWith
(
getRequestContext
().
getContextPath
()))
{
if
(
servletRelativeAction
.
startsWith
(
"/"
)
&&
!
servletRelativeAction
.
startsWith
(
getRequestContext
().
getContextPath
()))
{
servletRelativeAction
=
pathToServlet
+
servletRelativeAction
;
}
servletRelativeAction
=
getDisplayString
(
evaluate
(
ACTION_ATTRIBUTE
,
servletRelativeAction
));
...
...
@@ -444,12 +443,12 @@ public class FormTag extends AbstractHtmlElementTag {
}
else
{
String
requestUri
=
getRequestContext
().
getRequestUri
();
String
encoding
=
pageContext
.
getResponse
().
getCharacterEncoding
();
String
encoding
=
this
.
pageContext
.
getResponse
().
getCharacterEncoding
();
try
{
requestUri
=
UriUtils
.
encodePath
(
requestUri
,
encoding
);
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
JspException
(
e
);
catch
(
UnsupportedEncodingException
e
x
)
{
// shouldn't happen - if it does, proceed with requestUri as-is
}
ServletResponse
response
=
this
.
pageContext
.
getResponse
();
if
(
response
instanceof
HttpServletResponse
)
{
...
...
@@ -476,7 +475,7 @@ public class FormTag extends AbstractHtmlElementTag {
private
String
processAction
(
String
action
)
{
RequestDataValueProcessor
processor
=
getRequestContext
().
getRequestDataValueProcessor
();
ServletRequest
request
=
this
.
pageContext
.
getRequest
();
if
(
(
processor
!=
null
)
&&
(
request
instanceof
HttpServletRequest
)
)
{
if
(
processor
!=
null
&&
request
instanceof
HttpServletRequest
)
{
action
=
processor
.
processAction
((
HttpServletRequest
)
request
,
action
,
getHttpMethod
());
}
return
action
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录