提交 f020a1ad 编写于 作者: R Rossen Stoyanchev

Refactor package structure

Introduce http and dispatch packages under org.springframework.web to
separate HTTP-specific adapter code from higher level web framework
code. Move classes into their respective locations.
上级 56d69404
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.dispatch;
import java.util.ArrayList;
import java.util.List;
......@@ -26,11 +26,14 @@ import reactor.rx.Streams;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.reactive.web.http.ServerHttpHandler;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpResponse;
/**
* @author Rossen Stoyanchev
*/
public class DispatcherHttpHandler implements HttpHandler {
public class DispatcherHandler implements ServerHttpHandler {
private List<HandlerMapping> handlerMappings;
......
......@@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.dispatch;
import org.reactivestreams.Publisher;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpResponse;
/**
* @author Rossen Stoyanchev
*/
......
......@@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.dispatch;
import org.springframework.reactive.web.http.ServerHttpRequest;
/**
* @author Rossen Stoyanchev
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.dispatch;
/**
* @author Rossen Stoyanchev
......
......@@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.dispatch;
import org.reactivestreams.Publisher;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpResponse;
/**
* @author Rossen Stoyanchev
*/
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import java.net.URI;
......
......@@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import java.net.URI;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
/**
......
......@@ -14,15 +14,18 @@
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import org.reactivestreams.Publisher;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpResponse;
/**
* @author Arjen Poutsma
* @author Rossen Stoyanchev
*/
public interface HttpHandler {
public interface ServerHttpHandler {
Publisher<Void> handle(ServerHttpRequest request, ServerHttpResponse response);
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import org.reactivestreams.Publisher;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import org.reactivestreams.Publisher;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web.rxnetty;
package org.springframework.reactive.web.http.rxnetty;
import io.netty.buffer.ByteBuf;
import io.reactivex.netty.protocol.http.server.HttpServerRequest;
......@@ -23,7 +23,7 @@ import org.reactivestreams.Publisher;
import rx.Observable;
import rx.RxReactiveStreams;
import org.springframework.reactive.web.HttpHandler;
import org.springframework.reactive.web.http.ServerHttpHandler;
import org.springframework.util.Assert;
/**
......@@ -31,10 +31,10 @@ import org.springframework.util.Assert;
*/
public class RequestHandlerAdapter implements RequestHandler<ByteBuf, ByteBuf> {
private final HttpHandler httpHandler;
private final ServerHttpHandler httpHandler;
public RequestHandlerAdapter(HttpHandler httpHandler) {
public RequestHandlerAdapter(ServerHttpHandler httpHandler) {
Assert.notNull(httpHandler, "'httpHandler' is required.");
this.httpHandler = httpHandler;
}
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web.rxnetty;
package org.springframework.reactive.web.http.rxnetty;
import java.net.URI;
import java.net.URISyntaxException;
......@@ -25,7 +25,7 @@ import rx.Observable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.reactive.web.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.util.Assert;
/**
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web.rxnetty;
package org.springframework.reactive.web.http.rxnetty;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.reactivex.netty.protocol.http.server.HttpServerResponse;
......@@ -23,7 +23,7 @@ import rx.RxReactiveStreams;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.reactive.web.ServerHttpResponse;
import org.springframework.reactive.web.http.ServerHttpResponse;
import org.springframework.util.Assert;
/**
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import java.io.IOException;
import javax.servlet.AsyncContext;
......@@ -29,7 +29,7 @@ import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.springframework.reactive.web.HttpHandler;
import org.springframework.reactive.web.http.ServerHttpHandler;
/**
* @author Arjen Poutsma
......@@ -43,10 +43,10 @@ public class HttpHandlerServlet extends HttpServlet {
private static Log logger = LogFactory.getLog(HttpHandlerServlet.class);
private HttpHandler handler;
private ServerHttpHandler handler;
public void setHandler(HttpHandler handler) {
public void setHandler(ServerHttpHandler handler) {
this.handler = handler;
}
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import java.io.IOException;
import java.nio.charset.Charset;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import java.net.URI;
import java.net.URISyntaxException;
......@@ -28,7 +28,7 @@ import org.reactivestreams.Publisher;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.reactive.web.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.util.Assert;
import org.springframework.util.LinkedCaseInsensitiveMap;
import org.springframework.util.StringUtils;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import java.util.List;
import java.util.Map;
......@@ -23,7 +23,7 @@ import org.reactivestreams.Publisher;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.reactive.web.ServerHttpResponse;
import org.springframework.reactive.web.http.ServerHttpResponse;
import org.springframework.util.Assert;
/**
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.dispatch;
import java.nio.charset.Charset;
import java.util.HashMap;
......@@ -25,7 +25,9 @@ import org.reactivestreams.Publisher;
import reactor.rx.Streams;
import org.springframework.http.MediaType;
import org.springframework.reactive.web.rxnetty.RequestHandlerAdapter;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpResponse;
import org.springframework.reactive.web.http.rxnetty.RequestHandlerAdapter;
import org.springframework.web.context.support.StaticWebApplicationContext;
/**
......@@ -44,7 +46,7 @@ public class DispatcherApp {
SimpleUrlHandlerMapping handlerMapping = wac.getBean(SimpleUrlHandlerMapping.class);
handlerMapping.addHandler("/text", new HelloWorldTextHandler());
DispatcherHttpHandler dispatcherHandler = new DispatcherHttpHandler();
DispatcherHandler dispatcherHandler = new DispatcherHandler();
dispatcherHandler.initStrategies(wac);
RequestHandlerAdapter requestHandler = new RequestHandlerAdapter(dispatcherHandler);
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import java.net.URI;
import java.util.Random;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
......@@ -25,9 +25,9 @@ import org.reactivestreams.Subscription;
/**
* @author Arjen Poutsma
*/
public class CountingHttpHandler implements HttpHandler {
public class CountingHandler implements ServerHttpHandler {
private static final Log logger = LogFactory.getLog(CountingHttpHandler.class);
private static final Log logger = LogFactory.getLog(CountingHandler.class);
@Override
public Publisher<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
......
......@@ -14,14 +14,18 @@
* limitations under the License.
*/
package org.springframework.reactive.web;
package org.springframework.reactive.web.http;
import org.reactivestreams.Publisher;
import org.springframework.reactive.web.http.ServerHttpHandler;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpResponse;
/**
* @author Arjen Poutsma
*/
public class EchoHandler implements HttpHandler {
public class EchoHandler implements ServerHttpHandler {
@Override
public Publisher<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
......
......@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.reactive.web.rxnetty;
package org.springframework.reactive.web.http.rxnetty;
import io.netty.buffer.ByteBuf;
import io.reactivex.netty.protocol.http.server.HttpServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.springframework.reactive.web.EchoHandler;
import org.springframework.reactive.web.AbstractHttpHandlerIntegrationTestCase;
import org.springframework.reactive.web.http.EchoHandler;
import org.springframework.reactive.web.http.AbstractHttpHandlerIntegrationTestCase;
/**
* @author Rossen Stoyanchev
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import javax.servlet.AsyncContext;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
......@@ -23,8 +23,8 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.springframework.reactive.web.AbstractHttpHandlerIntegrationTestCase;
import org.springframework.reactive.web.EchoHandler;
import org.springframework.reactive.web.http.AbstractHttpHandlerIntegrationTestCase;
import org.springframework.reactive.web.http.EchoHandler;
/**
* @author Arjen Poutsma
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.web.servlet;
package org.springframework.reactive.web.http.servlet;
import java.io.File;
......@@ -24,8 +24,8 @@ import org.apache.catalina.startup.Tomcat;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.springframework.reactive.web.AbstractHttpHandlerIntegrationTestCase;
import org.springframework.reactive.web.EchoHandler;
import org.springframework.reactive.web.http.AbstractHttpHandlerIntegrationTestCase;
import org.springframework.reactive.web.http.EchoHandler;
/**
* @author Arjen Poutsma
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册