Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
31c56446
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 搜索 >>
提交
31c56446
编写于
8月 30, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ResponseStatusExceptionHandler in web.server.handler (plus related polishing)
上级
4ef428de
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
49 addition
and
47 deletion
+49
-47
spring-web-reactive/src/main/java/org/springframework/web/reactive/DispatcherHandler.java
...a/org/springframework/web/reactive/DispatcherHandler.java
+2
-4
spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerAdapter.java
...java/org/springframework/web/reactive/HandlerAdapter.java
+1
-5
spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerMapping.java
...java/org/springframework/web/reactive/HandlerMapping.java
+3
-2
spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerResultHandler.java
...rg/springframework/web/reactive/HandlerResultHandler.java
+2
-4
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java
...ctive/result/SimpleUrlHandlerMappingIntegrationTests.java
+1
-1
spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java
...work/web/server/MediaTypeNotSupportedStatusException.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java
...springframework/web/server/MethodNotAllowedException.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java
...ingframework/web/server/NotAcceptableStatusException.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java
...g/springframework/web/server/ResponseStatusException.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/ServerErrorException.java
.../org/springframework/web/server/ServerErrorException.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java
...ava/org/springframework/web/server/ServerWebExchange.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/ServerWebInputException.java
...g/springframework/web/server/ServerWebInputException.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java
...ework/web/server/UnsupportedMediaTypeStatusException.java
+1
-0
spring-web/src/main/java/org/springframework/web/server/WebExceptionHandler.java
...a/org/springframework/web/server/WebExceptionHandler.java
+2
-2
spring-web/src/main/java/org/springframework/web/server/WebFilter.java
...c/main/java/org/springframework/web/server/WebFilter.java
+0
-1
spring-web/src/main/java/org/springframework/web/server/WebFilterChain.java
...n/java/org/springframework/web/server/WebFilterChain.java
+1
-1
spring-web/src/main/java/org/springframework/web/server/WebHandler.java
.../main/java/org/springframework/web/server/WebHandler.java
+1
-2
spring-web/src/main/java/org/springframework/web/server/WebSession.java
.../main/java/org/springframework/web/server/WebSession.java
+2
-1
spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java
...ramework/web/server/adapter/DefaultServerWebExchange.java
+5
-4
spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java
...ngframework/web/server/adapter/HttpWebHandlerAdapter.java
+4
-4
spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java
...ngframework/web/server/adapter/WebHttpHandlerBuilder.java
+1
-1
spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java
...ework/web/server/handler/ExceptionHandlingWebHandler.java
+2
-2
spring-web/src/main/java/org/springframework/web/server/handler/FilteringWebHandler.java
...ringframework/web/server/handler/FilteringWebHandler.java
+3
-3
spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java
...rk/web/server/handler/ResponseStatusExceptionHandler.java
+4
-4
spring-web/src/main/java/org/springframework/web/server/handler/WebHandlerDecorator.java
...ringframework/web/server/handler/WebHandlerDecorator.java
+3
-2
spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java
...b/server/handler/ResponseStatusExceptionHandlerTests.java
+4
-4
未找到文件。
spring-web-reactive/src/main/java/org/springframework/web/reactive/DispatcherHandler.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -84,9 +84,7 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
...
@@ -84,9 +84,7 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
initStrategies
(
applicationContext
);
initStrategies
(
applicationContext
);
}
}
protected
void
initStrategies
(
ApplicationContext
context
)
{
protected
void
initStrategies
(
ApplicationContext
context
)
{
Map
<
String
,
HandlerMapping
>
mappingBeans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
Map
<
String
,
HandlerMapping
>
mappingBeans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
context
,
HandlerMapping
.
class
,
true
,
false
);
context
,
HandlerMapping
.
class
,
true
,
false
);
...
@@ -145,4 +143,4 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
...
@@ -145,4 +143,4 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
throw
new
IllegalStateException
(
"No HandlerResultHandler for "
+
handlerResult
.
getReturnValue
());
throw
new
IllegalStateException
(
"No HandlerResultHandler for "
+
handlerResult
.
getReturnValue
());
}
}
}
}
\ No newline at end of file
spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerAdapter.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -34,7 +34,6 @@ public interface HandlerAdapter {
...
@@ -34,7 +34,6 @@ public interface HandlerAdapter {
/**
/**
* Whether this {@code HandlerAdapter} supports the given {@code handler}.
* Whether this {@code HandlerAdapter} supports the given {@code handler}.
*
* @param handler handler object to check
* @param handler handler object to check
* @return whether or not the handler is supported
* @return whether or not the handler is supported
*/
*/
...
@@ -42,17 +41,14 @@ public interface HandlerAdapter {
...
@@ -42,17 +41,14 @@ public interface HandlerAdapter {
/**
/**
* Handle the request with the given handler.
* Handle the request with the given handler.
*
* <p>Implementations are encouraged to handle exceptions resulting from the
* <p>Implementations are encouraged to handle exceptions resulting from the
* invocation of a handler in order and if necessary to return an alternate
* invocation of a handler in order and if necessary to return an alternate
* result that represents an error response.
* result that represents an error response.
*
* <p>Furthermore since an async {@code HandlerResult} may produce an error
* <p>Furthermore since an async {@code HandlerResult} may produce an error
* later during result handling implementations are also encouraged to
* later during result handling implementations are also encouraged to
* {@link HandlerResult#setExceptionHandler(Function) set an exception
* {@link HandlerResult#setExceptionHandler(Function) set an exception
* handler} on the {@code HandlerResult} so that may also be applied later
* handler} on the {@code HandlerResult} so that may also be applied later
* after result handling.
* after result handling.
*
* @param exchange current server exchange
* @param exchange current server exchange
* @param handler the selected handler which must have been previously
* @param handler the selected handler which must have been previously
* checked via {@link #supports(Object)}
* checked via {@link #supports(Object)}
...
...
spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerMapping.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -80,10 +80,11 @@ public interface HandlerMapping {
...
@@ -80,10 +80,11 @@ public interface HandlerMapping {
*/
*/
String
PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE
=
HandlerMapping
.
class
.
getName
()
+
".producibleMediaTypes"
;
String
PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE
=
HandlerMapping
.
class
.
getName
()
+
".producibleMediaTypes"
;
/**
/**
* Return a handler for this request.
* Return a handler for this request.
* @param exchange current server exchange
* @param exchange current server exchange
* @return
A
{@link Mono} that emits one value or none in case the request
* @return
a
{@link Mono} that emits one value or none in case the request
* cannot be resolved to a handler
* cannot be resolved to a handler
*/
*/
Mono
<
Object
>
getHandler
(
ServerWebExchange
exchange
);
Mono
<
Object
>
getHandler
(
ServerWebExchange
exchange
);
...
...
spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerResultHandler.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -31,7 +31,6 @@ public interface HandlerResultHandler {
...
@@ -31,7 +31,6 @@ public interface HandlerResultHandler {
/**
/**
* Whether this handler supports the given {@link HandlerResult}.
* Whether this handler supports the given {@link HandlerResult}.
*
* @param result result object to check
* @param result result object to check
* @return whether or not this object can use the given result
* @return whether or not this object can use the given result
*/
*/
...
@@ -40,11 +39,10 @@ public interface HandlerResultHandler {
...
@@ -40,11 +39,10 @@ public interface HandlerResultHandler {
/**
/**
* Process the given result modifying response headers and/or writing data
* Process the given result modifying response headers and/or writing data
* to the response.
* to the response.
*
* @param exchange current server exchange
* @param exchange current server exchange
* @param result the result from the handling
* @param result the result from the handling
* @return {@code Mono<Void>} to indicate when request handling is complete.
* @return {@code Mono<Void>} to indicate when request handling is complete.
*/
*/
Mono
<
Void
>
handleResult
(
ServerWebExchange
exchange
,
HandlerResult
result
);
Mono
<
Void
>
handleResult
(
ServerWebExchange
exchange
,
HandlerResult
result
);
}
}
\ No newline at end of file
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java
浏览文件 @
31c56446
...
@@ -39,7 +39,7 @@ import org.springframework.http.server.reactive.HttpHandler;
...
@@ -39,7 +39,7 @@ import org.springframework.http.server.reactive.HttpHandler;
import
org.springframework.web.client.HttpClientErrorException
;
import
org.springframework.web.client.HttpClientErrorException
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.reactive.DispatcherHandler
;
import
org.springframework.web.reactive.DispatcherHandler
;
import
org.springframework.web.
reactive
.ResponseStatusExceptionHandler
;
import
org.springframework.web.
server.handler
.ResponseStatusExceptionHandler
;
import
org.springframework.web.reactive.handler.SimpleUrlHandlerMapping
;
import
org.springframework.web.reactive.handler.SimpleUrlHandlerMapping
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
...
...
spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.util.Collections
;
import
java.util.Collections
;
...
...
spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.util.Collection
;
import
java.util.Collection
;
...
...
spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.util.Collections
;
import
java.util.Collections
;
...
...
spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
org.springframework.core.NestedRuntimeException
;
import
org.springframework.core.NestedRuntimeException
;
...
...
spring-web/src/main/java/org/springframework/web/server/ServerErrorException.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.util.Optional
;
import
java.util.Optional
;
...
...
spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.util.Map
;
import
java.util.Map
;
...
...
spring-web/src/main/java/org/springframework/web/server/ServerWebInputException.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.util.Optional
;
import
java.util.Optional
;
...
...
spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.util.Collections
;
import
java.util.Collections
;
...
...
spring-web/src/main/java/org/springframework/web/server/WebExceptionHandler.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
...
@@ -29,7 +30,6 @@ public interface WebExceptionHandler {
...
@@ -29,7 +30,6 @@ public interface WebExceptionHandler {
* Handle the given exception. A completion signal through the return value
* Handle the given exception. A completion signal through the return value
* indicates error handling is complete while an error signal indicates the
* indicates error handling is complete while an error signal indicates the
* exception is still not handled.
* exception is still not handled.
*
* @param exchange the current exchange
* @param exchange the current exchange
* @param ex the exception to handle
* @param ex the exception to handle
* @return {@code Mono<Void>} to indicate when exception handling is complete
* @return {@code Mono<Void>} to indicate when exception handling is complete
...
...
spring-web/src/main/java/org/springframework/web/server/WebFilter.java
浏览文件 @
31c56446
...
@@ -31,7 +31,6 @@ public interface WebFilter {
...
@@ -31,7 +31,6 @@ public interface WebFilter {
/**
/**
* Process the Web request and (optionally) delegate to the next
* Process the Web request and (optionally) delegate to the next
* {@code WebFilter} through the given {@link WebFilterChain}.
* {@code WebFilter} through the given {@link WebFilterChain}.
*
* @param exchange the current server exchange
* @param exchange the current server exchange
* @param chain provides a way to delegate to the next filter
* @param chain provides a way to delegate to the next filter
* @return {@code Mono<Void>} to indicate when request processing is complete
* @return {@code Mono<Void>} to indicate when request processing is complete
...
...
spring-web/src/main/java/org/springframework/web/server/WebFilterChain.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
...
@@ -27,7 +28,6 @@ public interface WebFilterChain {
...
@@ -27,7 +28,6 @@ public interface WebFilterChain {
/**
/**
* Delegate to the next {@code WebFilter} in the chain.
* Delegate to the next {@code WebFilter} in the chain.
*
* @param exchange the current server exchange
* @param exchange the current server exchange
* @return {@code Mono<Void>} to indicate when request handling is complete
* @return {@code Mono<Void>} to indicate when request handling is complete
*/
*/
...
...
spring-web/src/main/java/org/springframework/web/server/WebHandler.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -36,7 +36,6 @@ public interface WebHandler {
...
@@ -36,7 +36,6 @@ public interface WebHandler {
/**
/**
* Handle the web server exchange.
* Handle the web server exchange.
*
* @param exchange the current server exchange
* @param exchange the current server exchange
* @return {@code Mono<Void>} to indicate when request handling is complete
* @return {@code Mono<Void>} to indicate when request handling is complete
*/
*/
...
...
spring-web/src/main/java/org/springframework/web/server/WebSession.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server
;
package
org.springframework.web.server
;
import
java.time.Duration
;
import
java.time.Duration
;
...
...
spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server.adapter
;
package
org.springframework.web.server.adapter
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -48,9 +49,9 @@ public class DefaultServerWebExchange implements ServerWebExchange {
...
@@ -48,9 +49,9 @@ public class DefaultServerWebExchange implements ServerWebExchange {
public
DefaultServerWebExchange
(
ServerHttpRequest
request
,
ServerHttpResponse
response
,
public
DefaultServerWebExchange
(
ServerHttpRequest
request
,
ServerHttpResponse
response
,
WebSessionManager
sessionManager
)
{
WebSessionManager
sessionManager
)
{
Assert
.
notNull
(
request
,
"'request' is required
.
"
);
Assert
.
notNull
(
request
,
"'request' is required"
);
Assert
.
notNull
(
response
,
"'response' is required
.
"
);
Assert
.
notNull
(
response
,
"'response' is required"
);
Assert
.
notNull
(
response
,
"'sessionManager' is required
.
"
);
Assert
.
notNull
(
response
,
"'sessionManager' is required"
);
this
.
request
=
request
;
this
.
request
=
request
;
this
.
response
=
response
;
this
.
response
=
response
;
this
.
sessionMono
=
sessionManager
.
getSession
(
this
).
cache
();
this
.
sessionMono
=
sessionManager
.
getSession
(
this
).
cache
();
...
...
spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server.adapter
;
package
org.springframework.web.server.adapter
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
...
@@ -24,9 +25,9 @@ import org.springframework.http.server.reactive.HttpHandler;
...
@@ -24,9 +25,9 @@ import org.springframework.http.server.reactive.HttpHandler;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.handler.WebHandlerDecorator
;
import
org.springframework.web.server.handler.WebHandlerDecorator
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.session.DefaultWebSessionManager
;
import
org.springframework.web.server.session.DefaultWebSessionManager
;
import
org.springframework.web.server.session.WebSessionManager
;
import
org.springframework.web.server.session.WebSessionManager
;
...
@@ -43,7 +44,6 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
...
@@ -43,7 +44,6 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
private
static
Log
logger
=
LogFactory
.
getLog
(
HttpWebHandlerAdapter
.
class
);
private
static
Log
logger
=
LogFactory
.
getLog
(
HttpWebHandlerAdapter
.
class
);
private
WebSessionManager
sessionManager
=
new
DefaultWebSessionManager
();
private
WebSessionManager
sessionManager
=
new
DefaultWebSessionManager
();
...
@@ -60,7 +60,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
...
@@ -60,7 +60,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
* @param sessionManager the session manager to use
* @param sessionManager the session manager to use
*/
*/
public
void
setSessionManager
(
WebSessionManager
sessionManager
)
{
public
void
setSessionManager
(
WebSessionManager
sessionManager
)
{
Assert
.
notNull
(
sessionManager
,
"
'sessionManager' must not be null.
"
);
Assert
.
notNull
(
sessionManager
,
"
WebSessionManager must not be null
"
);
this
.
sessionManager
=
sessionManager
;
this
.
sessionManager
=
sessionManager
;
}
}
...
...
spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java
浏览文件 @
31c56446
...
@@ -66,7 +66,7 @@ public class WebHttpHandlerBuilder {
...
@@ -66,7 +66,7 @@ public class WebHttpHandlerBuilder {
* See factory method {@link #webHandler(WebHandler)}.
* See factory method {@link #webHandler(WebHandler)}.
*/
*/
private
WebHttpHandlerBuilder
(
WebHandler
targetHandler
)
{
private
WebHttpHandlerBuilder
(
WebHandler
targetHandler
)
{
Assert
.
notNull
(
targetHandler
,
"
'targetHandler'
must not be null"
);
Assert
.
notNull
(
targetHandler
,
"
WebHandler
must not be null"
);
this
.
targetHandler
=
targetHandler
;
this
.
targetHandler
=
targetHandler
;
}
}
...
...
spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server.handler
;
package
org.springframework.web.server.handler
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -24,9 +25,9 @@ import org.apache.commons.logging.LogFactory;
...
@@ -24,9 +25,9 @@ import org.apache.commons.logging.LogFactory;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebExceptionHandler
;
import
org.springframework.web.server.WebExceptionHandler
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.ServerWebExchange
;
/**
/**
* WebHandler that can invoke a target {@link WebHandler} and then apply
* WebHandler that can invoke a target {@link WebHandler} and then apply
...
@@ -39,7 +40,6 @@ public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
...
@@ -39,7 +40,6 @@ public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
private
static
Log
logger
=
LogFactory
.
getLog
(
ExceptionHandlingWebHandler
.
class
);
private
static
Log
logger
=
LogFactory
.
getLog
(
ExceptionHandlingWebHandler
.
class
);
private
final
List
<
WebExceptionHandler
>
exceptionHandlers
;
private
final
List
<
WebExceptionHandler
>
exceptionHandlers
;
...
...
spring-web/src/main/java/org/springframework/web/server/handler/FilteringWebHandler.java
浏览文件 @
31c56446
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server.handler
;
package
org.springframework.web.server.handler
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -21,10 +22,10 @@ import java.util.List;
...
@@ -21,10 +22,10 @@ import java.util.List;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebFilter
;
import
org.springframework.web.server.WebFilter
;
import
org.springframework.web.server.WebFilterChain
;
import
org.springframework.web.server.WebFilterChain
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.ServerWebExchange
;
/**
/**
* WebHandler that delegates to a chain of {@link WebFilter} instances and then
* WebHandler that delegates to a chain of {@link WebFilter} instances and then
...
@@ -44,7 +45,7 @@ public class FilteringWebHandler extends WebHandlerDecorator {
...
@@ -44,7 +45,7 @@ public class FilteringWebHandler extends WebHandlerDecorator {
}
}
private
static
List
<
WebFilter
>
initList
(
WebFilter
[]
list
)
{
private
static
List
<
WebFilter
>
initList
(
WebFilter
[]
list
)
{
return
(
list
!=
null
?
Collections
.
unmodifiableList
(
Arrays
.
asList
(
list
)):
Collections
.
emptyList
());
return
(
list
!=
null
?
Collections
.
unmodifiableList
(
Arrays
.
asList
(
list
))
:
Collections
.
emptyList
());
}
}
...
@@ -65,7 +66,6 @@ public class FilteringWebHandler extends WebHandlerDecorator {
...
@@ -65,7 +66,6 @@ public class FilteringWebHandler extends WebHandlerDecorator {
private
int
index
;
private
int
index
;
@Override
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
if
(
this
.
index
<
filters
.
size
())
{
if
(
this
.
index
<
filters
.
size
())
{
...
...
spring-web
-reactive/src/main/java/org/springframework/web/reactive
/ResponseStatusExceptionHandler.java
→
spring-web
/src/main/java/org/springframework/web/server/handler
/ResponseStatusExceptionHandler.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -13,13 +13,14 @@
...
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.reactive
;
package
org.springframework.web.server.handler
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
org.springframework.web.server.ResponseStatusException
;
import
org.springframework.web.server.ResponseStatusException
;
import
org.springframework.web.server.WebExceptionHandler
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebExceptionHandler
;
/**
/**
* Handle {@link ResponseStatusException} by setting the response status.
* Handle {@link ResponseStatusException} by setting the response status.
...
@@ -29,7 +30,6 @@ import org.springframework.web.server.ServerWebExchange;
...
@@ -29,7 +30,6 @@ import org.springframework.web.server.ServerWebExchange;
*/
*/
public
class
ResponseStatusExceptionHandler
implements
WebExceptionHandler
{
public
class
ResponseStatusExceptionHandler
implements
WebExceptionHandler
{
@Override
@Override
public
Mono
<
Void
>
handle
(
ServerWebExchange
exchange
,
Throwable
ex
)
{
public
Mono
<
Void
>
handle
(
ServerWebExchange
exchange
,
Throwable
ex
)
{
if
(
ex
instanceof
ResponseStatusException
)
{
if
(
ex
instanceof
ResponseStatusException
)
{
...
...
spring-web/src/main/java/org/springframework/web/server/handler/WebHandlerDecorator.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -13,13 +13,14 @@
...
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.server.handler
;
package
org.springframework.web.server.handler
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebHandler
;
/**
/**
* {@link WebHandler} that decorates and delegates to another.
* {@link WebHandler} that decorates and delegates to another.
...
...
spring-web
-reactive/src/test/java/org/springframework/web/reactive
/ResponseStatusExceptionHandlerTests.java
→
spring-web
/src/test/java/org/springframework/web/server/handler
/ResponseStatusExceptionHandlerTests.java
浏览文件 @
31c56446
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.springframework.web.reactive
;
package
org.springframework.web.server.handler
;
import
java.net.URI
;
import
java.net.URI
;
import
java.time.Duration
;
import
java.time.Duration
;
...
@@ -32,8 +33,7 @@ import org.springframework.web.server.ServerWebExchange;
...
@@ -32,8 +33,7 @@ import org.springframework.web.server.ServerWebExchange;
import
org.springframework.web.server.adapter.DefaultServerWebExchange
;
import
org.springframework.web.server.adapter.DefaultServerWebExchange
;
import
org.springframework.web.server.session.MockWebSessionManager
;
import
org.springframework.web.server.session.MockWebSessionManager
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.
assertSame
;
/**
/**
* Unit tests for {@link ResponseStatusExceptionHandler}.
* Unit tests for {@link ResponseStatusExceptionHandler}.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录