Interface ISpringWebFluxTemplateEngine

  • All Superinterfaces:
    ISpringTemplateEngine, org.thymeleaf.ITemplateEngine
    All Known Implementing Classes:
    SpringWebFluxTemplateEngine

    public interface ISpringWebFluxTemplateEngine
    extends ISpringTemplateEngine

    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):

    1. 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 single Subscriber.onNext(Object) call, immediately followed by Subscriber.onComplete().
    2. 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 with Subscriber.onNext(Object) and then waiting until these output channels make the engine resume its work with a new Subscription.request(long) back-pressure call.
    3. Data-Driven: one of the context variables is a reactive Publisher data stream wrapped inside an implementation of the IReactiveDataDriverContextVariable interface. In this case, Thymeleaf will act as a Subscriber of this data stream and a Publisher of output buffers (the combination of which turns Thymeleaf into a Processor in Reactive Streams terminology). Thymeleaf will execute as a response to Subscriber.onNext(Object) events triggered by this data-driver Publisher. Thymeleaf will expect to find a th: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 via Subscriber.onNext(Object) and stopping until the data-driver Publisher 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:
    SpringWebFluxTemplateEngine
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer> processStream​(String template, Set<String> markupSelectors, org.thymeleaf.context.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, org.thymeleaf.context.IContext context, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.http.MediaType mediaType, Charset charset, int responseMaxChunkSizeBytes)  
      • Methods inherited from interface org.thymeleaf.ITemplateEngine

        getConfiguration, process, process, process, process, process, process, processThrottled, processThrottled, processThrottled
    • Method Detail

      • processStream

        org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer> processStream​(String template,
                                                                                                   Set<String> markupSelectors,
                                                                                                   org.thymeleaf.context.IContext context,
                                                                                                   org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
                                                                                                   org.springframework.http.MediaType mediaType,
                                                                                                   Charset charset)
      • processStream

        org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer> processStream​(String template,
                                                                                                   Set<String> markupSelectors,
                                                                                                   org.thymeleaf.context.IContext context,
                                                                                                   org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
                                                                                                   org.springframework.http.MediaType mediaType,
                                                                                                   Charset charset,
                                                                                                   int responseMaxChunkSizeBytes)