Move spring-web-reactive classes to spring-web
This commit is contained in:
parent
2e8326220b
commit
5d1b542698
41
build.gradle
41
build.gradle
|
|
@ -673,7 +673,7 @@ project("spring-web") {
|
|||
compile(project(":spring-beans")) // for MultipartFilter
|
||||
compile(project(":spring-context"))
|
||||
compile(project(":spring-core"))
|
||||
provided("javax.servlet:javax.servlet-api:3.0.1")
|
||||
provided "javax.servlet:javax.servlet-api:3.1.0"
|
||||
optional(project(":spring-oxm")) // for MarshallingHttpMessageConverter
|
||||
optional("javax.servlet.jsp:javax.servlet.jsp-api:2.2.1")
|
||||
optional("javax.el:javax.el-api:2.2.5")
|
||||
|
|
@ -682,6 +682,16 @@ project("spring-web") {
|
|||
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
|
||||
optional("com.caucho:hessian:4.0.38")
|
||||
optional("commons-fileupload:commons-fileupload:${fileuploadVersion}")
|
||||
optional("org.reactivestreams:reactive-streams:1.0.0")
|
||||
optional("io.projectreactor:reactor-core:${reactorCoreVersion}")
|
||||
optional("io.projectreactor:reactor-netty:${reactorNettyVersion}")
|
||||
optional("io.reactivex:rxnetty-http:0.5.2-SNAPSHOT") {
|
||||
exclude group: 'io.reactivex', module: 'rxjava'
|
||||
}
|
||||
optional("io.reactivex:rxjava:${rxJavaVersion}")
|
||||
optional("io.undertow:undertow-core:1.3.20.Final")
|
||||
optional("io.netty:netty-buffer:${nettyVersion}") // Temporarily for JsonObjectDecoder
|
||||
optional("com.fasterxml:aalto-xml:1.0.0")
|
||||
optional("org.apache.httpcomponents:httpclient:${httpclientVersion}")
|
||||
optional("org.apache.httpcomponents:httpasyncclient:${httpasyncVersion}")
|
||||
optional("io.netty:netty-all:${nettyVersion}")
|
||||
|
|
@ -710,6 +720,11 @@ project("spring-web") {
|
|||
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jackson2Version}")
|
||||
testCompile("com.fasterxml.jackson.module:jackson-module-kotlin:${jackson2Version}")
|
||||
testRuntime("com.sun.mail:javax.mail:${javamailVersion}")
|
||||
testCompile("org.apache.tomcat:tomcat-util:${tomcatVersion}")
|
||||
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
|
||||
testCompile("org.eclipse.jetty:jetty-server:${jettyVersion}")
|
||||
testCompile("org.eclipse.jetty:jetty-servlet:${jettyVersion}")
|
||||
testCompile("com.squareup.okhttp3:mockwebserver:3.0.1")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -817,25 +832,23 @@ project("spring-web-reactive") {
|
|||
compile(project(":spring-web"))
|
||||
compile "org.reactivestreams:reactive-streams:1.0.0"
|
||||
compile "io.projectreactor:reactor-core:${reactorCoreVersion}"
|
||||
compile "io.netty:netty-buffer:${nettyVersion}" // Temporarily for JsonObjectDecoder
|
||||
optional(project(":spring-context-support")) // for FreeMarker support
|
||||
provided "javax.servlet:javax.servlet-api:3.1.0"
|
||||
optional "org.apache.tomcat:tomcat-util:${tomcatVersion}"
|
||||
optional "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
|
||||
optional "org.eclipse.jetty:jetty-server:${jettyVersion}"
|
||||
optional "org.eclipse.jetty:jetty-servlet:${jettyVersion}"
|
||||
optional 'io.undertow:undertow-core:1.3.20.Final'
|
||||
optional "io.projectreactor:reactor-netty:${reactorNettyVersion}"
|
||||
optional "io.reactivex:rxjava:${rxJavaVersion}"
|
||||
optional("io.reactivex:rxnetty-http:0.5.2-SNAPSHOT") {
|
||||
exclude group: 'io.reactivex', module: 'rxjava'
|
||||
}
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
|
||||
optional("com.fasterxml:aalto-xml:1.0.0")
|
||||
optional("org.freemarker:freemarker:${freemarkerVersion}")
|
||||
optional "org.apache.httpcomponents:httpclient:4.5.1" // Needed to run Javadoc without error
|
||||
testCompile("org.apache.tomcat:tomcat-util:${tomcatVersion}")
|
||||
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
|
||||
testCompile("org.eclipse.jetty:jetty-server:${jettyVersion}")
|
||||
testCompile("org.eclipse.jetty:jetty-servlet:${jettyVersion}")
|
||||
testCompile("io.projectreactor:reactor-netty:${reactorNettyVersion}")
|
||||
testCompile("io.reactivex:rxnetty-http:0.5.2-SNAPSHOT") {
|
||||
exclude group: 'io.reactivex', module: 'rxjava'
|
||||
}
|
||||
testCompile("io.undertow:undertow-core:1.3.20.Final")
|
||||
testCompile("io.reactivex:rxjava:${rxJavaVersion}")
|
||||
testCompile("com.fasterxml:aalto-xml:1.0.0")
|
||||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
testCompile "com.squareup.okhttp3:mockwebserver:3.0.1"
|
||||
testCompile("javax.validation:validation-api:${beanvalVersion}")
|
||||
testCompile("xmlunit:xmlunit:1.6")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* Contains a basic abstraction over client/server-side HTTP. This package contains
|
||||
* the {@code HttpInputMessage} and {@code HttpOutputMessage} interfaces.
|
||||
*/
|
||||
package org.springframework.http;
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.http.support;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public abstract class MediaTypeUtils {
|
||||
|
||||
/**
|
||||
* TODO: move to MediaType static method
|
||||
*/
|
||||
public static List<MediaType> toMediaTypes(List<MimeType> mimeTypes) {
|
||||
return mimeTypes.stream().map(MediaTypeUtils::toMediaType)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: move to MediaType constructor
|
||||
*/
|
||||
public static MediaType toMediaType(MimeType mimeType) {
|
||||
return new MediaType(mimeType.getType(), mimeType.getSubtype(),
|
||||
mimeType.getParameters());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* Common, generic interfaces that define minimal boundary points
|
||||
* between Spring's web infrastructure and other framework modules.
|
||||
*/
|
||||
package org.springframework.web;
|
||||
|
|
@ -22,10 +22,9 @@ import java.util.Optional;
|
|||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.support.MediaTypeUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MimeTypeUtils2;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.NotAcceptableStatusException;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
|
@ -94,8 +93,8 @@ public class PathExtensionContentTypeResolver extends AbstractMappingContentType
|
|||
@Override
|
||||
protected MediaType handleNoMatch(String key) throws NotAcceptableStatusException {
|
||||
if (this.useJaf) {
|
||||
Optional<MimeType> mimeType = MimeTypeUtils2.getMimeType("file." + key);
|
||||
MediaType mediaType = mimeType.map(MediaTypeUtils::toMediaType).orElse(null);
|
||||
Optional<MimeType> mimeType = MimeTypeUtils.getMimeType("file." + key);
|
||||
MediaType mediaType = mimeType.map(MediaType::toMediaType).orElse(null);
|
||||
if (mediaType != null && !MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) {
|
||||
return mediaType;
|
||||
}
|
||||
|
|
@ -122,9 +121,7 @@ public class PathExtensionContentTypeResolver extends AbstractMappingContentType
|
|||
mediaType = getMediaType(extension);
|
||||
}
|
||||
if (mediaType == null) {
|
||||
mediaType =
|
||||
MimeTypeUtils2.getMimeType(filename).map(MediaTypeUtils::toMediaType)
|
||||
.orElse(null);
|
||||
mediaType = MimeTypeUtils.getMimeType(filename).map(MediaType::toMediaType).orElse(null);
|
||||
}
|
||||
if (MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) {
|
||||
mediaType = null;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import org.springframework.web.client.reactive.WebClient;
|
||||
import org.springframework.web.reactive.DispatcherHandler;
|
||||
import org.springframework.web.reactive.config.WebReactiveConfiguration;
|
||||
import org.springframework.web.reactive.sse.SseEvent;
|
||||
import org.springframework.http.codec.SseEvent;
|
||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.Comparator;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.InvalidMimeTypeException;
|
||||
|
|
@ -445,6 +446,22 @@ public class MediaType extends MimeType implements Serializable {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-create the given mime types as media types.
|
||||
* @since 5.0
|
||||
*/
|
||||
public static List<MediaType> toMediaTypes(List<MimeType> mimeTypes) {
|
||||
return mimeTypes.stream().map(MediaType::toMediaType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-create the given mime type as a media type.
|
||||
* @since 5.0
|
||||
*/
|
||||
public static MediaType toMediaType(MimeType mimeType) {
|
||||
return new MediaType(mimeType.getType(), mimeType.getSubtype(), mimeType.getParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of the given list of {@code MediaType} objects.
|
||||
* <p>This method can be used to for an {@code Accept} or {@code Content-Type} header.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.reactive.sse;
|
||||
package org.springframework.http.codec;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.SseEventEncoder;
|
||||
|
|
@ -34,7 +34,6 @@ import org.springframework.core.io.buffer.FlushingDataBuffer;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.web.reactive.sse.SseEvent;
|
||||
|
||||
/**
|
||||
* An encoder for {@link SseEvent}s that also supports any other kind of {@link Object}
|
||||
|
|
@ -35,13 +35,13 @@ import reactor.core.publisher.Flux;
|
|||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.CodecException;
|
||||
import org.springframework.core.codec.AbstractDecoder;
|
||||
import org.springframework.core.codec.CodecException;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.util.xml.StaxUtils2;
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
|
||||
/**
|
||||
* Decode from a bytes stream of XML elements to a stream of {@code Object} (POJO).
|
||||
|
|
@ -198,7 +198,7 @@ public class Jaxb2Decoder extends AbstractDecoder<Object> {
|
|||
private Object unmarshal(List<XMLEvent> events, Class<?> outputClass) {
|
||||
try {
|
||||
Unmarshaller unmarshaller = this.jaxbContexts.createUnmarshaller(outputClass);
|
||||
XMLEventReader eventReader = StaxUtils2.createXMLEventReader(events);
|
||||
XMLEventReader eventReader = StaxUtils.createXMLEventReader(events);
|
||||
if (outputClass.isAnnotationPresent(XmlRootElement.class)) {
|
||||
return unmarshaller.unmarshal(eventReader);
|
||||
}
|
||||
|
|
@ -32,7 +32,6 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.support.MediaTypeUtils;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link HttpMessageConverter} interface that delegates to
|
||||
|
|
@ -84,10 +83,10 @@ public class CodecHttpMessageConverter<T> implements HttpMessageConverter<T> {
|
|||
this.decoder = decoder;
|
||||
|
||||
this.readableMediaTypes = decoder != null ?
|
||||
MediaTypeUtils.toMediaTypes(decoder.getDecodableMimeTypes()) :
|
||||
MediaType.toMediaTypes(decoder.getDecodableMimeTypes()) :
|
||||
Collections.emptyList();
|
||||
this.writableMediaTypes = encoder != null ?
|
||||
MediaTypeUtils.toMediaTypes(encoder.getEncodableMimeTypes()) :
|
||||
MediaType.toMediaTypes(encoder.getEncodableMimeTypes()) :
|
||||
Collections.emptyList();
|
||||
}
|
||||
|
||||
|
|
@ -33,8 +33,7 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.ZeroCopyHttpOutputMessage;
|
||||
import org.springframework.http.support.MediaTypeUtils;
|
||||
import org.springframework.util.MimeTypeUtils2;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -73,8 +72,8 @@ public class ResourceHttpMessageConverter extends CodecHttpMessageConverter<Reso
|
|||
if (contentType == null ||
|
||||
!contentType.isConcrete() ||
|
||||
MediaType.APPLICATION_OCTET_STREAM.equals(contentType)) {
|
||||
contentType = MimeTypeUtils2.getMimeType(resource.getFilename()).
|
||||
map(MediaTypeUtils::toMediaType).
|
||||
contentType = MimeTypeUtils.getMimeType(resource.getFilename()).
|
||||
map(MediaType::toMediaType).
|
||||
orElse(MediaType.APPLICATION_OCTET_STREAM);
|
||||
}
|
||||
headers.setContentType(contentType);
|
||||
|
|
@ -26,6 +26,7 @@ import java.util.Enumeration;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
|
@ -165,6 +166,7 @@ public class ContentCachingRequestWrapper extends HttpServletRequestWrapper {
|
|||
return this.cachedContent.toByteArray();
|
||||
}
|
||||
|
||||
// TODO: this is no longer usable in Servlet 3.0 environment
|
||||
|
||||
private class ContentCachingInputStream extends ServletInputStream {
|
||||
|
||||
|
|
@ -182,6 +184,21 @@ public class ContentCachingRequestWrapper extends HttpServletRequestWrapper {
|
|||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return this.is.isFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return this.is.isReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
this.setReadListener(readListener);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import java.io.InputStream;
|
|||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.WriteListener;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
|
|||
|
||||
private final FastByteArrayOutputStream content = new FastByteArrayOutputStream(1024);
|
||||
|
||||
private final ServletOutputStream outputStream = new ResponseServletOutputStream();
|
||||
private ServletOutputStream outputStream;
|
||||
|
||||
private PrintWriter writer;
|
||||
|
||||
|
|
@ -109,6 +109,9 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
|
|||
|
||||
@Override
|
||||
public ServletOutputStream getOutputStream() throws IOException {
|
||||
if (this.outputStream == null) {
|
||||
this.outputStream = new ResponseServletOutputStream(getResponse().getOutputStream());
|
||||
}
|
||||
return this.outputStream;
|
||||
}
|
||||
|
||||
|
|
@ -225,9 +228,16 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: this is no longer usable in Servlet 3.0 environment
|
||||
|
||||
private class ResponseServletOutputStream extends ServletOutputStream {
|
||||
|
||||
private final ServletOutputStream os;
|
||||
|
||||
public ResponseServletOutputStream(ServletOutputStream os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
content.write(b);
|
||||
|
|
@ -237,6 +247,16 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
|
|||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
content.write(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return this.os.isReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWriteListener(WriteListener writeListener) {
|
||||
this.os.setWriteListener(writeListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue