Jakarta EE 9 migration
Upgrades many dependency declarations; removes old EJB 2.x support and outdated Servlet-based integrations (Commons FileUpload, FreeMarker JSP support, Tiles). Closes gh-22093 Closes gh-25354 Closes gh-26185 Closes gh-27423 See gh-27424
This commit is contained in:
@@ -54,7 +54,6 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
|
||||
private final ReactiveRequest.Builder builder;
|
||||
|
||||
|
||||
|
||||
public JettyClientHttpRequest(Request jettyRequest, DataBufferFactory bufferFactory) {
|
||||
this.jettyRequest = jettyRequest;
|
||||
this.bufferFactory = bufferFactory;
|
||||
@@ -137,10 +136,12 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
|
||||
@Override
|
||||
protected void applyHeaders() {
|
||||
HttpHeaders headers = getHeaders();
|
||||
headers.forEach((key, value) -> value.forEach(v -> this.jettyRequest.header(key, v)));
|
||||
if (!headers.containsKey(HttpHeaders.ACCEPT)) {
|
||||
this.jettyRequest.header(HttpHeaders.ACCEPT, "*/*");
|
||||
}
|
||||
this.jettyRequest.headers(fields -> {
|
||||
headers.forEach((key, value) -> value.forEach(v -> fields.add(key, v)));
|
||||
if (!headers.containsKey(HttpHeaders.ACCEPT)) {
|
||||
fields.add(HttpHeaders.ACCEPT, "*/*");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ReactiveRequest toReactiveRequest() {
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package org.springframework.http.client.reactive;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
import org.eclipse.jetty.reactive.client.ReactiveResponse;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -32,11 +30,9 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* {@link ClientHttpResponse} implementation for the Jetty ReactiveStreams HTTP client.
|
||||
@@ -50,10 +46,6 @@ class JettyClientHttpResponse implements ClientHttpResponse {
|
||||
|
||||
private static final Pattern SAMESITE_PATTERN = Pattern.compile("(?i).*SameSite=(Strict|Lax|None).*");
|
||||
|
||||
private static final ClassLoader classLoader = JettyClientHttpResponse.class.getClassLoader();
|
||||
|
||||
private static final boolean jetty10Present;
|
||||
|
||||
|
||||
private final ReactiveResponse reactiveResponse;
|
||||
|
||||
@@ -62,25 +54,11 @@ class JettyClientHttpResponse implements ClientHttpResponse {
|
||||
private final HttpHeaders headers;
|
||||
|
||||
|
||||
static {
|
||||
try {
|
||||
Class<?> httpFieldsClass = classLoader.loadClass("org.eclipse.jetty.http.HttpFields");
|
||||
jetty10Present = httpFieldsClass.isInterface();
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
throw new IllegalStateException("No compatible Jetty version found", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public JettyClientHttpResponse(ReactiveResponse reactiveResponse, Publisher<DataBuffer> content) {
|
||||
this.reactiveResponse = reactiveResponse;
|
||||
this.content = Flux.from(content);
|
||||
|
||||
MultiValueMap<String, String> headers = (jetty10Present ?
|
||||
Jetty10HttpFieldsHelper.getHttpHeaders(reactiveResponse) :
|
||||
new JettyHeadersAdapter(reactiveResponse.getHeaders()));
|
||||
|
||||
MultiValueMap<String, String> headers = new JettyHeadersAdapter(reactiveResponse.getHeaders());
|
||||
this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
|
||||
}
|
||||
|
||||
@@ -132,40 +110,4 @@ class JettyClientHttpResponse implements ClientHttpResponse {
|
||||
return this.headers;
|
||||
}
|
||||
|
||||
|
||||
private static class Jetty10HttpFieldsHelper {
|
||||
|
||||
private static final Method getHeadersMethod;
|
||||
|
||||
private static final Method getNameMethod;
|
||||
|
||||
private static final Method getValueMethod;
|
||||
|
||||
static {
|
||||
try {
|
||||
getHeadersMethod = Response.class.getMethod("getHeaders");
|
||||
Class<?> type = classLoader.loadClass("org.eclipse.jetty.http.HttpField");
|
||||
getNameMethod = type.getMethod("getName");
|
||||
getValueMethod = type.getMethod("getValue");
|
||||
}
|
||||
catch (ClassNotFoundException | NoSuchMethodException ex) {
|
||||
throw new IllegalStateException("No compatible Jetty version found", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpHeaders getHttpHeaders(ReactiveResponse response) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
Iterable<?> iterator = (Iterable<?>)
|
||||
ReflectionUtils.invokeMethod(getHeadersMethod, response.getResponse());
|
||||
Assert.notNull(iterator, "Iterator must not be null");
|
||||
for (Object field : iterator) {
|
||||
String name = (String) ReflectionUtils.invokeMethod(getNameMethod, field);
|
||||
Assert.notNull(name, "Header name must not be null");
|
||||
String value = (String) ReflectionUtils.invokeMethod(getValueMethod, field);
|
||||
headers.add(name, value);
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* <p>There is a duplicate of this class in the server package!
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @since 5.3
|
||||
*/
|
||||
class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@@ -58,7 +59,10 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void add(String key, @Nullable String value) {
|
||||
this.headers.add(key, value);
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
((HttpFields.Mutable) this.headers).add(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +77,10 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void set(String key, @Nullable String value) {
|
||||
this.headers.put(key, value);
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
((HttpFields.Mutable) this.headers).put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,7 +112,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return (key instanceof String && this.headers.containsKey((String) key));
|
||||
return (key instanceof String && this.headers.contains((String) key));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,17 +133,23 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> put(String key, List<String> value) {
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
List<String> oldValues = get(key);
|
||||
this.headers.put(key, value);
|
||||
((HttpFields.Mutable) this.headers).put(key, value);
|
||||
return oldValues;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> remove(Object key) {
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
if (key instanceof String) {
|
||||
List<String> oldValues = get(key);
|
||||
this.headers.remove((String) key);
|
||||
((HttpFields.Mutable) this.headers).remove((String) key);
|
||||
return oldValues;
|
||||
}
|
||||
return null;
|
||||
@@ -149,7 +162,10 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.headers.clear();
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
((HttpFields.Mutable) this.headers).clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,8 +237,11 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public List<String> setValue(List<String> value) {
|
||||
if (!(headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
List<String> previousValues = headers.getValuesList(this.key);
|
||||
headers.put(this.key, value);
|
||||
((HttpFields.Mutable) headers).put(this.key, value);
|
||||
return previousValues;
|
||||
}
|
||||
}
|
||||
@@ -266,13 +285,16 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (!(headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
if (this.currentName == null) {
|
||||
throw new IllegalStateException("No current Header in iterator");
|
||||
}
|
||||
if (!headers.containsKey(this.currentName)) {
|
||||
if (!headers.contains(this.currentName)) {
|
||||
throw new IllegalStateException("Header not present: " + this.currentName);
|
||||
}
|
||||
headers.remove(this.currentName);
|
||||
((HttpFields.Mutable) headers).remove(this.currentName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -84,13 +84,6 @@ public interface ServerCodecConfigurer extends CodecConfigurer {
|
||||
|
||||
/**
|
||||
* Configure the {@code HttpMessageReader} to use for multipart requests.
|
||||
* <p>By default, if
|
||||
* <a href="https://github.com/synchronoss/nio-multipart">Synchronoss NIO Multipart</a>
|
||||
* is present, this is set to
|
||||
* {@link org.springframework.http.codec.multipart.MultipartHttpMessageReader
|
||||
* MultipartHttpMessageReader} created with an instance of
|
||||
* {@link org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader
|
||||
* SynchronossPartHttpMessageReader}.
|
||||
* <p>Note that {@link #maxInMemorySize(int)} and/or
|
||||
* {@link #enableLoggingRequestDetails(boolean)}, if configured, will be
|
||||
* applied to the given reader, if applicable.
|
||||
|
||||
@@ -1,597 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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
|
||||
*
|
||||
* https://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.codec.multipart;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.synchronoss.cloud.nio.multipart.DefaultPartBodyStreamStorageFactory;
|
||||
import org.synchronoss.cloud.nio.multipart.Multipart;
|
||||
import org.synchronoss.cloud.nio.multipart.MultipartContext;
|
||||
import org.synchronoss.cloud.nio.multipart.MultipartUtils;
|
||||
import org.synchronoss.cloud.nio.multipart.NioMultipartParser;
|
||||
import org.synchronoss.cloud.nio.multipart.NioMultipartParserListener;
|
||||
import org.synchronoss.cloud.nio.multipart.PartBodyStreamStorageFactory;
|
||||
import org.synchronoss.cloud.nio.stream.storage.StreamStorage;
|
||||
import reactor.core.publisher.BaseSubscriber;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.FluxSink;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.publisher.SignalType;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.DecodingException;
|
||||
import org.springframework.core.codec.Hints;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferLimitException;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.core.log.LogFormatUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.LoggingCodecSupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@code HttpMessageReader} for parsing {@code "multipart/form-data"} requests
|
||||
* to a stream of {@link Part}'s using the Synchronoss NIO Multipart library.
|
||||
*
|
||||
* <p>This reader can be provided to {@link MultipartHttpMessageReader} in order
|
||||
* to aggregate all parts into a Map.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Arjen Poutsma
|
||||
* @author Brian Clozel
|
||||
* @since 5.0
|
||||
* @see <a href="https://github.com/synchronoss/nio-multipart">Synchronoss NIO Multipart</a>
|
||||
* @see MultipartHttpMessageReader
|
||||
*/
|
||||
public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implements HttpMessageReader<Part> {
|
||||
|
||||
private static final String FILE_STORAGE_DIRECTORY_PREFIX = "synchronoss-file-upload-";
|
||||
|
||||
private int maxInMemorySize = 256 * 1024;
|
||||
|
||||
private long maxDiskUsagePerPart = -1;
|
||||
|
||||
private int maxParts = -1;
|
||||
|
||||
private final AtomicReference<Path> fileStorageDirectory = new AtomicReference<>();
|
||||
|
||||
|
||||
/**
|
||||
* Configure the maximum amount of memory that is allowed to use per part.
|
||||
* When the limit is exceeded:
|
||||
* <ul>
|
||||
* <li>file parts are written to a temporary file.
|
||||
* <li>non-file parts are rejected with {@link DataBufferLimitException}.
|
||||
* </ul>
|
||||
* <p>By default this is set to 256K.
|
||||
* @param byteCount the in-memory limit in bytes; if set to -1 this limit is
|
||||
* not enforced, and all parts may be written to disk and are limited only
|
||||
* by the {@link #setMaxDiskUsagePerPart(long) maxDiskUsagePerPart} property.
|
||||
* @since 5.1.11
|
||||
*/
|
||||
public void setMaxInMemorySize(int byteCount) {
|
||||
this.maxInMemorySize = byteCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link #setMaxInMemorySize configured} maximum in-memory size.
|
||||
* @since 5.1.11
|
||||
*/
|
||||
public int getMaxInMemorySize() {
|
||||
return this.maxInMemorySize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the maximum amount of disk space allowed for file parts.
|
||||
* <p>By default this is set to -1.
|
||||
* @param maxDiskUsagePerPart the disk limit in bytes, or -1 for unlimited
|
||||
* @since 5.1.11
|
||||
*/
|
||||
public void setMaxDiskUsagePerPart(long maxDiskUsagePerPart) {
|
||||
this.maxDiskUsagePerPart = maxDiskUsagePerPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link #setMaxDiskUsagePerPart configured} maximum disk usage.
|
||||
* @since 5.1.11
|
||||
*/
|
||||
public long getMaxDiskUsagePerPart() {
|
||||
return this.maxDiskUsagePerPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the maximum number of parts allowed in a given multipart request.
|
||||
* @since 5.1.11
|
||||
*/
|
||||
public void setMaxParts(int maxParts) {
|
||||
this.maxParts = maxParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link #setMaxParts configured} limit on the number of parts.
|
||||
* @since 5.1.11
|
||||
*/
|
||||
public int getMaxParts() {
|
||||
return this.maxParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the directory used to store parts larger than
|
||||
* {@link #setMaxInMemorySize(int) maxInMemorySize}. By default, a new
|
||||
* temporary directory is created.
|
||||
* @throws IOException if an I/O error occurs, or the parent directory
|
||||
* does not exist
|
||||
* @since 5.3.7
|
||||
*/
|
||||
public void setFileStorageDirectory(Path fileStorageDirectory) throws IOException {
|
||||
Assert.notNull(fileStorageDirectory, "FileStorageDirectory must not be null");
|
||||
if (!Files.exists(fileStorageDirectory)) {
|
||||
Files.createDirectory(fileStorageDirectory);
|
||||
}
|
||||
this.fileStorageDirectory.set(fileStorageDirectory);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<MediaType> getReadableMediaTypes() {
|
||||
return MultipartHttpMessageReader.MIME_TYPES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType) {
|
||||
if (Part.class.equals(elementType.toClass())) {
|
||||
if (mediaType == null) {
|
||||
return true;
|
||||
}
|
||||
for (MediaType supportedMediaType : getReadableMediaTypes()) {
|
||||
if (supportedMediaType.isCompatibleWith(mediaType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Part> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
|
||||
return getFileStorageDirectory().flatMapMany(directory ->
|
||||
Flux.create(new SynchronossPartGenerator(message, directory))
|
||||
.doOnNext(part -> {
|
||||
if (!Hints.isLoggingSuppressed(hints)) {
|
||||
LogFormatUtils.traceDebug(logger, traceOn -> Hints.getLogPrefix(hints) + "Parsed " +
|
||||
(isEnableLoggingRequestDetails() ?
|
||||
LogFormatUtils.formatValue(part, !traceOn) :
|
||||
"parts '" + part.name() + "' (content masked)"));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Part> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
|
||||
return Mono.error(new UnsupportedOperationException("Cannot read multipart request body into single Part"));
|
||||
}
|
||||
|
||||
private Mono<Path> getFileStorageDirectory() {
|
||||
return Mono.defer(() -> {
|
||||
Path directory = this.fileStorageDirectory.get();
|
||||
if (directory != null) {
|
||||
return Mono.just(directory);
|
||||
}
|
||||
else {
|
||||
return Mono.fromCallable(() -> {
|
||||
Path tempDirectory = Files.createTempDirectory(FILE_STORAGE_DIRECTORY_PREFIX);
|
||||
if (this.fileStorageDirectory.compareAndSet(null, tempDirectory)) {
|
||||
return tempDirectory;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Files.delete(tempDirectory);
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
return this.fileStorageDirectory.get();
|
||||
}
|
||||
}).subscribeOn(Schedulers.boundedElastic());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subscribe to the input stream and feed the Synchronoss parser. Then listen
|
||||
* for parser output, creating parts, and pushing them into the FluxSink.
|
||||
*/
|
||||
private class SynchronossPartGenerator extends BaseSubscriber<DataBuffer> implements Consumer<FluxSink<Part>> {
|
||||
|
||||
private final ReactiveHttpInputMessage inputMessage;
|
||||
|
||||
private final LimitedPartBodyStreamStorageFactory storageFactory = new LimitedPartBodyStreamStorageFactory();
|
||||
|
||||
private final Path fileStorageDirectory;
|
||||
|
||||
@Nullable
|
||||
private NioMultipartParserListener listener;
|
||||
|
||||
@Nullable
|
||||
private NioMultipartParser parser;
|
||||
|
||||
public SynchronossPartGenerator(ReactiveHttpInputMessage inputMessage, Path fileStorageDirectory) {
|
||||
this.inputMessage = inputMessage;
|
||||
this.fileStorageDirectory = fileStorageDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(FluxSink<Part> sink) {
|
||||
HttpHeaders headers = this.inputMessage.getHeaders();
|
||||
MediaType mediaType = headers.getContentType();
|
||||
Assert.state(mediaType != null, "No content type set");
|
||||
|
||||
int length = getContentLength(headers);
|
||||
Charset charset = Optional.ofNullable(mediaType.getCharset()).orElse(StandardCharsets.UTF_8);
|
||||
MultipartContext context = new MultipartContext(mediaType.toString(), length, charset.name());
|
||||
|
||||
this.listener = new FluxSinkAdapterListener(sink, context, this.storageFactory);
|
||||
|
||||
this.parser = Multipart
|
||||
.multipart(context)
|
||||
.saveTemporaryFilesTo(this.fileStorageDirectory.toString())
|
||||
.usePartBodyStreamStorageFactory(this.storageFactory)
|
||||
.forNIO(this.listener);
|
||||
|
||||
this.inputMessage.getBody().subscribe(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hookOnNext(DataBuffer buffer) {
|
||||
Assert.state(this.parser != null && this.listener != null, "Not initialized yet");
|
||||
|
||||
int size = buffer.readableByteCount();
|
||||
this.storageFactory.increaseByteCount(size);
|
||||
byte[] resultBytes = new byte[size];
|
||||
buffer.read(resultBytes);
|
||||
|
||||
try {
|
||||
this.parser.write(resultBytes);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
cancel();
|
||||
int index = this.storageFactory.getCurrentPartIndex();
|
||||
this.listener.onError("Parser error for part [" + index + "]", ex);
|
||||
}
|
||||
finally {
|
||||
DataBufferUtils.release(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hookOnError(Throwable ex) {
|
||||
if (this.listener != null) {
|
||||
int index = this.storageFactory.getCurrentPartIndex();
|
||||
this.listener.onError("Failure while parsing part[" + index + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hookOnComplete() {
|
||||
if (this.listener != null) {
|
||||
this.listener.onAllPartsFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hookFinally(SignalType type) {
|
||||
try {
|
||||
if (this.parser != null) {
|
||||
this.parser.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private int getContentLength(HttpHeaders headers) {
|
||||
// Until this is fixed https://github.com/synchronoss/nio-multipart/issues/10
|
||||
long length = headers.getContentLength();
|
||||
return (int) length == length ? (int) length : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class LimitedPartBodyStreamStorageFactory implements PartBodyStreamStorageFactory {
|
||||
|
||||
private final PartBodyStreamStorageFactory storageFactory = (maxInMemorySize > 0 ?
|
||||
new DefaultPartBodyStreamStorageFactory(maxInMemorySize) :
|
||||
new DefaultPartBodyStreamStorageFactory());
|
||||
|
||||
private int index = 1;
|
||||
|
||||
private boolean isFilePart;
|
||||
|
||||
private long partSize;
|
||||
|
||||
public int getCurrentPartIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamStorage newStreamStorageForPartBody(Map<String, List<String>> headers, int index) {
|
||||
this.index = index;
|
||||
this.isFilePart = (MultipartUtils.getFileName(headers) != null);
|
||||
this.partSize = 0;
|
||||
if (maxParts > 0 && index > maxParts) {
|
||||
throw new DecodingException("Too many parts: Part[" + index + "] but maxParts=" + maxParts);
|
||||
}
|
||||
return this.storageFactory.newStreamStorageForPartBody(headers, index);
|
||||
}
|
||||
|
||||
public void increaseByteCount(long byteCount) {
|
||||
this.partSize += byteCount;
|
||||
if (maxInMemorySize > 0 && !this.isFilePart && this.partSize >= maxInMemorySize) {
|
||||
throw new DataBufferLimitException("Part[" + this.index + "] " +
|
||||
"exceeded the in-memory limit of " + maxInMemorySize + " bytes");
|
||||
}
|
||||
if (maxDiskUsagePerPart > 0 && this.isFilePart && this.partSize > maxDiskUsagePerPart) {
|
||||
throw new DecodingException("Part[" + this.index + "] " +
|
||||
"exceeded the disk usage limit of " + maxDiskUsagePerPart + " bytes");
|
||||
}
|
||||
}
|
||||
|
||||
public void partFinished() {
|
||||
this.index++;
|
||||
this.isFilePart = false;
|
||||
this.partSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listen for parser output and adapt to {@code Flux<Sink<Part>>}.
|
||||
*/
|
||||
private static class FluxSinkAdapterListener implements NioMultipartParserListener {
|
||||
|
||||
private final FluxSink<Part> sink;
|
||||
|
||||
private final MultipartContext context;
|
||||
|
||||
private final LimitedPartBodyStreamStorageFactory storageFactory;
|
||||
|
||||
private final AtomicInteger terminated = new AtomicInteger();
|
||||
|
||||
FluxSinkAdapterListener(
|
||||
FluxSink<Part> sink, MultipartContext context, LimitedPartBodyStreamStorageFactory factory) {
|
||||
|
||||
this.sink = sink;
|
||||
this.context = context;
|
||||
this.storageFactory = factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPartFinished(StreamStorage storage, Map<String, List<String>> headers) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.putAll(headers);
|
||||
this.storageFactory.partFinished();
|
||||
this.sink.next(createPart(storage, httpHeaders));
|
||||
}
|
||||
|
||||
private Part createPart(StreamStorage storage, HttpHeaders httpHeaders) {
|
||||
String filename = MultipartUtils.getFileName(httpHeaders);
|
||||
if (filename != null) {
|
||||
return new SynchronossFilePart(httpHeaders, filename, storage);
|
||||
}
|
||||
else if (MultipartUtils.isFormField(httpHeaders, this.context)) {
|
||||
String value = MultipartUtils.readFormParameterValue(storage, httpHeaders);
|
||||
return new SynchronossFormFieldPart(httpHeaders, value);
|
||||
}
|
||||
else {
|
||||
return new SynchronossPart(httpHeaders, storage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, Throwable cause) {
|
||||
if (this.terminated.getAndIncrement() == 0) {
|
||||
this.sink.error(new DecodingException(message, cause));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllPartsFinished() {
|
||||
if (this.terminated.getAndIncrement() == 0) {
|
||||
this.sink.complete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNestedPartStarted(Map<String, List<String>> headersFromParentPart) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNestedPartFinished() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private abstract static class AbstractSynchronossPart implements Part {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final HttpHeaders headers;
|
||||
|
||||
AbstractSynchronossPart(HttpHeaders headers) {
|
||||
Assert.notNull(headers, "HttpHeaders is required");
|
||||
this.name = MultipartUtils.getFieldName(headers);
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders headers() {
|
||||
return this.headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Part '" + this.name + "', headers=" + this.headers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class SynchronossPart extends AbstractSynchronossPart {
|
||||
|
||||
private final StreamStorage storage;
|
||||
|
||||
SynchronossPart(HttpHeaders headers, StreamStorage storage) {
|
||||
super(headers);
|
||||
Assert.notNull(storage, "StreamStorage is required");
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("resource")
|
||||
public Flux<DataBuffer> content() {
|
||||
return DataBufferUtils.readInputStream(
|
||||
getStorage()::getInputStream, DefaultDataBufferFactory.sharedInstance, 4096);
|
||||
}
|
||||
|
||||
protected StreamStorage getStorage() {
|
||||
return this.storage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class SynchronossFilePart extends SynchronossPart implements FilePart {
|
||||
|
||||
private static final OpenOption[] FILE_CHANNEL_OPTIONS =
|
||||
{StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE};
|
||||
|
||||
private final String filename;
|
||||
|
||||
SynchronossFilePart(HttpHeaders headers, String filename, StreamStorage storage) {
|
||||
super(headers, storage);
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filename() {
|
||||
return this.filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> transferTo(Path dest) {
|
||||
ReadableByteChannel input = null;
|
||||
FileChannel output = null;
|
||||
try {
|
||||
input = Channels.newChannel(getStorage().getInputStream());
|
||||
output = FileChannel.open(dest, FILE_CHANNEL_OPTIONS);
|
||||
long size = (input instanceof FileChannel ? ((FileChannel) input).size() : Long.MAX_VALUE);
|
||||
long totalWritten = 0;
|
||||
while (totalWritten < size) {
|
||||
long written = output.transferFrom(input, totalWritten, size - totalWritten);
|
||||
if (written <= 0) {
|
||||
break;
|
||||
}
|
||||
totalWritten += written;
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return Mono.error(ex);
|
||||
}
|
||||
finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
if (output != null) {
|
||||
try {
|
||||
output.close();
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Part '" + name() + "', filename='" + this.filename + "'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class SynchronossFormFieldPart extends AbstractSynchronossPart implements FormFieldPart {
|
||||
|
||||
private final String content;
|
||||
|
||||
SynchronossFormFieldPart(HttpHeaders headers, String content) {
|
||||
super(headers);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<DataBuffer> content() {
|
||||
byte[] bytes = this.content.getBytes(getCharset());
|
||||
return Flux.just(DefaultDataBufferFactory.sharedInstance.wrap(bytes));
|
||||
}
|
||||
|
||||
private Charset getCharset() {
|
||||
String name = MultipartUtils.getCharEncoding(headers());
|
||||
return (name != null ? Charset.forName(name) : StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Part '" + name() + "=" + this.content + "'";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,7 +58,6 @@ import org.springframework.http.codec.json.KotlinSerializationJsonEncoder;
|
||||
import org.springframework.http.codec.multipart.DefaultPartHttpMessageReader;
|
||||
import org.springframework.http.codec.multipart.MultipartHttpMessageReader;
|
||||
import org.springframework.http.codec.multipart.MultipartHttpMessageWriter;
|
||||
import org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader;
|
||||
import org.springframework.http.codec.protobuf.ProtobufDecoder;
|
||||
import org.springframework.http.codec.protobuf.ProtobufEncoder;
|
||||
import org.springframework.http.codec.protobuf.ProtobufHttpMessageWriter;
|
||||
@@ -103,7 +102,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
|
||||
jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
|
||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", classLoader);
|
||||
jackson2SmilePresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
|
||||
jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", classLoader);
|
||||
jaxb2Present = ClassUtils.isPresent("jakarta.xml.bind.Binder", classLoader);
|
||||
protobufPresent = ClassUtils.isPresent("com.google.protobuf.Message", classLoader);
|
||||
synchronossMultipartPresent = ClassUtils.isPresent("org.synchronoss.cloud.nio.multipart.NioMultipartParser", classLoader);
|
||||
nettyByteBufPresent = ClassUtils.isPresent("io.netty.buffer.ByteBuf", classLoader);
|
||||
@@ -417,11 +416,6 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
|
||||
if (codec instanceof DefaultPartHttpMessageReader) {
|
||||
((DefaultPartHttpMessageReader) codec).setMaxInMemorySize(size);
|
||||
}
|
||||
if (synchronossMultipartPresent) {
|
||||
if (codec instanceof SynchronossPartHttpMessageReader) {
|
||||
((SynchronossPartHttpMessageReader) codec).setMaxInMemorySize(size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Boolean enable = this.enableLoggingRequestDetails;
|
||||
@@ -435,11 +429,6 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
|
||||
if (codec instanceof DefaultPartHttpMessageReader) {
|
||||
((DefaultPartHttpMessageReader) codec).setEnableLoggingRequestDetails(enable);
|
||||
}
|
||||
if (synchronossMultipartPresent) {
|
||||
if (codec instanceof SynchronossPartHttpMessageReader) {
|
||||
((SynchronossPartHttpMessageReader) codec).setEnableLoggingRequestDetails(enable);
|
||||
}
|
||||
}
|
||||
if (codec instanceof FormHttpMessageWriter) {
|
||||
((FormHttpMessageWriter) codec).setEnableLoggingRequestDetails(enable);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -24,19 +24,19 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.UnmarshalException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.UnmarshalException;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlSchema;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.Exceptions;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -175,7 +175,6 @@ public class Jaxb2XmlDecoder extends AbstractDecoder<Object> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked", "cast"}) // XMLEventReader is Iterator<Object> on JDK 9
|
||||
public Mono<Object> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType,
|
||||
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
|
||||
|
||||
@@ -184,12 +183,11 @@ public class Jaxb2XmlDecoder extends AbstractDecoder<Object> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked", "cast"}) // XMLEventReader is Iterator<Object> on JDK 9
|
||||
public Object decode(DataBuffer dataBuffer, ResolvableType targetType,
|
||||
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException {
|
||||
|
||||
try {
|
||||
Iterator eventReader = inputFactory.createXMLEventReader(dataBuffer.asInputStream());
|
||||
Iterator<Object> eventReader = inputFactory.createXMLEventReader(dataBuffer.asInputStream());
|
||||
List<XMLEvent> events = new ArrayList<>();
|
||||
eventReader.forEachRemaining(event -> events.add((XMLEvent) event));
|
||||
return unmarshal(events, targetType.toClass());
|
||||
|
||||
@@ -21,12 +21,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.MarshalException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.MarshalException;
|
||||
import jakarta.xml.bind.Marshaller;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -48,8 +47,8 @@ import org.springframework.util.MimeTypeUtils;
|
||||
/**
|
||||
* Encode from single value to a byte stream containing XML elements.
|
||||
*
|
||||
* <p>{@link javax.xml.bind.annotation.XmlElements @XmlElements} and
|
||||
* {@link javax.xml.bind.annotation.XmlElement @XmlElement} can be used
|
||||
* <p>{@link jakarta.xml.bind.annotation.XmlElements @XmlElements} and
|
||||
* {@link jakarta.xml.bind.annotation.XmlElement @XmlElement} can be used
|
||||
* to specify how collections should be marshalled.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
|
||||
@@ -19,10 +19,10 @@ package org.springframework.http.codec.xml;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import jakarta.xml.bind.JAXBContext;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.Marshaller;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
||||
|
||||
import org.springframework.core.codec.CodecException;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.MimeUtility;
|
||||
import jakarta.mail.internet.MimeUtility;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpEntity;
|
||||
@@ -287,7 +287,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
/**
|
||||
* Set the character set to use when writing multipart data to encode file
|
||||
* names. Encoding is based on the {@code encoded-word} syntax defined in
|
||||
* RFC 2047 and relies on {@code MimeUtility} from {@code javax.mail}.
|
||||
* RFC 2047 and relies on {@code MimeUtility} from {@code jakarta.mail}.
|
||||
* <p>As of 5.0 by default part headers, including {@code Content-Disposition}
|
||||
* (and its filename parameter) will be encoded based on the setting of
|
||||
* {@link #setCharset(Charset)} or {@code UTF-8} by default.
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.io.Writer;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import javax.json.bind.Jsonb;
|
||||
import javax.json.bind.JsonbBuilder;
|
||||
import javax.json.bind.JsonbConfig;
|
||||
import jakarta.json.bind.Jsonb;
|
||||
import jakarta.json.bind.JsonbBuilder;
|
||||
import jakarta.json.bind.JsonbConfig;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -39,8 +39,8 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 5.0
|
||||
* @see javax.json.bind.Jsonb
|
||||
* @see javax.json.bind.JsonbBuilder
|
||||
* @see jakarta.json.bind.Jsonb
|
||||
* @see jakarta.json.bind.JsonbBuilder
|
||||
* @see #setJsonb
|
||||
*/
|
||||
public class JsonbHttpMessageConverter extends AbstractJsonHttpMessageConverter {
|
||||
|
||||
@@ -62,13 +62,13 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = AllEncompassingFormHttpMessageConverter.class.getClassLoader();
|
||||
jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", classLoader);
|
||||
jaxb2Present = ClassUtils.isPresent("jakarta.xml.bind.Binder", classLoader);
|
||||
jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
|
||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", classLoader);
|
||||
jackson2XmlPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", classLoader);
|
||||
jackson2SmilePresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
|
||||
gsonPresent = ClassUtils.isPresent("com.google.gson.Gson", classLoader);
|
||||
jsonbPresent = ClassUtils.isPresent("javax.json.bind.Jsonb", classLoader);
|
||||
jsonbPresent = ClassUtils.isPresent("jakarta.json.bind.Jsonb", classLoader);
|
||||
kotlinSerializationJsonPresent = ClassUtils.isPresent("kotlinx.serialization.json.Json", classLoader);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package org.springframework.http.converter.xml;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import jakarta.xml.bind.JAXBContext;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.Marshaller;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
||||
|
||||
import org.springframework.http.converter.HttpMessageConversionException;
|
||||
|
||||
|
||||
@@ -26,17 +26,18 @@ import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.UnmarshalException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.UnmarshalException;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -18,20 +18,20 @@ package org.springframework.http.converter.xml;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.MarshalException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.PropertyException;
|
||||
import javax.xml.bind.UnmarshalException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.MarshalException;
|
||||
import jakarta.xml.bind.Marshaller;
|
||||
import jakarta.xml.bind.PropertyException;
|
||||
import jakarta.xml.bind.UnmarshalException;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
@@ -149,7 +149,7 @@ public class Jaxb2RootElementHttpMessageConverter extends AbstractJaxb2HttpMessa
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // on JDK 9
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Source processSource(Source source) {
|
||||
if (source instanceof StreamSource) {
|
||||
StreamSource streamSource = (StreamSource) source;
|
||||
|
||||
@@ -19,11 +19,11 @@ package org.springframework.http.server;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.AsyncEvent;
|
||||
import jakarta.servlet.AsyncListener;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -234,7 +234,7 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link javax.servlet.ServletRequest#getParameterMap()} to reconstruct the
|
||||
* Use {@link jakarta.servlet.ServletRequest#getParameterMap()} to reconstruct the
|
||||
* body of a form 'POST' providing a predictable outcome as opposed to reading
|
||||
* from the body, which can fail if any other code has used the ServletRequest
|
||||
* to access a parameter, thus causing the input stream to be "consumed".
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* <p>There is a duplicate of this class in the client package!
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Juergen Hoeller
|
||||
* @since 5.1.1
|
||||
*/
|
||||
class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@@ -58,7 +59,10 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void add(String key, @Nullable String value) {
|
||||
this.headers.add(key, value);
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
((HttpFields.Mutable) this.headers).add(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +77,10 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void set(String key, @Nullable String value) {
|
||||
this.headers.put(key, value);
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
((HttpFields.Mutable) this.headers).put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,7 +112,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return (key instanceof String && this.headers.containsKey((String) key));
|
||||
return (key instanceof String && this.headers.contains((String) key));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,17 +133,23 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> put(String key, List<String> value) {
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
List<String> oldValues = get(key);
|
||||
this.headers.put(key, value);
|
||||
((HttpFields.Mutable) this.headers).put(key, value);
|
||||
return oldValues;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> remove(Object key) {
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
if (key instanceof String) {
|
||||
List<String> oldValues = get(key);
|
||||
this.headers.remove((String) key);
|
||||
((HttpFields.Mutable) this.headers).remove((String) key);
|
||||
return oldValues;
|
||||
}
|
||||
return null;
|
||||
@@ -149,7 +162,10 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.headers.clear();
|
||||
if (!(this.headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
((HttpFields.Mutable) this.headers).clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,8 +237,11 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public List<String> setValue(List<String> value) {
|
||||
if (!(headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
List<String> previousValues = headers.getValuesList(this.key);
|
||||
headers.put(this.key, value);
|
||||
((HttpFields.Mutable) headers).put(this.key, value);
|
||||
return previousValues;
|
||||
}
|
||||
}
|
||||
@@ -266,13 +285,16 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (!(headers instanceof HttpFields.Mutable)) {
|
||||
throw new IllegalStateException("Immutable headers");
|
||||
}
|
||||
if (this.currentName == null) {
|
||||
throw new IllegalStateException("No current Header in iterator");
|
||||
}
|
||||
if (!headers.containsKey(this.currentName)) {
|
||||
if (!headers.contains(this.currentName)) {
|
||||
throw new IllegalStateException("Header not present: " + this.currentName);
|
||||
}
|
||||
headers.remove(this.currentName);
|
||||
((HttpFields.Mutable) headers).remove(this.currentName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,12 @@ import java.net.URISyntaxException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponseWrapper;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.server.HttpOutput;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
@@ -38,7 +37,6 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
@@ -52,10 +50,6 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
public class JettyHttpHandlerAdapter extends ServletHttpHandlerAdapter {
|
||||
|
||||
private static final boolean jetty10Present = ClassUtils.isPresent(
|
||||
"org.eclipse.jetty.http.CookieCutter", JettyHttpHandlerAdapter.class.getClassLoader());
|
||||
|
||||
|
||||
public JettyHttpHandlerAdapter(HttpHandler httpHandler) {
|
||||
super(httpHandler);
|
||||
}
|
||||
@@ -65,11 +59,6 @@ public class JettyHttpHandlerAdapter extends ServletHttpHandlerAdapter {
|
||||
protected ServletServerHttpRequest createRequest(HttpServletRequest request, AsyncContext context)
|
||||
throws IOException, URISyntaxException {
|
||||
|
||||
// TODO: need to compile against Jetty 10 to use HttpFields (class->interface)
|
||||
if (jetty10Present) {
|
||||
return super.createRequest(request, context);
|
||||
}
|
||||
|
||||
Assert.notNull(getServletPath(), "Servlet path is not initialized");
|
||||
return new JettyServerHttpRequest(
|
||||
request, context, getServletPath(), getDataBufferFactory(), getBufferSize());
|
||||
@@ -79,15 +68,8 @@ public class JettyHttpHandlerAdapter extends ServletHttpHandlerAdapter {
|
||||
protected ServletServerHttpResponse createResponse(HttpServletResponse response,
|
||||
AsyncContext context, ServletServerHttpRequest request) throws IOException {
|
||||
|
||||
// TODO: need to compile against Jetty 10 to use HttpFields (class->interface)
|
||||
if (jetty10Present) {
|
||||
return new BaseJettyServerHttpResponse(
|
||||
response, context, getDataBufferFactory(), getBufferSize(), request);
|
||||
}
|
||||
else {
|
||||
return new JettyServerHttpResponse(
|
||||
response, context, getDataBufferFactory(), getBufferSize(), request);
|
||||
}
|
||||
return new JettyServerHttpResponse(
|
||||
response, context, getDataBufferFactory(), getBufferSize(), request);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,39 +102,10 @@ public class JettyHttpHandlerAdapter extends ServletHttpHandlerAdapter {
|
||||
"] to org.eclipse.jetty.server.Request");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class BaseJettyServerHttpResponse extends ServletServerHttpResponse {
|
||||
|
||||
BaseJettyServerHttpResponse(HttpServletResponse response, AsyncContext asyncContext,
|
||||
DataBufferFactory bufferFactory, int bufferSize, ServletServerHttpRequest request)
|
||||
throws IOException {
|
||||
|
||||
super(response, asyncContext, bufferFactory, bufferSize, request);
|
||||
}
|
||||
|
||||
BaseJettyServerHttpResponse(HttpHeaders headers, HttpServletResponse response, AsyncContext asyncContext,
|
||||
DataBufferFactory bufferFactory, int bufferSize, ServletServerHttpRequest request)
|
||||
throws IOException {
|
||||
|
||||
super(headers, response, asyncContext, bufferFactory, bufferSize, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int writeToOutputStream(DataBuffer dataBuffer) throws IOException {
|
||||
ByteBuffer input = dataBuffer.asByteBuffer();
|
||||
int len = input.remaining();
|
||||
ServletResponse response = getNativeResponse();
|
||||
((HttpOutput) response.getOutputStream()).write(input);
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final class JettyServerHttpResponse extends BaseJettyServerHttpResponse {
|
||||
private static final class JettyServerHttpResponse extends ServletServerHttpResponse {
|
||||
|
||||
JettyServerHttpResponse(HttpServletResponse response, AsyncContext asyncContext,
|
||||
DataBufferFactory bufferFactory, int bufferSize, ServletServerHttpRequest request)
|
||||
@@ -182,6 +135,15 @@ public class JettyHttpHandlerAdapter extends ServletHttpHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int writeToOutputStream(DataBuffer dataBuffer) throws IOException {
|
||||
ByteBuffer input = dataBuffer.asByteBuffer();
|
||||
int len = input.remaining();
|
||||
ServletResponse response = getNativeResponse();
|
||||
((HttpOutput) response.getOutputStream()).write(input);
|
||||
return len;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyHeaders() {
|
||||
HttpServletResponse response = getNativeResponse();
|
||||
|
||||
@@ -21,20 +21,19 @@ import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.AsyncEvent;
|
||||
import jakarta.servlet.AsyncListener;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import jakarta.servlet.Servlet;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRegistration;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
|
||||
@@ -26,14 +26,13 @@ import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.AsyncEvent;
|
||||
import jakarta.servlet.AsyncListener;
|
||||
import jakarta.servlet.ReadListener;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.logging.Log;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -203,12 +202,12 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
@Nullable
|
||||
private String getSslSessionId() {
|
||||
return (String) this.request.getAttribute("javax.servlet.request.ssl_session_id");
|
||||
return (String) this.request.getAttribute("jakarta.servlet.request.ssl_session_id");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private X509Certificate[] getX509Certificates() {
|
||||
String name = "javax.servlet.request.X509Certificate";
|
||||
String name = "jakarta.servlet.request.X509Certificate";
|
||||
return (X509Certificate[]) this.request.getAttribute(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,12 @@ import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.WriteListener;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.AsyncEvent;
|
||||
import jakarta.servlet.AsyncListener;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.WriteListener;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.reactivestreams.Processor;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
|
||||
@@ -22,15 +22,14 @@ import java.net.URISyntaxException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponseWrapper;
|
||||
import org.apache.catalina.connector.CoyoteInputStream;
|
||||
import org.apache.catalina.connector.CoyoteOutputStream;
|
||||
import org.apache.catalina.connector.RequestFacade;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.web;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@ package org.springframework.web;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Plain handler interface for components that process HTTP requests,
|
||||
* analogous to a Servlet. Only declares {@link javax.servlet.ServletException}
|
||||
* analogous to a Servlet. Only declares {@link jakarta.servlet.ServletException}
|
||||
* and {@link java.io.IOException}, to allow for usage within any
|
||||
* {@link javax.servlet.http.HttpServlet}. This interface is essentially the
|
||||
* {@link jakarta.servlet.http.HttpServlet}. This interface is essentially the
|
||||
* direct equivalent of an HttpServlet, reduced to a central handle method.
|
||||
*
|
||||
* <p>The easiest way to expose an HttpRequestHandler bean in Spring style
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.HandlesTypes;
|
||||
import jakarta.servlet.ServletContainerInitializer;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.HandlesTypes;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -43,7 +43,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* method invoked by any Servlet 3.0-compliant container during container startup assuming
|
||||
* that the {@code spring-web} module JAR is present on the classpath. This occurs through
|
||||
* the JAR Services API {@link ServiceLoader#load(Class)} method detecting the
|
||||
* {@code spring-web} module's {@code META-INF/services/javax.servlet.ServletContainerInitializer}
|
||||
* {@code spring-web} module's {@code META-INF/services/jakarta.servlet.ServletContainerInitializer}
|
||||
* service provider configuration file. See the
|
||||
* <a href="https://download.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider">
|
||||
* JAR Services API documentation</a> as well as section <em>8.2.4</em> of the Servlet 3.0
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
/**
|
||||
* Interface to be implemented in Servlet 3.0+ environments in order to configure the
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
*
|
||||
* <p>The method {@link #handleNoMatch} allow sub-classes to plug in additional
|
||||
* ways of looking up media types (e.g. through the Java Activation framework,
|
||||
* or {@link javax.servlet.ServletContext#getMimeType}. Media types resolved
|
||||
* or {@link jakarta.servlet.ServletContext#getMimeType}. Media types resolved
|
||||
* via base classes are then added to the base class
|
||||
* {@link MappingMediaTypeFileExtensionResolver}, i.e. cached for new lookups.
|
||||
*
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.web.accept;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.accept;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.bind;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -56,7 +56,7 @@ import org.springframework.web.util.WebUtils;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @see #bind(javax.servlet.ServletRequest)
|
||||
* @see #bind(jakarta.servlet.ServletRequest)
|
||||
* @see #registerCustomEditor
|
||||
* @see #setAllowedFields
|
||||
* @see #setRequiredFields
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.bind;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.bind;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class UnsatisfiedServletRequestParameterException extends ServletRequestB
|
||||
|
||||
/**
|
||||
* Return the actual parameter Map associated with the ServletRequest.
|
||||
* @see javax.servlet.ServletRequest#getParameterMap()
|
||||
* @see jakarta.servlet.ServletRequest#getParameterMap()
|
||||
*/
|
||||
public final Map<String, String[]> getActualParams() {
|
||||
return this.actualParams;
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
|
||||
* as Spring beans or auto-detected via classpath scanning. All such beans are
|
||||
* sorted based on {@link org.springframework.core.Ordered Ordered} semantics or
|
||||
* {@link org.springframework.core.annotation.Order @Order} /
|
||||
* {@link javax.annotation.Priority @Priority} declarations, with {@code Ordered}
|
||||
* {@link jakarta.annotation.Priority @Priority} declarations, with {@code Ordered}
|
||||
* semantics taking precedence over {@code @Order} / {@code @Priority} declarations.
|
||||
* {@code @ControllerAdvice} beans are then applied in that order at runtime.
|
||||
* Note, however, that {@code @ControllerAdvice} beans that implement
|
||||
|
||||
@@ -27,12 +27,12 @@ import org.springframework.core.annotation.AliasFor;
|
||||
/**
|
||||
* Annotation to indicate that a method parameter is bound to an HTTP cookie.
|
||||
*
|
||||
* <p>The method parameter may be declared as type {@link javax.servlet.http.Cookie}
|
||||
* <p>The method parameter may be declared as type {@link jakarta.servlet.http.Cookie}
|
||||
* or as cookie value type (String, int, etc.).
|
||||
*
|
||||
* <p>Note that with spring-webmvc 5.3.x and earlier, the cookie value is URL
|
||||
* decoded. This will be changed in 6.0 but in the meantime, applications can
|
||||
* also declare parameters of type {@link javax.servlet.http.Cookie} to access
|
||||
* also declare parameters of type {@link jakarta.servlet.http.Cookie} to access
|
||||
* the raw value.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -38,8 +38,8 @@ import java.lang.annotation.Target;
|
||||
* exposed, whereas previously only an immediate cause was considered.
|
||||
* <li>Request and/or response objects (typically from the Servlet API).
|
||||
* You may choose any specific request/response type, e.g.
|
||||
* {@link javax.servlet.ServletRequest} / {@link javax.servlet.http.HttpServletRequest}.
|
||||
* <li>Session object: typically {@link javax.servlet.http.HttpSession}.
|
||||
* {@link jakarta.servlet.ServletRequest} / {@link jakarta.servlet.http.HttpServletRequest}.
|
||||
* <li>Session object: typically {@link jakarta.servlet.http.HttpSession}.
|
||||
* An argument of this type will enforce the presence of a corresponding session.
|
||||
* As a consequence, such an argument will never be {@code null}.
|
||||
* <i>Note that session access may not be thread-safe, in particular in a
|
||||
@@ -88,7 +88,7 @@ import java.lang.annotation.Target;
|
||||
* {@linkplain org.springframework.http.converter.HttpMessageConverter message converters}.
|
||||
* <li>{@code void} if the method handles the response itself (by
|
||||
* writing the response content directly, declaring an argument of type
|
||||
* {@link javax.servlet.ServletResponse} / {@link javax.servlet.http.HttpServletResponse}
|
||||
* {@link jakarta.servlet.ServletResponse} / {@link jakarta.servlet.http.HttpServletResponse}
|
||||
* for that purpose) or if the view name is supposed to be implicitly determined
|
||||
* through a {@link org.springframework.web.servlet.RequestToViewNameTranslator}
|
||||
* (not declaring a response argument in the handler method signature).
|
||||
|
||||
@@ -176,7 +176,7 @@ public @interface RequestMapping {
|
||||
* If specified at both levels, the method level consumes condition overrides
|
||||
* the type level condition.
|
||||
* @see org.springframework.http.MediaType
|
||||
* @see javax.servlet.http.HttpServletRequest#getContentType()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getContentType()
|
||||
*/
|
||||
String[] consumes() default {};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.web.multipart.MultipartResolver;
|
||||
* with a method argument.
|
||||
*
|
||||
* <p>Supported method argument types include {@link MultipartFile} in conjunction with
|
||||
* Spring's {@link MultipartResolver} abstraction, {@code javax.servlet.http.Part} in
|
||||
* Spring's {@link MultipartResolver} abstraction, {@code jakarta.servlet.http.Part} in
|
||||
* conjunction with Servlet 3.0 multipart requests, or otherwise for any other method
|
||||
* argument, the content of the part is passed through an {@link HttpMessageConverter}
|
||||
* taking into consideration the 'Content-Type' header of the request part. This is
|
||||
|
||||
@@ -53,7 +53,7 @@ import org.springframework.http.HttpStatus;
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
* @see org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver
|
||||
* @see javax.servlet.http.HttpServletResponse#sendError(int, String)
|
||||
* @see jakarta.servlet.http.HttpServletResponse#sendError(int, String)
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -71,8 +71,8 @@ public @interface ResponseStatus {
|
||||
* <p>Default is {@link HttpStatus#INTERNAL_SERVER_ERROR}, which should
|
||||
* typically be changed to something more appropriate.
|
||||
* @since 4.2
|
||||
* @see javax.servlet.http.HttpServletResponse#setStatus(int)
|
||||
* @see javax.servlet.http.HttpServletResponse#sendError(int)
|
||||
* @see jakarta.servlet.http.HttpServletResponse#setStatus(int)
|
||||
* @see jakarta.servlet.http.HttpServletResponse#sendError(int)
|
||||
*/
|
||||
@AliasFor("value")
|
||||
HttpStatus code() default HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
@@ -81,7 +81,7 @@ public @interface ResponseStatus {
|
||||
* The <em>reason</em> to be used for the response.
|
||||
* <p>Defaults to an empty string which will be ignored. Set the reason to a
|
||||
* non-empty value to have it used for the response.
|
||||
* @see javax.servlet.http.HttpServletResponse#sendError(int, String)
|
||||
* @see jakarta.servlet.http.HttpServletResponse#sendError(int, String)
|
||||
*/
|
||||
String reason() default "";
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.core.annotation.AliasFor;
|
||||
*
|
||||
* <p>For use cases that require adding or removing session attributes consider
|
||||
* injecting {@code org.springframework.web.context.request.WebRequest} or
|
||||
* {@code javax.servlet.http.HttpSession} into the controller method.
|
||||
* {@code jakarta.servlet.http.HttpSession} into the controller method.
|
||||
*
|
||||
* <p>For temporary storage of model attributes in the session as part of the
|
||||
* workflow for a controller, consider using {@link SessionAttributes} instead.
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.bind.support;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorFactory;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorFactory;
|
||||
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.bind.support;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -104,7 +104,7 @@ public class WebRequestDataBinder extends WebDataBinder {
|
||||
* @param request the request with parameters to bind (can be multipart)
|
||||
* @see org.springframework.web.multipart.MultipartRequest
|
||||
* @see org.springframework.web.multipart.MultipartFile
|
||||
* @see javax.servlet.http.Part
|
||||
* @see jakarta.servlet.http.Part
|
||||
* @see #bind(org.springframework.beans.PropertyValues)
|
||||
*/
|
||||
public void bind(WebRequest request) {
|
||||
|
||||
@@ -121,14 +121,14 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
static {
|
||||
ClassLoader classLoader = RestTemplate.class.getClassLoader();
|
||||
romePresent = ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", classLoader);
|
||||
jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", classLoader);
|
||||
jaxb2Present = ClassUtils.isPresent("jakarta.xml.bind.Binder", classLoader);
|
||||
jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
|
||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", classLoader);
|
||||
jackson2XmlPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", classLoader);
|
||||
jackson2SmilePresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
|
||||
jackson2CborPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.cbor.CBORFactory", classLoader);
|
||||
gsonPresent = ClassUtils.isPresent("com.google.gson.Gson", classLoader);
|
||||
jsonbPresent = ClassUtils.isPresent("javax.json.bind.Jsonb", classLoader);
|
||||
jsonbPresent = ClassUtils.isPresent("jakarta.json.bind.Jsonb", classLoader);
|
||||
kotlinSerializationJsonPresent = ClassUtils.isPresent("kotlinx.serialization.json.Json", classLoader);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -47,7 +47,7 @@ public interface ConfigurableWebApplicationContext extends WebApplicationContext
|
||||
|
||||
/**
|
||||
* Name of the ServletConfig environment bean in the factory.
|
||||
* @see javax.servlet.ServletConfig
|
||||
* @see jakarta.servlet.ServletConfig
|
||||
*/
|
||||
String SERVLET_CONFIG_BEAN_NAME = "servletConfig";
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -18,10 +18,9 @@ package org.springframework.web.context;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContextEvent;
|
||||
import jakarta.servlet.ServletContextListener;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import jakarta.servlet.ServletContextEvent;
|
||||
import jakarta.servlet.ServletContextListener;
|
||||
|
||||
/**
|
||||
* Bootstrap listener to start up and shut down Spring's root {@link WebApplicationContext}.
|
||||
@@ -59,7 +59,7 @@ public class ContextLoaderListener extends ContextLoader implements ServletConte
|
||||
/**
|
||||
* Create a new {@code ContextLoaderListener} with the given application context. This
|
||||
* constructor is useful in Servlet 3.0+ environments where instance-based
|
||||
* registration of listeners is possible through the {@link javax.servlet.ServletContext#addListener}
|
||||
* registration of listeners is possible through the {@link jakarta.servlet.ServletContext#addListener}
|
||||
* API.
|
||||
* <p>The context may or may not yet be {@linkplain
|
||||
* org.springframework.context.ConfigurableApplicationContext#refresh() refreshed}. If it
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
|
||||
import org.springframework.beans.factory.Aware;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.Aware;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -74,7 +74,7 @@ public interface WebApplicationContext extends ApplicationContext {
|
||||
|
||||
/**
|
||||
* Name of the ServletContext environment bean in the factory.
|
||||
* @see javax.servlet.ServletContext
|
||||
* @see jakarta.servlet.ServletContext
|
||||
*/
|
||||
String SERVLET_CONTEXT_BEAN_NAME = "servletContext";
|
||||
|
||||
@@ -82,17 +82,17 @@ public interface WebApplicationContext extends ApplicationContext {
|
||||
* Name of the ServletContext init-params environment bean in the factory.
|
||||
* <p>Note: Possibly merged with ServletConfig parameters.
|
||||
* ServletConfig parameters override ServletContext parameters of the same name.
|
||||
* @see javax.servlet.ServletContext#getInitParameterNames()
|
||||
* @see javax.servlet.ServletContext#getInitParameter(String)
|
||||
* @see javax.servlet.ServletConfig#getInitParameterNames()
|
||||
* @see javax.servlet.ServletConfig#getInitParameter(String)
|
||||
* @see jakarta.servlet.ServletContext#getInitParameterNames()
|
||||
* @see jakarta.servlet.ServletContext#getInitParameter(String)
|
||||
* @see jakarta.servlet.ServletConfig#getInitParameterNames()
|
||||
* @see jakarta.servlet.ServletConfig#getInitParameter(String)
|
||||
*/
|
||||
String CONTEXT_PARAMETERS_BEAN_NAME = "contextParameters";
|
||||
|
||||
/**
|
||||
* Name of the ServletContext attributes environment bean in the factory.
|
||||
* @see javax.servlet.ServletContext#getAttributeNames()
|
||||
* @see javax.servlet.ServletContext#getAttribute(String)
|
||||
* @see jakarta.servlet.ServletContext#getAttributeNames()
|
||||
* @see jakarta.servlet.ServletContext#getAttribute(String)
|
||||
*/
|
||||
String CONTEXT_ATTRIBUTES_BEAN_NAME = "contextAttributes";
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.context.request;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.servlet.http.HttpSessionBindingEvent;
|
||||
import javax.servlet.http.HttpSessionBindingListener;
|
||||
import jakarta.servlet.http.HttpSessionBindingEvent;
|
||||
import jakarta.servlet.http.HttpSessionBindingListener;
|
||||
|
||||
/**
|
||||
* Adapter that implements the Servlet HttpSessionBindingListener interface,
|
||||
|
||||
@@ -19,9 +19,8 @@ package org.springframework.web.context.request;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -31,7 +30,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* {@link RequestAttributes} adapter for a JSF {@link javax.faces.context.FacesContext}.
|
||||
* {@link RequestAttributes} adapter for a JSF {@link jakarta.faces.context.FacesContext}.
|
||||
* Used as default in a JSF environment, wrapping the current FacesContext.
|
||||
*
|
||||
* <p><b>NOTE:</b> In contrast to {@link ServletRequestAttributes}, this variant does
|
||||
@@ -44,9 +43,9 @@ import org.springframework.web.util.WebUtils;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5.2
|
||||
* @see javax.faces.context.FacesContext#getExternalContext()
|
||||
* @see javax.faces.context.ExternalContext#getRequestMap()
|
||||
* @see javax.faces.context.ExternalContext#getSessionMap()
|
||||
* @see jakarta.faces.context.FacesContext#getExternalContext()
|
||||
* @see jakarta.faces.context.ExternalContext#getRequestMap()
|
||||
* @see jakarta.faces.context.ExternalContext#getSessionMap()
|
||||
* @see RequestContextHolder#currentRequestAttributes()
|
||||
*/
|
||||
public class FacesRequestAttributes implements RequestAttributes {
|
||||
@@ -62,7 +61,7 @@ public class FacesRequestAttributes implements RequestAttributes {
|
||||
/**
|
||||
* Create a new FacesRequestAttributes adapter for the given FacesContext.
|
||||
* @param facesContext the current FacesContext
|
||||
* @see javax.faces.context.FacesContext#getCurrentInstance()
|
||||
* @see jakarta.faces.context.FacesContext#getCurrentInstance()
|
||||
*/
|
||||
public FacesRequestAttributes(FacesContext facesContext) {
|
||||
Assert.notNull(facesContext, "FacesContext must not be null");
|
||||
@@ -79,7 +78,7 @@ public class FacesRequestAttributes implements RequestAttributes {
|
||||
|
||||
/**
|
||||
* Return the JSF ExternalContext that this adapter operates on.
|
||||
* @see javax.faces.context.FacesContext#getExternalContext()
|
||||
* @see jakarta.faces.context.FacesContext#getExternalContext()
|
||||
*/
|
||||
protected final ExternalContext getExternalContext() {
|
||||
return getFacesContext().getExternalContext();
|
||||
|
||||
@@ -21,14 +21,14 @@ import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link WebRequest} adapter for a JSF {@link javax.faces.context.FacesContext}.
|
||||
* {@link WebRequest} adapter for a JSF {@link jakarta.faces.context.FacesContext}.
|
||||
*
|
||||
* <p>Requires JSF 2.0 or higher, as of Spring 4.0.
|
||||
*
|
||||
@@ -40,7 +40,7 @@ public class FacesWebRequest extends FacesRequestAttributes implements NativeWeb
|
||||
/**
|
||||
* Create a new FacesWebRequest adapter for the given FacesContext.
|
||||
* @param facesContext the current FacesContext
|
||||
* @see javax.faces.context.FacesContext#getCurrentInstance()
|
||||
* @see jakarta.faces.context.FacesContext#getCurrentInstance()
|
||||
*/
|
||||
public FacesWebRequest(FacesContext facesContext) {
|
||||
super(facesContext);
|
||||
|
||||
@@ -32,13 +32,13 @@ public interface NativeWebRequest extends WebRequest {
|
||||
|
||||
/**
|
||||
* Return the underlying native request object.
|
||||
* @see javax.servlet.http.HttpServletRequest
|
||||
* @see jakarta.servlet.http.HttpServletRequest
|
||||
*/
|
||||
Object getNativeRequest();
|
||||
|
||||
/**
|
||||
* Return the underlying native response object, if any.
|
||||
* @see javax.servlet.http.HttpServletResponse
|
||||
* @see jakarta.servlet.http.HttpServletResponse
|
||||
*/
|
||||
@Nullable
|
||||
Object getNativeResponse();
|
||||
@@ -48,7 +48,7 @@ public interface NativeWebRequest extends WebRequest {
|
||||
* @param requiredType the desired type of request object
|
||||
* @return the matching request object, or {@code null} if none
|
||||
* of that type is available
|
||||
* @see javax.servlet.http.HttpServletRequest
|
||||
* @see jakarta.servlet.http.HttpServletRequest
|
||||
*/
|
||||
@Nullable
|
||||
<T> T getNativeRequest(@Nullable Class<T> requiredType);
|
||||
@@ -58,7 +58,7 @@ public interface NativeWebRequest extends WebRequest {
|
||||
* @param requiredType the desired type of response object
|
||||
* @return the matching response object, or {@code null} if none
|
||||
* of that type is available
|
||||
* @see javax.servlet.http.HttpServletResponse
|
||||
* @see jakarta.servlet.http.HttpServletResponse
|
||||
*/
|
||||
@Nullable
|
||||
<T> T getNativeResponse(@Nullable Class<T> requiredType);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context.request;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.core.NamedInheritableThreadLocal;
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
@@ -45,7 +45,7 @@ import org.springframework.util.ClassUtils;
|
||||
public abstract class RequestContextHolder {
|
||||
|
||||
private static final boolean jsfPresent =
|
||||
ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
|
||||
ClassUtils.isPresent("jakarta.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
|
||||
|
||||
private static final ThreadLocal<RequestAttributes> requestAttributesHolder =
|
||||
new NamedThreadLocal<>("Request attributes");
|
||||
@@ -119,7 +119,7 @@ public abstract class RequestContextHolder {
|
||||
* @see #setRequestAttributes
|
||||
* @see ServletRequestAttributes
|
||||
* @see FacesRequestAttributes
|
||||
* @see javax.faces.context.FacesContext#getCurrentInstance()
|
||||
* @see jakarta.faces.context.FacesContext#getCurrentInstance()
|
||||
*/
|
||||
public static RequestAttributes currentRequestAttributes() throws IllegalStateException {
|
||||
RequestAttributes attributes = getRequestAttributes();
|
||||
@@ -147,8 +147,14 @@ public abstract class RequestContextHolder {
|
||||
|
||||
@Nullable
|
||||
public static RequestAttributes getFacesRequestAttributes() {
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
return (facesContext != null ? new FacesRequestAttributes(facesContext) : null);
|
||||
try {
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
return (facesContext != null ? new FacesRequestAttributes(facesContext) : null);
|
||||
}
|
||||
catch (NoClassDefFoundError err) {
|
||||
// typically for com/sun/faces/util/Util if only the JSF API jar is present
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.web.context.request;
|
||||
|
||||
import javax.servlet.ServletRequestEvent;
|
||||
import javax.servlet.ServletRequestListener;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.ServletRequestEvent;
|
||||
import jakarta.servlet.ServletRequestListener;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.context.i18n.LocaleContextHolder;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
* @see javax.servlet.ServletRequestListener
|
||||
* @see jakarta.servlet.ServletRequestListener
|
||||
* @see org.springframework.context.i18n.LocaleContextHolder
|
||||
* @see RequestContextHolder
|
||||
* @see org.springframework.web.filter.RequestContextFilter
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -39,8 +39,8 @@ import org.springframework.web.util.WebUtils;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
* @see javax.servlet.ServletRequest#getAttribute
|
||||
* @see javax.servlet.http.HttpSession#getAttribute
|
||||
* @see jakarta.servlet.ServletRequest#getAttribute
|
||||
* @see jakarta.servlet.http.HttpSession#getAttribute
|
||||
*/
|
||||
public class ServletRequestAttributes extends AbstractRequestAttributes {
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ import java.util.TimeZone;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -43,7 +43,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* {@link WebRequest} adapter for an {@link javax.servlet.http.HttpServletRequest}.
|
||||
* {@link WebRequest} adapter for an {@link jakarta.servlet.http.HttpServletRequest}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Brian Clozel
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface WebRequest extends RequestAttributes {
|
||||
* Return the request header of the given name, or {@code null} if none.
|
||||
* <p>Retrieves the first header value in case of a multi-value header.
|
||||
* @since 3.0
|
||||
* @see javax.servlet.http.HttpServletRequest#getHeader(String)
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getHeader(String)
|
||||
*/
|
||||
@Nullable
|
||||
String getHeader(String headerName);
|
||||
@@ -49,7 +49,7 @@ public interface WebRequest extends RequestAttributes {
|
||||
* or {@code null} if none.
|
||||
* <p>A single-value header will be exposed as an array with a single element.
|
||||
* @since 3.0
|
||||
* @see javax.servlet.http.HttpServletRequest#getHeaders(String)
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getHeaders(String)
|
||||
*/
|
||||
@Nullable
|
||||
String[] getHeaderValues(String headerName);
|
||||
@@ -57,14 +57,14 @@ public interface WebRequest extends RequestAttributes {
|
||||
/**
|
||||
* Return a Iterator over request header names.
|
||||
* @since 3.0
|
||||
* @see javax.servlet.http.HttpServletRequest#getHeaderNames()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getHeaderNames()
|
||||
*/
|
||||
Iterator<String> getHeaderNames();
|
||||
|
||||
/**
|
||||
* Return the request parameter of the given name, or {@code null} if none.
|
||||
* <p>Retrieves the first parameter value in case of a multi-value parameter.
|
||||
* @see javax.servlet.http.HttpServletRequest#getParameter(String)
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getParameter(String)
|
||||
*/
|
||||
@Nullable
|
||||
String getParameter(String paramName);
|
||||
@@ -73,7 +73,7 @@ public interface WebRequest extends RequestAttributes {
|
||||
* Return the request parameter values for the given parameter name,
|
||||
* or {@code null} if none.
|
||||
* <p>A single-value parameter will be exposed as an array with a single element.
|
||||
* @see javax.servlet.http.HttpServletRequest#getParameterValues(String)
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getParameterValues(String)
|
||||
*/
|
||||
@Nullable
|
||||
String[] getParameterValues(String paramName);
|
||||
@@ -81,7 +81,7 @@ public interface WebRequest extends RequestAttributes {
|
||||
/**
|
||||
* Return a Iterator over request parameter names.
|
||||
* @since 3.0
|
||||
* @see javax.servlet.http.HttpServletRequest#getParameterNames()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getParameterNames()
|
||||
*/
|
||||
Iterator<String> getParameterNames();
|
||||
|
||||
@@ -89,47 +89,47 @@ public interface WebRequest extends RequestAttributes {
|
||||
* Return a immutable Map of the request parameters, with parameter names as map keys
|
||||
* and parameter values as map values. The map values will be of type String array.
|
||||
* <p>A single-value parameter will be exposed as an array with a single element.
|
||||
* @see javax.servlet.http.HttpServletRequest#getParameterMap()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getParameterMap()
|
||||
*/
|
||||
Map<String, String[]> getParameterMap();
|
||||
|
||||
/**
|
||||
* Return the primary Locale for this request.
|
||||
* @see javax.servlet.http.HttpServletRequest#getLocale()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getLocale()
|
||||
*/
|
||||
Locale getLocale();
|
||||
|
||||
/**
|
||||
* Return the context path for this request
|
||||
* (usually the base path that the current web application is mapped to).
|
||||
* @see javax.servlet.http.HttpServletRequest#getContextPath()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getContextPath()
|
||||
*/
|
||||
String getContextPath();
|
||||
|
||||
/**
|
||||
* Return the remote user for this request, if any.
|
||||
* @see javax.servlet.http.HttpServletRequest#getRemoteUser()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getRemoteUser()
|
||||
*/
|
||||
@Nullable
|
||||
String getRemoteUser();
|
||||
|
||||
/**
|
||||
* Return the user principal for this request, if any.
|
||||
* @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getUserPrincipal()
|
||||
*/
|
||||
@Nullable
|
||||
Principal getUserPrincipal();
|
||||
|
||||
/**
|
||||
* Determine whether the user is in the given role for this request.
|
||||
* @see javax.servlet.http.HttpServletRequest#isUserInRole(String)
|
||||
* @see jakarta.servlet.http.HttpServletRequest#isUserInRole(String)
|
||||
*/
|
||||
boolean isUserInRole(String role);
|
||||
|
||||
/**
|
||||
* Return whether this request has been sent over a secure transport
|
||||
* mechanism (such as SSL).
|
||||
* @see javax.servlet.http.HttpServletRequest#isSecure()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#isSecure()
|
||||
*/
|
||||
boolean isSecure();
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.AsyncEvent;
|
||||
import jakarta.servlet.AsyncListener;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
@@ -24,8 +24,7 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -99,7 +98,7 @@ public final class WebAsyncManager {
|
||||
|
||||
/**
|
||||
* Package-private constructor.
|
||||
* @see WebAsyncUtils#getAsyncManager(javax.servlet.ServletRequest)
|
||||
* @see WebAsyncUtils#getAsyncManager(jakarta.servlet.ServletRequest)
|
||||
* @see WebAsyncUtils#getAsyncManager(org.springframework.web.context.request.WebRequest)
|
||||
*/
|
||||
WebAsyncManager() {
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.web.context.request.async;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.support.AbstractRefreshableConfigApplicationContext;
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.web.context.ContextLoader;
|
||||
* implementation which accepts <em>component classes</em> as input — in particular
|
||||
* {@link org.springframework.context.annotation.Configuration @Configuration}-annotated
|
||||
* classes, but also plain {@link org.springframework.stereotype.Component @Component}
|
||||
* classes and JSR-330 compliant classes using {@code javax.inject} annotations.
|
||||
* classes and JSR-330 compliant classes using {@code jakarta.inject} annotations.
|
||||
*
|
||||
* <p>Allows for registering classes one by one (specifying class names as config
|
||||
* location) as well as for classpath scanning (specifying base packages as config location).
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.web.context.support;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.web.context.support;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.web.context.support;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class RequestHandledEvent extends ApplicationEvent {
|
||||
/**
|
||||
* Return the name of the user that was associated with the request
|
||||
* (usually the UserPrincipal).
|
||||
* @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getUserPrincipal()
|
||||
*/
|
||||
@Nullable
|
||||
public String getUserName() {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
|
||||
import org.springframework.core.env.EnumerablePropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.web.context.support;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -43,7 +42,7 @@ import org.springframework.web.context.ServletContextAware;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.1.4
|
||||
* @see javax.servlet.ServletContext#getAttribute
|
||||
* @see jakarta.servlet.ServletContext#getAttribute
|
||||
* @see WebApplicationContextUtils#getWebApplicationContext
|
||||
*/
|
||||
public class ServletContextAttributeExporter implements ServletContextAware {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Enumeration;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.env.EnumerablePropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.io.AbstractFileResolvingResource;
|
||||
import org.springframework.core.io.ContextResource;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.core.io.Resource} implementation for
|
||||
* {@link javax.servlet.ServletContext} resources, interpreting
|
||||
* {@link jakarta.servlet.ServletContext} resources, interpreting
|
||||
* relative paths within the web application root directory.
|
||||
*
|
||||
* <p>Always supports stream access and URL access, but only allows
|
||||
@@ -45,9 +45,9 @@ import org.springframework.web.util.WebUtils;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 28.12.2003
|
||||
* @see javax.servlet.ServletContext#getResourceAsStream
|
||||
* @see javax.servlet.ServletContext#getResource
|
||||
* @see javax.servlet.ServletContext#getRealPath
|
||||
* @see jakarta.servlet.ServletContext#getResourceAsStream
|
||||
* @see jakarta.servlet.ServletContext#getResource
|
||||
* @see jakarta.servlet.ServletContext#getRealPath
|
||||
*/
|
||||
public class ServletContextResource extends AbstractFileResolvingResource implements ContextResource {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
||||
|
||||
/**
|
||||
* This implementation checks {@code ServletContext.getResource}.
|
||||
* @see javax.servlet.ServletContext#getResource(String)
|
||||
* @see jakarta.servlet.ServletContext#getResource(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean exists() {
|
||||
@@ -112,7 +112,7 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
||||
/**
|
||||
* This implementation delegates to {@code ServletContext.getResourceAsStream},
|
||||
* which returns {@code null} in case of a non-readable resource (e.g. a directory).
|
||||
* @see javax.servlet.ServletContext#getResourceAsStream(String)
|
||||
* @see jakarta.servlet.ServletContext#getResourceAsStream(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadable() {
|
||||
@@ -150,7 +150,7 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
||||
/**
|
||||
* This implementation delegates to {@code ServletContext.getResourceAsStream},
|
||||
* but throws a FileNotFoundException if no resource found.
|
||||
* @see javax.servlet.ServletContext#getResourceAsStream(String)
|
||||
* @see jakarta.servlet.ServletContext#getResourceAsStream(String)
|
||||
*/
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
@@ -164,7 +164,7 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
||||
/**
|
||||
* This implementation delegates to {@code ServletContext.getResource},
|
||||
* but throws a FileNotFoundException if no resource found.
|
||||
* @see javax.servlet.ServletContext#getResource(String)
|
||||
* @see jakarta.servlet.ServletContext#getResource(String)
|
||||
*/
|
||||
@Override
|
||||
public URL getURL() throws IOException {
|
||||
@@ -180,8 +180,8 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
||||
* This implementation resolves "file:" URLs or alternatively delegates to
|
||||
* {@code ServletContext.getRealPath}, throwing a FileNotFoundException
|
||||
* if not found or not resolvable.
|
||||
* @see javax.servlet.ServletContext#getResource(String)
|
||||
* @see javax.servlet.ServletContext#getRealPath(String)
|
||||
* @see jakarta.servlet.ServletContext#getResource(String)
|
||||
* @see jakarta.servlet.ServletContext#getRealPath(String)
|
||||
*/
|
||||
@Override
|
||||
public File getFile() throws IOException {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -52,7 +51,7 @@ public class ServletContextResourcePatternResolver extends PathMatchingResourceP
|
||||
/**
|
||||
* Create a new ServletContextResourcePatternResolver.
|
||||
* @param servletContext the ServletContext to load resources with
|
||||
* @see ServletContextResourceLoader#ServletContextResourceLoader(javax.servlet.ServletContext)
|
||||
* @see ServletContextResourceLoader#ServletContextResourceLoader(jakarta.servlet.ServletContext)
|
||||
*/
|
||||
public ServletContextResourcePatternResolver(ServletContext servletContext) {
|
||||
super(new ServletContextResourceLoader(servletContext));
|
||||
@@ -75,7 +74,7 @@ public class ServletContextResourcePatternResolver extends PathMatchingResourceP
|
||||
* In case of other resources, delegates to the superclass version.
|
||||
* @see #doRetrieveMatchingServletContextResources
|
||||
* @see ServletContextResource
|
||||
* @see javax.servlet.ServletContext#getResourcePaths
|
||||
* @see jakarta.servlet.ServletContext#getResourcePaths
|
||||
*/
|
||||
@Override
|
||||
protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern)
|
||||
@@ -104,7 +103,7 @@ public class ServletContextResourcePatternResolver extends PathMatchingResourceP
|
||||
* @param result the Set of matching Resources to add to
|
||||
* @throws IOException if directory contents could not be retrieved
|
||||
* @see ServletContextResource
|
||||
* @see javax.servlet.ServletContext#getResourcePaths
|
||||
* @see jakarta.servlet.ServletContext#getResourcePaths
|
||||
*/
|
||||
protected void doRetrieveMatchingServletContextResources(
|
||||
ServletContext servletContext, String fullPattern, String dir, Set<Resource> result)
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.web.context.support;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -101,7 +100,7 @@ public abstract class SpringBeanAutowiringSupport {
|
||||
* <p>Intended for use as a delegate.
|
||||
* @param target the target object to process
|
||||
* @param servletContext the ServletContext to find the Spring web application context in
|
||||
* @see WebApplicationContextUtils#getWebApplicationContext(javax.servlet.ServletContext)
|
||||
* @see WebApplicationContextUtils#getWebApplicationContext(jakarta.servlet.ServletContext)
|
||||
*/
|
||||
public static void processInjectionBasedOnServletContext(Object target, ServletContext servletContext) {
|
||||
Assert.notNull(target, "Target object must not be null");
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
@@ -22,13 +22,13 @@ import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
@@ -66,7 +66,7 @@ import org.springframework.web.context.request.WebRequest;
|
||||
public abstract class WebApplicationContextUtils {
|
||||
|
||||
private static final boolean jsfPresent =
|
||||
ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
|
||||
ClassUtils.isPresent("jakarta.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.context.support;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ApplicationObjectSupport;
|
||||
@@ -70,7 +70,7 @@ public abstract class WebApplicationObjectSupport extends ApplicationObjectSuppo
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #initServletContext(javax.servlet.ServletContext)} if the
|
||||
* Calls {@link #initServletContext(jakarta.servlet.ServletContext)} if the
|
||||
* given ApplicationContext is a {@link WebApplicationContext}.
|
||||
*/
|
||||
@Override
|
||||
@@ -89,7 +89,7 @@ public abstract class WebApplicationObjectSupport extends ApplicationObjectSuppo
|
||||
* on the ServletContext that this application object runs in.
|
||||
* <p>The default implementation is empty. Called by
|
||||
* {@link #initApplicationContext(org.springframework.context.ApplicationContext)}
|
||||
* as well as {@link #setServletContext(javax.servlet.ServletContext)}.
|
||||
* as well as {@link #setServletContext(jakarta.servlet.ServletContext)}.
|
||||
* @param servletContext the ServletContext that this application object runs in
|
||||
* (never {@code null})
|
||||
*/
|
||||
@@ -147,7 +147,7 @@ public abstract class WebApplicationObjectSupport extends ApplicationObjectSuppo
|
||||
* as provided by the servlet container.
|
||||
* @return the File representing the temporary directory
|
||||
* @throws IllegalStateException if not running within a ServletContext
|
||||
* @see org.springframework.web.util.WebUtils#getTempDir(javax.servlet.ServletContext)
|
||||
* @see org.springframework.web.util.WebUtils#getTempDir(jakarta.servlet.ServletContext)
|
||||
*/
|
||||
protected final File getTempDir() throws IllegalStateException {
|
||||
ServletContext servletContext = getServletContext();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.cors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.cors;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.cors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
@@ -22,9 +22,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -21,11 +21,11 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.web.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -41,8 +41,8 @@ import org.springframework.util.Assert;
|
||||
* @since 15.03.2004
|
||||
* @see #setEncoding
|
||||
* @see #setForceEncoding
|
||||
* @see javax.servlet.http.HttpServletRequest#setCharacterEncoding
|
||||
* @see javax.servlet.http.HttpServletResponse#setCharacterEncoding
|
||||
* @see jakarta.servlet.http.HttpServletRequest#setCharacterEncoding
|
||||
* @see jakarta.servlet.http.HttpServletResponse#setCharacterEncoding
|
||||
*/
|
||||
public class CharacterEncodingFilter extends OncePerRequestFilter {
|
||||
|
||||
@@ -107,7 +107,7 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
|
||||
|
||||
/**
|
||||
* Set the encoding to use for requests. This encoding will be passed into a
|
||||
* {@link javax.servlet.http.HttpServletRequest#setCharacterEncoding} call.
|
||||
* {@link jakarta.servlet.http.HttpServletRequest#setCharacterEncoding} call.
|
||||
* <p>Whether this encoding will override existing request encodings
|
||||
* (and whether it will be applied as default response encoding as well)
|
||||
* depends on the {@link #setForceEncoding "forceEncoding"} flag.
|
||||
@@ -129,7 +129,7 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
|
||||
* Set whether the configured {@link #setEncoding encoding} of this filter
|
||||
* is supposed to override existing request and response encodings.
|
||||
* <p>Default is "false", i.e. do not modify the encoding if
|
||||
* {@link javax.servlet.http.HttpServletRequest#getCharacterEncoding()}
|
||||
* {@link jakarta.servlet.http.HttpServletRequest#getCharacterEncoding()}
|
||||
* returns a non-null value. Switch this to "true" to enforce the specified
|
||||
* encoding in any case, applying it as default response encoding as well.
|
||||
* <p>This is the equivalent to setting both {@link #setForceRequestEncoding(boolean)}
|
||||
@@ -146,7 +146,7 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
|
||||
* Set whether the configured {@link #setEncoding encoding} of this filter
|
||||
* is supposed to override existing request encodings.
|
||||
* <p>Default is "false", i.e. do not modify the encoding if
|
||||
* {@link javax.servlet.http.HttpServletRequest#getCharacterEncoding()}
|
||||
* {@link jakarta.servlet.http.HttpServletRequest#getCharacterEncoding()}
|
||||
* returns a non-null value. Switch this to "true" to enforce the specified
|
||||
* encoding in any case.
|
||||
* @since 4.3
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.filter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Simple request logging filter that writes the request URI
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user