Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
86b7118d
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,体验更适合开发者的 AI 搜索 >>
提交
86b7118d
编写于
9月 04, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
20c2ba35
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
120 addition
and
119 deletion
+120
-119
spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java
...ork/util/concurrent/ListenableFutureCallbackRegistry.java
+6
-6
spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java
...gframework/util/concurrent/ListenableFutureTaskTests.java
+6
-12
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java
.../messaging/simp/stomp/StompBrokerRelayMessageHandler.java
+19
-19
spring-web/src/main/java/org/springframework/http/HttpEntity.java
...eb/src/main/java/org/springframework/http/HttpEntity.java
+7
-7
spring-web/src/main/java/org/springframework/http/RequestEntity.java
...src/main/java/org/springframework/http/RequestEntity.java
+10
-9
spring-web/src/main/java/org/springframework/http/ResponseEntity.java
...rc/main/java/org/springframework/http/ResponseEntity.java
+3
-3
spring-web/src/main/java/org/springframework/web/client/RestOperations.java
...n/java/org/springframework/web/client/RestOperations.java
+13
-18
spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
...ain/java/org/springframework/web/client/RestTemplate.java
+6
-0
spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
.../servlet/config/AnnotationDrivenBeanDefinitionParser.java
+6
-3
spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java
...ork/web/servlet/config/ResourcesBeanDefinitionParser.java
+19
-15
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
...servlet/config/annotation/WebMvcConfigurationSupport.java
+7
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMethodMappingNamingStrategy.java
...b/servlet/handler/HandlerMethodMappingNamingStrategy.java
+0
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/ParameterizableViewController.java
...mework/web/servlet/mvc/ParameterizableViewController.java
+1
-5
spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java
...va/org/springframework/web/servlet/view/RedirectView.java
+0
-4
spring-webmvc/src/main/java/org/springframework/web/servlet/view/ViewResolverComposite.java
...ringframework/web/servlet/view/ViewResolverComposite.java
+6
-6
spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java
...mework/web/servlet/view/json/MappingJackson2JsonView.java
+4
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlView.java
...ramework/web/servlet/view/xml/MappingJackson2XmlView.java
+6
-5
spring-websocket/src/main/java/org/springframework/web/socket/client/WebSocketConnectionManager.java
...amework/web/socket/client/WebSocketConnectionManager.java
+1
-1
未找到文件。
spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java
浏览文件 @
86b7118d
...
...
@@ -44,7 +44,7 @@ public class ListenableFutureCallbackRegistry<T> {
/**
* Add
s
the given callback to this registry.
* Add the given callback to this registry.
* @param callback the callback to add
*/
@SuppressWarnings
(
"unchecked"
)
...
...
@@ -67,7 +67,7 @@ public class ListenableFutureCallbackRegistry<T> {
}
/**
* Add
s
the given success callback to this registry.
* Add the given success callback to this registry.
* @param callback the success callback to add
* @since 4.1
*/
...
...
@@ -87,7 +87,7 @@ public class ListenableFutureCallbackRegistry<T> {
}
/**
* Add
s
the given failure callback to this registry.
* Add the given failure callback to this registry.
* @param callback the failure callback to add
* @since 4.1
*/
...
...
@@ -107,8 +107,8 @@ public class ListenableFutureCallbackRegistry<T> {
}
/**
* Trigger
s
a {@link ListenableFutureCallback#onSuccess(Object)} call on all
* added callbacks with the given result
* Trigger a {@link ListenableFutureCallback#onSuccess(Object)} call on all
* added callbacks with the given result
.
* @param result the result to trigger the callbacks with
*/
public
void
success
(
T
result
)
{
...
...
@@ -122,7 +122,7 @@ public class ListenableFutureCallbackRegistry<T> {
}
/**
* Trigger
s
a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
* Trigger a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
* added callbacks with the given {@code Throwable}.
* @param ex the exception to trigger the callbacks with
*/
...
...
spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java
浏览文件 @
86b7118d
...
...
@@ -18,15 +18,11 @@ package org.springframework.util.concurrent;
import
java.io.IOException
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
fail
;
import
org.junit.Test
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verifyZeroInteractions
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
Mockito
.*;
/**
* @author Arjen Poutsma
...
...
@@ -35,7 +31,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
public
class
ListenableFutureTaskTests
{
@Test
public
void
success
()
throws
Ex
ecutionException
,
InterruptedEx
ception
{
public
void
success
()
throws
Exception
{
final
String
s
=
"Hello World"
;
Callable
<
String
>
callable
=
new
Callable
<
String
>()
{
@Override
...
...
@@ -49,7 +45,6 @@ public class ListenableFutureTaskTests {
public
void
onSuccess
(
String
result
)
{
assertEquals
(
s
,
result
);
}
@Override
public
void
onFailure
(
Throwable
ex
)
{
fail
(
ex
.
getMessage
());
...
...
@@ -59,7 +54,7 @@ public class ListenableFutureTaskTests {
}
@Test
public
void
failure
()
throws
Ex
ecutionException
,
InterruptedEx
ception
{
public
void
failure
()
throws
Exception
{
final
String
s
=
"Hello World"
;
Callable
<
String
>
callable
=
new
Callable
<
String
>()
{
@Override
...
...
@@ -73,7 +68,6 @@ public class ListenableFutureTaskTests {
public
void
onSuccess
(
String
result
)
{
fail
(
"onSuccess not expected"
);
}
@Override
public
void
onFailure
(
Throwable
ex
)
{
assertEquals
(
s
,
ex
.
getMessage
());
...
...
@@ -83,7 +77,7 @@ public class ListenableFutureTaskTests {
}
@Test
public
void
successWithLambdas
()
throws
Ex
ecutionException
,
InterruptedEx
ception
{
public
void
successWithLambdas
()
throws
Exception
{
final
String
s
=
"Hello World"
;
Callable
<
String
>
callable
=
()
->
s
;
SuccessCallback
<
String
>
successCallback
=
mock
(
SuccessCallback
.
class
);
...
...
@@ -96,7 +90,7 @@ public class ListenableFutureTaskTests {
}
@Test
public
void
failureWithLambdas
()
throws
Ex
ecutionException
,
InterruptedEx
ception
{
public
void
failureWithLambdas
()
throws
Exception
{
final
String
s
=
"Hello World"
;
IOException
ex
=
new
IOException
(
s
);
Callable
<
String
>
callable
=
()
->
{
...
...
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java
浏览文件 @
86b7118d
...
...
@@ -158,7 +158,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
*
@r
eturn the STOMP message broker host.
*
R
eturn the STOMP message broker host.
*/
public
String
getRelayHost
()
{
return
this
.
relayHost
;
...
...
@@ -172,7 +172,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
*
@r
eturn the STOMP message broker port.
*
R
eturn the STOMP message broker port.
*/
public
int
getRelayPort
()
{
return
this
.
relayPort
;
...
...
@@ -190,7 +190,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
*
@return T
he interval, in milliseconds, at which the "system" connection will
*
Return t
he interval, in milliseconds, at which the "system" connection will
* send heartbeats to the STOMP broker.
*/
public
long
getSystemHeartbeatSendInterval
()
{
...
...
@@ -210,7 +210,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
*
@return T
he interval, in milliseconds, at which the "system" connection expects
*
Return t
he interval, in milliseconds, at which the "system" connection expects
* to receive heartbeats from the STOMP broker.
*/
public
long
getSystemHeartbeatReceiveInterval
()
{
...
...
@@ -238,9 +238,9 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
* Set the client
P
asscode to use to create connections to the STOMP broker on
* Set the client
p
asscode to use to create connections to the STOMP broker on
* behalf of connected clients.
* <p>
By default this is set to "guest".
* <p>By default this is set to "guest".
* @see #setSystemPasscode
*/
public
void
setClientPasscode
(
String
clientPasscode
)
{
...
...
@@ -249,7 +249,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
* Return the configured pass
oc
de to use for connections to the STOMP broker on
* Return the configured pass
co
de to use for connections to the STOMP broker on
* behalf of connected clients.
* @see #getSystemPasscode()
*/
...
...
@@ -269,7 +269,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
* Return the login used for the shared "system" connection to the STOMP broker
* Return the login used for the shared "system" connection to the STOMP broker
.
*/
public
String
getSystemLogin
()
{
return
this
.
systemLogin
;
...
...
@@ -286,7 +286,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
*
@return the passcode used for the shared "system" connection to the STOMP broker
*
Return the passcode used for the shared "system" connection to the STOMP broker.
*/
public
String
getSystemPasscode
()
{
return
this
.
systemPasscode
;
...
...
@@ -305,7 +305,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
/**
*
@r
eturn the configured virtual host value.
*
R
eturn the configured virtual host value.
*/
public
String
getVirtualHost
()
{
return
this
.
virtualHost
;
...
...
@@ -419,7 +419,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
"receive BrokerAvailabilityEvent's from an ApplicationListener Spring bean."
);
}
SimpMessageType
messageType
=
SimpMessageHeaderAccessor
.
getMessageType
(
message
.
getHeaders
());
if
(
logger
.
isErrorEnabled
()
&&
messageType
.
equals
(
SimpMessageType
.
CONNECT
))
{
if
(
logger
.
isErrorEnabled
()
&&
SimpMessageType
.
CONNECT
.
equals
(
messageType
))
{
logger
.
error
(
"Broker not active. Ignoring "
+
message
);
}
else
if
(
logger
.
isDebugEnabled
())
{
...
...
@@ -464,7 +464,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
String
destination
=
stompAccessor
.
getDestination
();
if
(
(
command
!=
null
)
&&
command
.
requiresDestination
()
&&
!
checkDestinationPrefix
(
destination
))
{
if
(
command
!=
null
&&
command
.
requiresDestination
()
&&
!
checkDestinationPrefix
(
destination
))
{
return
;
}
...
...
@@ -673,12 +673,12 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
@Override
public
void
handleFailure
(
Throwable
failure
)
{
public
void
handleFailure
(
Throwable
ex
)
{
if
(
this
.
tcpConnection
!=
null
)
{
handleTcpConnectionFailure
(
"transport failure."
,
failure
);
handleTcpConnectionFailure
(
"transport failure."
,
ex
);
}
else
if
(
logger
.
isErrorEnabled
())
{
logger
.
error
(
"Transport failure: "
+
failure
);
logger
.
error
(
"Transport failure: "
+
ex
);
}
}
...
...
@@ -699,7 +699,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
this
.
tcpConnection
=
null
;
clearConnection
();
}
catch
(
Throwable
t
)
{
catch
(
Throwable
ex
)
{
// Shouldn't happen with connection reset beforehand
}
}
...
...
@@ -742,7 +742,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
(
conn
!=
null
?
"before STOMP CONNECTED. "
:
"while inactive. "
)
+
"Consider subscribing to receive BrokerAvailabilityEvent's from "
+
"an ApplicationListener Spring bean. Dropped "
+
accessor
.
getShortLogMessage
(
(
byte
[])
message
.
getPayload
()));
accessor
.
getShortLogMessage
(
message
.
getPayload
()));
}
}
...
...
@@ -842,8 +842,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
}
@Override
protected
void
handleTcpConnectionFailure
(
String
error
,
Throwable
t
)
{
super
.
handleTcpConnectionFailure
(
error
,
t
);
protected
void
handleTcpConnectionFailure
(
String
error
Message
,
Throwable
ex
)
{
super
.
handleTcpConnectionFailure
(
error
Message
,
ex
);
publishBrokerUnavailableEvent
();
}
...
...
spring-web/src/main/java/org/springframework/http/HttpEntity.java
浏览文件 @
86b7118d
/*
* 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.
...
...
@@ -138,20 +138,20 @@ public class HttpEntity<T> {
@Override
public
int
hashCode
()
{
return
ObjectUtils
.
nullSafeHashCode
(
this
.
headers
)
*
29
+
ObjectUtils
.
nullSafeHashCode
(
this
.
body
);
return
(
ObjectUtils
.
nullSafeHashCode
(
this
.
headers
)
*
29
+
ObjectUtils
.
nullSafeHashCode
(
this
.
body
)
);
}
@Override
public
String
toString
()
{
StringBuilder
builder
=
new
StringBuilder
(
"<"
);
if
(
body
!=
null
)
{
builder
.
append
(
body
);
if
(
headers
!=
null
)
{
if
(
this
.
body
!=
null
)
{
builder
.
append
(
this
.
body
);
if
(
this
.
headers
!=
null
)
{
builder
.
append
(
','
);
}
}
if
(
headers
!=
null
)
{
builder
.
append
(
headers
);
if
(
this
.
headers
!=
null
)
{
builder
.
append
(
this
.
headers
);
}
builder
.
append
(
'>'
);
return
builder
.
toString
();
...
...
spring-web/src/main/java/org/springframework/http/RequestEntity.java
浏览文件 @
86b7118d
...
...
@@ -128,20 +128,20 @@ public class RequestEntity<T> extends HttpEntity<T> {
if
(
this
==
other
)
{
return
true
;
}
if
(!(
other
instanceof
RequestEntity
))
{
if
(!(
other
instanceof
RequestEntity
)
||
!
super
.
equals
(
other
)
)
{
return
false
;
}
RequestEntity
<?>
otherEntity
=
(
RequestEntity
<?>)
other
;
return
(
ObjectUtils
.
nullSafeEquals
(
this
.
method
,
otherEntity
.
method
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
url
,
otherEntity
.
url
)
&&
super
.
equals
(
other
));
ObjectUtils
.
nullSafeEquals
(
this
.
url
,
otherEntity
.
url
));
}
@Override
public
int
hashCode
()
{
return
29
*
super
.
hashCode
()
+
29
*
ObjectUtils
.
nullSafeHashCode
(
this
.
method
)
+
ObjectUtils
.
nullSafeHashCode
(
this
.
url
);
int
hashCode
=
super
.
hashCode
();
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
method
);
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
url
);
return
hashCode
;
}
@Override
...
...
@@ -166,6 +166,7 @@ public class RequestEntity<T> extends HttpEntity<T> {
return
builder
.
toString
();
}
// Static builder methods
/**
...
...
@@ -422,6 +423,7 @@ public class RequestEntity<T> extends HttpEntity<T> {
return
method
(
HttpMethod
.
OPTIONS
,
url
);
}
/**
* Defines a builder that adds headers to the request entity.
* @param <B> the builder subclass
...
...
@@ -471,9 +473,9 @@ public class RequestEntity<T> extends HttpEntity<T> {
* @see BodyBuilder#body(Object)
*/
RequestEntity
<
Void
>
build
();
}
/**
* Defines a builder that adds a body to the response entity.
*/
...
...
@@ -504,9 +506,9 @@ public class RequestEntity<T> extends HttpEntity<T> {
* @return the built request entity
*/
<
T
>
RequestEntity
<
T
>
body
(
T
body
);
}
private
static
class
DefaultBodyBuilder
implements
BodyBuilder
{
private
final
HttpMethod
method
;
...
...
@@ -515,7 +517,6 @@ public class RequestEntity<T> extends HttpEntity<T> {
private
final
HttpHeaders
headers
=
new
HttpHeaders
();
public
DefaultBodyBuilder
(
HttpMethod
method
,
URI
url
)
{
this
.
method
=
method
;
this
.
url
=
url
;
...
...
spring-web/src/main/java/org/springframework/http/ResponseEntity.java
浏览文件 @
86b7118d
...
...
@@ -121,16 +121,16 @@ public class ResponseEntity<T> extends HttpEntity<T> {
if
(
this
==
other
)
{
return
true
;
}
if
(!(
other
instanceof
ResponseEntity
))
{
if
(!(
other
instanceof
ResponseEntity
)
||
!
super
.
equals
(
other
)
)
{
return
false
;
}
ResponseEntity
<?>
otherEntity
=
(
ResponseEntity
<?>)
other
;
return
(
ObjectUtils
.
nullSafeEquals
(
this
.
statusCode
,
otherEntity
.
statusCode
)
&&
super
.
equals
(
other
)
);
return
ObjectUtils
.
nullSafeEquals
(
this
.
statusCode
,
otherEntity
.
statusCode
);
}
@Override
public
int
hashCode
()
{
return
super
.
hashCode
()
*
29
+
ObjectUtils
.
nullSafeHashCode
(
this
.
statusCode
);
return
(
super
.
hashCode
()
*
29
+
ObjectUtils
.
nullSafeHashCode
(
this
.
statusCode
)
);
}
@Override
...
...
spring-web/src/main/java/org/springframework/web/client/RestOperations.java
浏览文件 @
86b7118d
/*
* 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.
...
...
@@ -107,6 +107,7 @@ public interface RestOperations {
*/
<
T
>
ResponseEntity
<
T
>
getForEntity
(
URI
url
,
Class
<
T
>
responseType
)
throws
RestClientException
;
// HEAD
/**
...
...
@@ -134,6 +135,7 @@ public interface RestOperations {
*/
HttpHeaders
headForHeaders
(
URI
url
)
throws
RestClientException
;
// POST
/**
...
...
@@ -266,6 +268,7 @@ public interface RestOperations {
*/
<
T
>
ResponseEntity
<
T
>
postForEntity
(
URI
url
,
Object
request
,
Class
<
T
>
responseType
)
throws
RestClientException
;
// PUT
/**
...
...
@@ -302,6 +305,7 @@ public interface RestOperations {
*/
void
put
(
URI
url
,
Object
request
)
throws
RestClientException
;
// DELETE
/**
...
...
@@ -327,6 +331,7 @@ public interface RestOperations {
*/
void
delete
(
URI
url
)
throws
RestClientException
;
// OPTIONS
/**
...
...
@@ -354,6 +359,7 @@ public interface RestOperations {
*/
Set
<
HttpMethod
>
optionsForAllow
(
URI
url
)
throws
RestClientException
;
// exchange
/**
...
...
@@ -403,12 +409,10 @@ public interface RestOperations {
* Execute the HTTP method to the given URI template, writing the given
* request entity to the request, and returns the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
*
* <pre class="code">
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
* </pre>
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the
...
...
@@ -416,7 +420,7 @@ public interface RestOperations {
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity
* @since 3.2
.0
* @since 3.2
*/
<
T
>
ResponseEntity
<
T
>
exchange
(
String
url
,
HttpMethod
method
,
HttpEntity
<?>
requestEntity
,
ParameterizedTypeReference
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
;
...
...
@@ -425,19 +429,17 @@ public interface RestOperations {
* Execute the HTTP method to the given URI template, writing the given
* request entity to the request, and returns the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
*
* <pre class="code">
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
* </pre>
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity
* @since 3.2
.0
* @since 3.2
*/
<
T
>
ResponseEntity
<
T
>
exchange
(
String
url
,
HttpMethod
method
,
HttpEntity
<?>
requestEntity
,
ParameterizedTypeReference
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
;
...
...
@@ -446,18 +448,16 @@ public interface RestOperations {
* Execute the HTTP method to the given URI template, writing the given
* request entity to the request, and returns the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
*
* <pre class="code">
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
* </pre>
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
* @param responseType the type of the return value
* @return the response as entity
* @since 3.2
.0
* @since 3.2
*/
<
T
>
ResponseEntity
<
T
>
exchange
(
URI
url
,
HttpMethod
method
,
HttpEntity
<?>
requestEntity
,
ParameterizedTypeReference
<
T
>
responseType
)
throws
RestClientException
;
...
...
@@ -466,40 +466,35 @@ public interface RestOperations {
* Execute the request specified in the given {@link RequestEntity} and return
* the response as {@link ResponseEntity}. Typically used in combination
* with the static builder methods on {@code RequestEntity}, for instance:
*
* <pre class="code">
* MyRequest body = ...
* RequestEntity request = RequestEntity.post("http://example.com/{foo}", "bar").accept(MediaType.APPLICATION_JSON).body(body);
* ResponseEntity<MyResponse> response = template.exchange(request, MyResponse.class);
* </pre>
*
* @param requestEntity the entity to write to the request
* @param responseType the type of the return value
* @return the response as entity
* @since 4.1
*/
<
T
>
ResponseEntity
<
T
>
exchange
(
RequestEntity
<?>
requestEntity
,
Class
<
T
>
responseType
)
throws
RestClientException
;
<
T
>
ResponseEntity
<
T
>
exchange
(
RequestEntity
<?>
requestEntity
,
Class
<
T
>
responseType
)
throws
RestClientException
;
/**
* Execute the request specified in the given {@link RequestEntity} and return
* the response as {@link ResponseEntity}. The given
* {@link ParameterizedTypeReference} is used to pass generic type information:
*
* <pre class="code">
* MyRequest body = ...
* RequestEntity request = RequestEntity.post("http://example.com/{foo}", "bar").accept(MediaType.APPLICATION_JSON).body(body);
* ParameterizedTypeReference<List<MyResponse>> myBean = new ParameterizedTypeReference<List<MyResponse>>() {};
* ResponseEntity<List<MyResponse>> response = template.exchange(request, myBean);
* </pre>
*
* @param requestEntity the entity to write to the request
* @param responseType the type of the return value
* @return the response as entity
* @since 4.1
*/
<
T
>
ResponseEntity
<
T
>
exchange
(
RequestEntity
<?>
requestEntity
,
ParameterizedTypeReference
<
T
>
responseType
)
throws
RestClientException
;
<
T
>
ResponseEntity
<
T
>
exchange
(
RequestEntity
<?>
requestEntity
,
ParameterizedTypeReference
<
T
>
responseType
)
throws
RestClientException
;
// general execution
...
...
spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
浏览文件 @
86b7118d
...
...
@@ -269,6 +269,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
return
execute
(
url
,
HttpMethod
.
GET
,
requestCallback
,
responseExtractor
);
}
// HEAD
@Override
...
...
@@ -286,6 +287,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
return
execute
(
url
,
HttpMethod
.
HEAD
,
null
,
headersExtractor
());
}
// POST
@Override
...
...
@@ -362,6 +364,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
return
execute
(
url
,
HttpMethod
.
POST
,
requestCallback
,
responseExtractor
);
}
// PUT
@Override
...
...
@@ -382,6 +385,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
execute
(
url
,
HttpMethod
.
PUT
,
requestCallback
,
null
);
}
// DELETE
@Override
...
...
@@ -399,6 +403,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
execute
(
url
,
HttpMethod
.
DELETE
,
null
,
null
);
}
// OPTIONS
@Override
...
...
@@ -422,6 +427,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
return
headers
.
getAllow
();
}
// exchange
@Override
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
浏览文件 @
86b7118d
...
...
@@ -148,8 +148,9 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
public
static
final
String
CONTENT_NEGOTIATION_MANAGER_BEAN_NAME
=
"mvcContentNegotiationManager"
;
private
static
final
boolean
javaxValidationPresent
=
ClassUtils
.
isPresent
(
"javax.validation.Validator"
,
AnnotationDrivenBeanDefinitionParser
.
class
.
getClassLoader
());
private
static
final
boolean
javaxValidationPresent
=
ClassUtils
.
isPresent
(
"javax.validation.Validator"
,
AnnotationDrivenBeanDefinitionParser
.
class
.
getClassLoader
());
private
static
boolean
romePresent
=
ClassUtils
.
isPresent
(
"com.rometools.rome.feed.WireFeed"
,
AnnotationDrivenBeanDefinitionParser
.
class
.
getClassLoader
());
...
...
@@ -532,12 +533,14 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
messageConverters
.
add
(
createConverterDefinition
(
AtomFeedHttpMessageConverter
.
class
,
source
));
messageConverters
.
add
(
createConverterDefinition
(
RssChannelHttpMessageConverter
.
class
,
source
));
}
if
(
jackson2XmlPresent
)
{
if
(
jackson2XmlPresent
)
{
messageConverters
.
add
(
createConverterDefinition
(
MappingJackson2XmlHttpMessageConverter
.
class
,
source
));
}
else
if
(
jaxb2Present
)
{
messageConverters
.
add
(
createConverterDefinition
(
Jaxb2RootElementHttpMessageConverter
.
class
,
source
));
}
if
(
jackson2Present
)
{
messageConverters
.
add
(
createConverterDefinition
(
MappingJackson2HttpMessageConverter
.
class
,
source
));
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java
浏览文件 @
86b7118d
...
...
@@ -51,8 +51,8 @@ import org.springframework.web.servlet.resource.VersionResourceResolver;
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a
* {@code resources} element to register a {@link ResourceHttpRequestHandler} and
* register a {@link SimpleUrlHandlerMapping} for mapping resource requests,
* and a {@link HttpRequestHandlerAdapter}.
*
Will also create a resource handling
chain with {@link ResourceResolver}s and {@link ResourceTransformer}s.
* and a {@link HttpRequestHandlerAdapter}.
Will also create a resource handling
* chain with {@link ResourceResolver}s and {@link ResourceTransformer}s.
*
* @author Keith Donald
* @author Jeremy Grelle
...
...
@@ -62,11 +62,16 @@ import org.springframework.web.servlet.resource.VersionResourceResolver;
class
ResourcesBeanDefinitionParser
implements
BeanDefinitionParser
{
private
static
final
String
RESOURCE_CHAIN_CACHE
=
"spring-resource-chain-cache"
;
private
static
final
String
VERSION_RESOLVER_ELEMENT
=
"version-resolver"
;
private
static
final
String
VERSION_STRATEGY_ELEMENT
=
"version-strategy"
;
private
static
final
String
FIXED_VERSION_STRATEGY_ELEMENT
=
"fixed-version-strategy"
;
private
static
final
String
CONTENT_VERSION_STRATEGY_ELEMENT
=
"content-version-strategy"
;
@Override
public
BeanDefinition
parse
(
Element
element
,
ParserContext
parserContext
)
{
Object
source
=
parserContext
.
extractSource
(
element
);
...
...
@@ -129,7 +134,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
}
Element
resourceChainElement
=
DomUtils
.
getChildElementByTagName
(
element
,
"resource-chain"
);
if
(
resourceChainElement
!=
null
)
{
if
(
resourceChainElement
!=
null
)
{
parseResourceChain
(
resourceHandlerDef
,
parserContext
,
resourceChainElement
,
source
);
}
...
...
@@ -152,8 +157,8 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
resourceTransformers
.
setSource
(
source
);
parseResourceCache
(
resourceResolvers
,
resourceTransformers
,
element
,
source
);
parseResourceResolversTransformers
(
isAutoRegistration
,
resourceResolvers
,
resourceTransformers
,
parserContext
,
element
,
source
);
parseResourceResolversTransformers
(
isAutoRegistration
,
resourceResolvers
,
resourceTransformers
,
parserContext
,
element
,
source
);
if
(!
resourceResolvers
.
isEmpty
())
{
resourceHandlerDef
.
getPropertyValues
().
add
(
"resourceResolvers"
,
resourceResolvers
);
...
...
@@ -164,11 +169,10 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
}
private
void
parseResourceCache
(
ManagedList
<?
super
Object
>
resourceResolvers
,
ManagedList
<?
super
Object
>
resourceTransformers
,
Element
element
,
Object
source
)
{
ManagedList
<?
super
Object
>
resourceTransformers
,
Element
element
,
Object
source
)
{
Element
resourceCacheElement
=
DomUtils
.
getChildElementByTagName
(
element
,
"resource-cache"
);
if
(
resourceCacheElement
!=
null
)
{
if
(
resourceCacheElement
!=
null
)
{
ConstructorArgumentValues
cavs
=
new
ConstructorArgumentValues
();
RootBeanDefinition
cachingResolverDef
=
new
RootBeanDefinition
(
CachingResourceResolver
.
class
);
...
...
@@ -191,7 +195,6 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
else
{
ConstructorArgumentValues
cacheCavs
=
new
ConstructorArgumentValues
();
cacheCavs
.
addIndexedArgumentValue
(
0
,
RESOURCE_CHAIN_CACHE
);
RootBeanDefinition
cacheDef
=
new
RootBeanDefinition
(
ConcurrentMapCache
.
class
);
cacheDef
.
setSource
(
source
);
cacheDef
.
setRole
(
BeanDefinition
.
ROLE_INFRASTRUCTURE
);
...
...
@@ -211,25 +214,25 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
Element
resolversElement
=
DomUtils
.
getChildElementByTagName
(
element
,
"resolvers"
);
if
(
resolversElement
!=
null
)
{
for
(
Element
beanElement
:
DomUtils
.
getChildElements
(
resolversElement
))
{
if
(
VERSION_RESOLVER_ELEMENT
.
equals
(
beanElement
.
getLocalName
()))
{
if
(
VERSION_RESOLVER_ELEMENT
.
equals
(
beanElement
.
getLocalName
()))
{
RootBeanDefinition
versionResolverDef
=
parseVersionResolver
(
parserContext
,
beanElement
,
source
);
versionResolverDef
.
setSource
(
source
);
resourceResolvers
.
add
(
versionResolverDef
);
if
(
isAutoRegistration
)
{
if
(
isAutoRegistration
)
{
RootBeanDefinition
cssLinkTransformerDef
=
new
RootBeanDefinition
(
CssLinkResourceTransformer
.
class
);
cssLinkTransformerDef
.
setSource
(
source
);
cssLinkTransformerDef
.
setRole
(
BeanDefinition
.
ROLE_INFRASTRUCTURE
);
resourceTransformers
.
add
(
cssLinkTransformerDef
);
}
}
else
{
}
else
{
Object
object
=
parserContext
.
getDelegate
().
parsePropertySubElement
(
beanElement
,
null
);
resourceResolvers
.
add
(
object
);
}
}
}
if
(
isAutoRegistration
)
{
if
(
isAutoRegistration
)
{
RootBeanDefinition
pathResolverDef
=
new
RootBeanDefinition
(
PathResourceResolver
.
class
);
pathResolverDef
.
setSource
(
source
);
pathResolverDef
.
setRole
(
BeanDefinition
.
ROLE_INFRASTRUCTURE
);
...
...
@@ -256,7 +259,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
for
(
Element
beanElement
:
DomUtils
.
getChildElements
(
element
))
{
String
[]
patterns
=
StringUtils
.
commaDelimitedListToStringArray
(
beanElement
.
getAttribute
(
"patterns"
));
Object
strategy
=
null
;
if
(
FIXED_VERSION_STRATEGY_ELEMENT
.
equals
(
beanElement
.
getLocalName
()))
{
if
(
FIXED_VERSION_STRATEGY_ELEMENT
.
equals
(
beanElement
.
getLocalName
()))
{
ConstructorArgumentValues
cavs
=
new
ConstructorArgumentValues
();
cavs
.
addIndexedArgumentValue
(
0
,
beanElement
.
getAttribute
(
"version"
));
RootBeanDefinition
strategyDef
=
new
RootBeanDefinition
(
FixedVersionStrategy
.
class
);
...
...
@@ -282,4 +285,5 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
return
versionResolverDef
;
}
}
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
浏览文件 @
86b7118d
...
...
@@ -66,7 +66,10 @@ import org.springframework.web.context.ServletContextAware;
import
org.springframework.web.method.support.CompositeUriComponentsContributor
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.method.support.HandlerMethodReturnValueHandler
;
import
org.springframework.web.servlet.*
;
import
org.springframework.web.servlet.HandlerAdapter
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
org.springframework.web.servlet.HandlerMapping
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.handler.AbstractHandlerMapping
;
import
org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
;
import
org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor
;
...
...
@@ -657,12 +660,14 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
messageConverters
.
add
(
new
AtomFeedHttpMessageConverter
());
messageConverters
.
add
(
new
RssChannelHttpMessageConverter
());
}
if
(
jackson2XmlPresent
)
{
if
(
jackson2XmlPresent
)
{
messageConverters
.
add
(
new
MappingJackson2XmlHttpMessageConverter
());
}
else
if
(
jaxb2Present
)
{
messageConverters
.
add
(
new
Jaxb2RootElementHttpMessageConverter
());
}
if
(
jackson2Present
)
{
messageConverters
.
add
(
new
MappingJackson2HttpMessageConverter
());
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMethodMappingNamingStrategy.java
浏览文件 @
86b7118d
...
...
@@ -41,10 +41,8 @@ public interface HandlerMethodMappingNamingStrategy<T> {
/**
* Determine the name for the given HandlerMethod and mapping.
*
* @param handlerMethod the handler method
* @param mapping the mapping
*
* @return the name
*/
String
getName
(
HandlerMethod
handlerMethod
,
T
mapping
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/ParameterizableViewController.java
浏览文件 @
86b7118d
...
...
@@ -81,15 +81,12 @@ public class ParameterizableViewController extends AbstractController {
/**
* Configure the HTTP status code that this controller should set on the
* response.
*
* <p>When a "redirect:" prefixed view name is configured, there is no need
* to set this property since RedirectView will do that. However this property
* may still be used to override the 3xx status code of {@code RedirectView}.
* For full control over redirecting provide a {@code RedirectView} instance.
*
* <p>If the status code is 204 and no view is configured, the request is
* fully handled within the controller.
*
* @since 4.1
*/
public
void
setStatusCode
(
HttpStatus
statusCode
)
{
...
...
@@ -123,12 +120,11 @@ public class ParameterizableViewController extends AbstractController {
return
this
.
statusOnly
;
}
/**
* Return a ModelAndView object with the specified view name.
*
* <p>The content of the {@link RequestContextUtils#getInputFlashMap
* "input" FlashMap} is also added to the model.
*
* @see #getViewName()
*/
@Override
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java
浏览文件 @
86b7118d
...
...
@@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -382,10 +381,8 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
* @since 4.1
*/
protected
void
appendCurrentQueryParams
(
StringBuilder
targetUrl
,
HttpServletRequest
request
)
{
String
query
=
request
.
getQueryString
();
if
(
StringUtils
.
hasText
(
query
))
{
// Extract anchor fragment, if any.
String
fragment
=
null
;
int
anchorIndex
=
targetUrl
.
indexOf
(
"#"
);
...
...
@@ -400,7 +397,6 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
else
{
targetUrl
.
append
(
'&'
).
append
(
query
);
}
// Append anchor fragment, if any, to end of URL.
if
(
fragment
!=
null
)
{
targetUrl
.
append
(
fragment
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/view/ViewResolverComposite.java
浏览文件 @
86b7118d
...
...
@@ -16,6 +16,12 @@
package
org.springframework.web.servlet.view
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Locale
;
import
javax.servlet.ServletContext
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.context.ApplicationContext
;
...
...
@@ -26,12 +32,6 @@ import org.springframework.web.context.ServletContextAware;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.ViewResolver
;
import
javax.servlet.ServletContext
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Locale
;
/**
* A {@link org.springframework.web.servlet.ViewResolver} that delegates to others.
*
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java
浏览文件 @
86b7118d
...
...
@@ -82,6 +82,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
super
(
new
ObjectMapper
(),
DEFAULT_CONTENT_TYPE
);
}
/**
* Specify a custom prefix to use for this view's JSON output.
* Default is none.
...
...
@@ -207,9 +208,10 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
Object
value
=
super
.
filterAndWrapModel
(
model
,
request
);
String
jsonpParameterValue
=
getJsonpParameterValue
(
request
);
if
(
jsonpParameterValue
!=
null
)
{
if
(
value
instanceof
MappingJacksonValue
)
{
if
(
value
instanceof
MappingJacksonValue
)
{
((
MappingJacksonValue
)
value
).
setJsonpFunction
(
jsonpParameterValue
);
}
else
{
}
else
{
MappingJacksonValue
container
=
new
MappingJacksonValue
(
value
);
container
.
setJsonpFunction
(
jsonpParameterValue
);
value
=
container
;
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlView.java
浏览文件 @
86b7118d
...
...
@@ -50,6 +50,7 @@ public class MappingJackson2XmlView extends AbstractJackson2View {
super
(
new
XmlMapper
(),
DEFAULT_CONTENT_TYPE
);
}
/**
* {@inheritDoc}
*/
...
...
@@ -73,11 +74,11 @@ public class MappingJackson2XmlView extends AbstractJackson2View {
throw
new
IllegalStateException
(
"Model contains no object with key ["
+
this
.
modelKey
+
"]"
);
}
}
else
{
}
else
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
model
.
entrySet
())
{
if
(!(
entry
.
getValue
()
instanceof
BindingResult
)
&&
!
entry
.
getKey
().
equals
(
JsonView
.
class
.
getName
()))
{
if
(
value
!=
null
)
{
if
(!(
entry
.
getValue
()
instanceof
BindingResult
)
&&
!
entry
.
getKey
().
equals
(
JsonView
.
class
.
getName
()))
{
if
(
value
!=
null
)
{
throw
new
IllegalStateException
(
"Model contains more than one object to render, only one is supported"
);
}
value
=
entry
.
getValue
();
...
...
@@ -87,4 +88,4 @@ public class MappingJackson2XmlView extends AbstractJackson2View {
return
value
;
}
}
\ No newline at end of file
}
spring-websocket/src/main/java/org/springframework/web/socket/client/WebSocketConnectionManager.java
浏览文件 @
86b7118d
...
...
@@ -23,9 +23,9 @@ import org.springframework.http.HttpHeaders;
import
org.springframework.util.concurrent.ListenableFuture
;
import
org.springframework.util.concurrent.ListenableFutureCallback
;
import
org.springframework.web.socket.WebSocketHandler
;
import
org.springframework.web.socket.WebSocketHttpHeaders
;
import
org.springframework.web.socket.WebSocketSession
;
import
org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator
;
import
org.springframework.web.socket.WebSocketHttpHeaders
;
/**
* A WebSocket connection manager that is given a URI, a {@link WebSocketClient}, and a
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录