public abstract class AbstractServerHttpMessageWriter<T> extends Object implements ServerHttpMessageWriter<T>
HttpMessageWriter wrapper that implements ServerHttpMessageWriter in order
to allow providing hints to the nested writer or setting the response status for
example, by implementing resolveWriteHints(ResolvableType, ResolvableType, MediaType, ServerHttpRequest).| Constructor and Description |
|---|
AbstractServerHttpMessageWriter(HttpMessageWriter<T> writer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canWrite(org.springframework.core.ResolvableType elementType,
MediaType mediaType)
Indicates whether the given class can be written by this converter.
|
List<MediaType> |
getWritableMediaTypes()
Return the list of
MediaType objects that can be written by this converter. |
protected abstract Map<String,Object> |
resolveWriteHints(org.springframework.core.ResolvableType streamType,
org.springframework.core.ResolvableType elementType,
MediaType mediaType,
ServerHttpRequest request)
Invoked before writing the response to resolve hints by
write(Publisher, ResolvableType, ResolvableType, MediaType, ServerHttpRequest, ServerHttpResponse, Map). |
reactor.core.publisher.Mono<Void> |
write(org.reactivestreams.Publisher<? extends T> inputStream,
org.springframework.core.ResolvableType elementType,
MediaType mediaType,
ReactiveHttpOutputMessage outputMessage,
Map<String,Object> hints)
Write an given object to the given output message.
|
reactor.core.publisher.Mono<Void> |
write(org.reactivestreams.Publisher<? extends T> inputStream,
org.springframework.core.ResolvableType streamType,
org.springframework.core.ResolvableType elementType,
MediaType mediaType,
ServerHttpRequest request,
ServerHttpResponse response,
Map<String,Object> hints)
Write a given object to the given output message with additional server related
parameters which could be used to create some hints or set the response status for example.
|
public AbstractServerHttpMessageWriter(HttpMessageWriter<T> writer)
public boolean canWrite(org.springframework.core.ResolvableType elementType,
MediaType mediaType)
HttpMessageWritercanWrite in interface HttpMessageWriter<T>elementType - the stream element type to test for writabilitymediaType - the media type to write, can be null if not specified.
Typically the value of an Accept header.true if writable; false otherwisepublic List<MediaType> getWritableMediaTypes()
HttpMessageWriterMediaType objects that can be written by this converter.getWritableMediaTypes in interface HttpMessageWriter<T>public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, org.springframework.core.ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map<String,Object> hints)
HttpMessageWriterwrite in interface HttpMessageWriter<T>inputStream - the input stream to writeelementType - the stream element type to process. This type must have previously
been passed to the HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType) canWrite} method of this interface, which must
have returned true.mediaType - the content type to use when writing, typically the value of an
Accept header. May be null to indicate that the default content
type of the converter must be used.outputMessage - the message to write tohints - additional information about how to writeMono that indicates completion or errorpublic reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, org.springframework.core.ResolvableType streamType, org.springframework.core.ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
ServerHttpMessageWriterwrite in interface ServerHttpMessageWriter<T>streamType - the original type used for the method return value. For annotation
based controllers, the MethodParameter is available via ResolvableType.getSource().
Can be null.elementType - the stream element type to processmediaType - the content type to use when writing. May be null to
indicate that the default content type of the converter must be used.request - the current HTTP requestresponse - the current HTTP responseMono that indicates completion or errorprotected abstract Map<String,Object> resolveWriteHints(org.springframework.core.ResolvableType streamType, org.springframework.core.ResolvableType elementType, MediaType mediaType, ServerHttpRequest request)
write(Publisher, ResolvableType, ResolvableType, MediaType, ServerHttpRequest, ServerHttpResponse, Map).streamType - the original type used for the method return value. For annotation
based controllers, the MethodParameter is available via ResolvableType.getSource().elementType - the stream element type to processmediaType - the content type to use when writing. May be null to
indicate that the default content type of the converter must be used.request - the current HTTP request