public interface IThrottledTemplateProcessor
Interface defining operations that can regulate the pace at which the template engine will process a
template (a.k.a. engine throttling). Objects implementing this interface are returned by
the processThrottled(...) methods at ITemplateEngine
.
When the processing of a template is throttled the client classes can tell the engine how much output
they are prepared to handle by calling any of the process(int,...) methods. As a response to this,
the engine will process only the part of the template enough to write at most so many chars
or bytes as specified at the processThrottled(...) call. Output will be written to a Writer
in the form of chars, or to an OutputStream
in the form of bytes.
Once the desired amount of output has been written, the engine stops where it is with minimum or no pending output caching, and returns control to the caller, so that the client can process output and prepare for a subsequent call. Note that this whole process is single-threaded.
Among other scenarios, this should allow Thymeleaf to be efficiently integrated as a back-pressure-driven cold observable in a reactive architecture.
Modifier and Type | Method and Description |
---|---|
boolean |
isFinished()
Checks whether the processing of the template has already finished.
|
void |
process(int maxOutputInBytes,
OutputStream outputStream,
Charset charset)
Process the template until at most the specified amount of bytes has been written to output, then return control.
|
void |
process(int maxOutputInChars,
Writer writer)
Process the template until at most the specified amount of chars has been written to output, then return control.
|
void |
processAll(OutputStream outputStream,
Charset charset)
Process the whole template (all parts remaining), with no limit in the amount of bytes written to output.
|
void |
processAll(Writer writer)
Process the whole template (all parts remaining), with no limit in the amount of chars written to output.
|
boolean isFinished()
Checks whether the processing of the template has already finished.
void processAll(Writer writer)
Process the whole template (all parts remaining), with no limit in the amount of chars written to output.
writer
- the writer output should be written to.void processAll(OutputStream outputStream, Charset charset)
Process the whole template (all parts remaining), with no limit in the amount of bytes written to output.
outputStream
- the output stream output should be written to.charset
- the charset to be used for encoding the written output into bytes.void process(int maxOutputInChars, Writer writer)
Process the template until at most the specified amount of chars has been written to output, then return control.
maxOutputInChars
- the maximum amount of chars that the engine is allowed to output. A number < 0 or
Integer.MAX_VALUE
will mean "no limit".writer
- the writer output should be written to.void process(int maxOutputInBytes, OutputStream outputStream, Charset charset)
Process the template until at most the specified amount of bytes has been written to output, then return control.
maxOutputInBytes
- the maximum amount of bytes that the engine is allowed to output. A number < 0 or
Integer.MAX_VALUE
will mean "no limit".outputStream
- the output stream output should be written to.charset
- the charset to be used for encoding the written output into bytes.Copyright © 2016 The THYMELEAF team. All rights reserved.