From 1dcaff8a5cefa16f82118dc81812ce58685c51d3 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 8 Dec 2015 15:13:30 -0500 Subject: [PATCH] Updates to Javadoc --- .../reactive/FilterChainHttpHandler.java | 4 ++-- .../http/server/reactive/HttpFilter.java | 18 ++++++++++++++++- .../http/server/reactive/HttpFilterChain.java | 9 +++++++++ .../http/server/reactive/HttpHandler.java | 20 ++++++------------- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/FilterChainHttpHandler.java b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/FilterChainHttpHandler.java index 746807b9a72..729f5dd36be 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/FilterChainHttpHandler.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/FilterChainHttpHandler.java @@ -24,8 +24,8 @@ import org.reactivestreams.Publisher; import org.springframework.util.Assert; /** - * An {@link HttpHandler} decorator that delegates to a list of - * {@link HttpFilter}s and the target {@link HttpHandler}. + * {@link HttpHandler} that delegates to a chain of {@link HttpFilter}s followed + * by a target {@link HttpHandler}. * * @author Rossen Stoyanchev */ diff --git a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilter.java b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilter.java index 9e9d5fd500a..525fb4d6251 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilter.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilter.java @@ -19,11 +19,27 @@ package org.springframework.http.server.reactive; import org.reactivestreams.Publisher; /** + * Contract for interception-style, chained processing of HTTP requests. + * + *

Filters may be used to implement cross-cutting, application-agnostic + * requirements such as security, timeouts, and others. + * + *

{@link FilterChainHttpHandler} provides a way of constructing a chain of + * {@link HttpFilter}s followed by a target {@link HttpHandler}. + * * @author Rossen Stoyanchev + * @see FilterChainHttpHandler */ public interface HttpFilter { - + /** + * Process the given request and optionally delegate to the next HttpFilter. + * + * @param request current HTTP request. + * @param response current HTTP response. + * @param chain provides a way to delegate to the next HttpFilter. + * @return Publisher to indicate when request processing is complete. + */ Publisher filter(ServerHttpRequest request, ServerHttpResponse response, HttpFilterChain chain); diff --git a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilterChain.java b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilterChain.java index 1c15d907917..a18a644f2db 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilterChain.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpFilterChain.java @@ -19,10 +19,19 @@ import org.reactivestreams.Publisher; /** + * Represents a chain of {@link HttpFilter}s allowing each {@link HttpFilter} to + * delegate to the next in the chain. + * * @author Rossen Stoyanchev */ public interface HttpFilterChain { + /** + * + * @param request current HTTP request. + * @param response current HTTP response. + * @return Publisher to indicate when request handling is complete. + */ Publisher filter(ServerHttpRequest request, ServerHttpResponse response); } diff --git a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpHandler.java b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpHandler.java index f11cc13a2d4..ab0e93197a6 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpHandler.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/HttpHandler.java @@ -19,29 +19,21 @@ package org.springframework.http.server.reactive; 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. + * Contract for handling HTTP requests in a non-blocking way. * * @author Arjen Poutsma * @author Rossen Stoyanchev * @author Sebastien Deleuze - * @see ServerHttpRequest#getBody() - * @see ServerHttpResponse#setBody(Publisher) + * @see HttpFilter */ 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}. + * Handle the given request and generate a response. * - * @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} 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. + * @param request current HTTP request. + * @param response current HTTP response. + * @return Publisher to indicate when request handling is complete. */ Publisher handle(ServerHttpRequest request, ServerHttpResponse response);