Package org.thymeleaf.spring6
Interface ISpringWebFluxTemplateEngine
- All Superinterfaces:
ISpringTemplateEngine
,ITemplateEngine
- All Known Implementing Classes:
SpringWebFluxTemplateEngine
Sub-interface of ISpringTemplateEngine
meant for Spring WebFlux applications, adding
methods specifically needed for the execution of templates in a reactive-friendly way.
Template engines implementing this interface offer three possible processing modes (note Reactive Streams terminology is used in the explanation):
- Full mode: Output buffer size not limited and
no data-driven execution (no context variable of type
Publisher
driving the template engine execution): In this case Thymeleaf will be executed unthrottled, computing the whole template in memory and sending all output to the output channels in a singleSubscriber.onNext(Object)
call, immediately followed bySubscriber.onComplete()
. - Chunked: Output buffers limited in size but no data-driven
execution (no
Publisher
driving engine execution). All context variables are expected to be fully resolved (in a non-blocking fashion) by WebFlux before engine execution and the Thymeleaf engine will execute in throttled mode, performing a full-stop each time the output buffer reaches the specified size, sending it to the output channels withSubscriber.onNext(Object)
and then waiting until these output channels make the engine resume its work with a newSubscription.request(long)
back-pressure call. - Data-Driven: one of the context variables is a reactive
Publisher
data stream wrapped inside an implementation of theIReactiveDataDriverContextVariable
interface. In this case, Thymeleaf will act as aSubscriber
of this data stream and aPublisher
of output buffers (the combination of which turns Thymeleaf into aProcessor
in Reactive Streams terminology). Thymeleaf will execute as a response toSubscriber.onNext(Object)
events triggered by this data-driverPublisher
. Thymeleaf will expect to find ath:each
iteration on the data-driven variable inside the processed template, and will be executed in throttled mode for the published elements, sending the resulting output buffers to the output channels viaSubscriber.onNext(Object)
and stopping until the data-driverPublisher
produces new data (normally after being requested to do so via back-pressure. When execution is data-driven, a limit in size can be optionally specified for the output buffers which will make Thymeleaf never send to the output channels a buffer bigger than that.
The SpringWebFluxTemplateEngine
implementation of this interface (or a subclass) should be used
in almost every case, but this interface improves testability of these artifacts.
- Since:
- 3.0.3
- Author:
- Daniel Fernández
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer>
processStream
(String template, Set<String> markupSelectors, IContext context, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.http.MediaType mediaType, Charset charset) org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer>
processStream
(String template, Set<String> markupSelectors, IContext context, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.http.MediaType mediaType, Charset charset, int responseMaxChunkSizeBytes) Methods inherited from interface org.thymeleaf.spring6.ISpringTemplateEngine
setTemplateEngineMessageSource
Methods inherited from interface org.thymeleaf.ITemplateEngine
getConfiguration, process, process, process, process, process, process, processThrottled, processThrottled, processThrottled
-
Method Details
-
processStream
-
processStream
org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer> processStream(String template, Set<String> markupSelectors, IContext context, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.http.MediaType mediaType, Charset charset, int responseMaxChunkSizeBytes)
-