Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
32214e0a
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 搜索 >>
提交
32214e0a
编写于
10月 05, 2015
作者:
S
Sebastien Deleuze
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Javadoc for main interfaces/classes
上级
9516c999
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
97 addition
and
0 deletion
+97
-0
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/DispatcherHandler.java
...ingframework/reactive/web/dispatch/DispatcherHandler.java
+15
-0
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/HandlerAdapter.java
...springframework/reactive/web/dispatch/HandlerAdapter.java
+27
-0
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/HandlerResult.java
.../springframework/reactive/web/dispatch/HandlerResult.java
+2
-0
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/HandlerResultHandler.java
...framework/reactive/web/dispatch/HandlerResultHandler.java
+20
-0
spring-web-reactive/src/main/java/org/springframework/reactive/web/http/HttpHandler.java
...va/org/springframework/reactive/web/http/HttpHandler.java
+19
-0
spring-web-reactive/src/main/java/org/springframework/reactive/web/http/ServerHttpRequest.java
.../springframework/reactive/web/http/ServerHttpRequest.java
+4
-0
spring-web-reactive/src/main/java/org/springframework/reactive/web/http/ServerHttpResponse.java
...springframework/reactive/web/http/ServerHttpResponse.java
+10
-0
未找到文件。
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/DispatcherHandler.java
浏览文件 @
32214e0a
...
...
@@ -35,7 +35,22 @@ import org.springframework.reactive.web.http.ServerHttpRequest;
import
org.springframework.reactive.web.http.ServerHttpResponse
;
/**
* Central dispatcher for HTTP request handlers/controllers. Dispatches to registered
* handlers for processing a web request, providing convenient mapping facilities.
*
* <li>It can use any {@link HandlerMapping} implementation to control the routing of
* requests to handler objects. HandlerMapping objects can be defined as beans in
* the application context.
*
* <li>It can use any {@link HandlerAdapter}; this allows for using any handler interface.
* HandlerAdapter objects can be added as beans in the application context.
*
* <li>It can use any {@link HandlerResultHandler}; this allows to process the result of
* the request handling. HandlerResultHandler objects can be added as beans in the
* application context.
*
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
*/
public
class
DispatcherHandler
implements
HttpHandler
,
ApplicationContextAware
{
...
...
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/HandlerAdapter.java
浏览文件 @
32214e0a
...
...
@@ -19,12 +19,39 @@ import org.springframework.reactive.web.http.ServerHttpRequest;
import
org.springframework.reactive.web.http.ServerHttpResponse
;
/**
* Interface that must be implemented for each handler type to handle an HTTP request.
* This interface is used to allow the {@link DispatcherHandler} to be indefinitely
* extensible. The {@code DispatcherHandler} accesses all installed handlers through
* this interface, meaning that it does not contain code specific to any handler type.
*
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
*/
public
interface
HandlerAdapter
{
/**
* Given a handler instance, return whether or not this {@code HandlerAdapter}
* can support it. Typical HandlerAdapters will base the decision on the handler
* type. HandlerAdapters will usually only support one handler type each.
* <p>A typical implementation:
* <p>{@code
* return (handler instanceof MyHandler);
* }
* @param handler handler object to check
* @return whether or not this object can use the given handler
*/
boolean
supports
(
Object
handler
);
/**
* Use the given handler to handle this request.
* @param request current HTTP request
* @param response current HTTP response
* @param handler handler to use. This object must have previously been passed
* to the {@code supports} method of this interface, which must have
* returned {@code true}.
* @throws Exception in case of errors
* @return An {@link HandlerResult} instance
*/
HandlerResult
handle
(
ServerHttpRequest
request
,
ServerHttpResponse
response
,
Object
handler
)
throws
Exception
;
}
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/HandlerResult.java
浏览文件 @
32214e0a
...
...
@@ -17,6 +17,8 @@ package org.springframework.reactive.web.dispatch;
/**
* Represent the result of the invocation of an handler.
*
* @author Rossen Stoyanchev
*/
public
class
HandlerResult
{
...
...
spring-web-reactive/src/main/java/org/springframework/reactive/web/dispatch/HandlerResultHandler.java
浏览文件 @
32214e0a
...
...
@@ -21,12 +21,32 @@ import org.springframework.reactive.web.http.ServerHttpRequest;
import
org.springframework.reactive.web.http.ServerHttpResponse
;
/**
* Process the {@link HandlerResult}, usually returned by an {@link HandlerAdapter}.
*
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
*/
public
interface
HandlerResultHandler
{
/**
* Given a handler instance, return whether or not this {@code HandlerResultHandler}
* can support it.
*
* @param result result object to check
* @return whether or not this object can use the given result
*/
boolean
supports
(
HandlerResult
result
);
/**
* Process the given result in an asynchronous non blocking way, by eventually modifying
* response headers, or writing some data stream into the response.
* Implementations should not throw exceptions but signal them via the returned
* {@code Publisher<Void>}.
*
* @return A {@code Publisher<Void>} used to signal the demand, and receive a notification
* when the handling is complete (success or error) including the flush of the data on the
* network.
*/
Publisher
<
Void
>
handleResult
(
ServerHttpRequest
request
,
ServerHttpResponse
response
,
HandlerResult
result
);
}
\ No newline at end of file
spring-web-reactive/src/main/java/org/springframework/reactive/web/http/HttpHandler.java
浏览文件 @
32214e0a
...
...
@@ -20,11 +20,30 @@ import org.reactivestreams.Publisher;
/**
* Interface for handlers that process HTTP requests and generate an HTTP response.
* This handler is designed to be called when the HTTP headers have been received, making
* the HTTP request body available as stream. The HTTP response body can also be written
* as a stream.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
* @see ServerHttpRequest#getBody()
* @see ServerHttpResponse#writeWith(Publisher)
*/
public
interface
HttpHandler
{
/**
* Process the given request, generating a response in an asynchronous non blocking way.
* Implementations should not throw exceptions but signal them via the returned
* {@code Publisher<Void>}.
*
* @param request current HTTP request, the body can be processed as a data stream.
* @param response current HTTP response, the body can be provided as a data stream.
* @return A {@code Publisher<Void>} used to signal the demand, and receive a notification
* when the handling is complete (success or error) including the flush of the data on the
* network.
*/
Publisher
<
Void
>
handle
(
ServerHttpRequest
request
,
ServerHttpResponse
response
);
}
spring-web-reactive/src/main/java/org/springframework/reactive/web/http/ServerHttpRequest.java
浏览文件 @
32214e0a
...
...
@@ -20,11 +20,15 @@ import java.nio.ByteBuffer;
import
org.reactivestreams.Publisher
;
/**
* Represent a server-side HTTP request.
*
* @author Rossen Stoyanchev
*/
public
interface
ServerHttpRequest
extends
HttpRequest
{
/**
* Return the body of the message as a reactive stream.
*/
Publisher
<
ByteBuffer
>
getBody
();
}
spring-web-reactive/src/main/java/org/springframework/reactive/web/http/ServerHttpResponse.java
浏览文件 @
32214e0a
...
...
@@ -22,12 +22,22 @@ import org.reactivestreams.Publisher;
import
org.springframework.http.HttpStatus
;
/**
* Represent a server-side HTTP response.
*
* @author Rossen Stoyanchev
*/
public
interface
ServerHttpResponse
extends
HttpMessage
{
void
setStatusCode
(
HttpStatus
status
);
/**
* Write the provided reactive stream of bytes to the response body. Most servers
* support multiple {@code writeWith} calls.
* @param contentPublisher the stream to write in the response body.
* @return A {@code Publisher<Void>} used to signal the demand, and receive a notification
* when the handling is complete (success or error) including the flush of the data on the
* network.
*/
Publisher
<
Void
>
writeWith
(
Publisher
<
ByteBuffer
>
contentPublisher
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录