public final class ThrottledTemplateProcessor extends Object implements IThrottledTemplateProcessor
Standard implementation of IThrottledTemplateProcessor
.
This class is for internal use only. There is usually no reason why user's code should directly reference it.
Modifier and Type | Method and Description |
---|---|
String |
getProcessorIdentifier()
Returns an identifier for this processor that should enable the tracing of its executions.
|
TemplateSpec |
getTemplateSpec()
Return the
TemplateSpec this throttled template processor object is acting on. |
IThrottledTemplateWriterControl |
getThrottledTemplateWriterControl() |
boolean |
isFinished()
Checks whether the processing of the template has already finished.
|
int |
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.
|
int |
process(int maxOutputInChars,
Writer writer)
Process the template until at most the specified amount of chars has been written to output, then return control.
|
int |
processAll(OutputStream outputStream,
Charset charset)
Process the whole template (all parts remaining), with no limit in the amount of bytes written to output.
|
int |
processAll(Writer writer)
Process the whole template (all parts remaining), with no limit in the amount of chars written to output.
|
public IThrottledTemplateWriterControl getThrottledTemplateWriterControl()
public boolean isFinished()
IThrottledTemplateProcessor
Checks whether the processing of the template has already finished.
NOTE Implementations of this method must be thread-safe as, even if executions of the throttled processor (calls to process(...) methods) should never happen concurrently, determining whether a throttled processor has finished or not can happen concurrently from different threads as a way of short-cutting the execution of the processor (and avoid excessive consumption of upstream data, for example).
isFinished
in interface IThrottledTemplateProcessor
public String getProcessorIdentifier()
IThrottledTemplateProcessor
Returns an identifier for this processor that should enable the tracing of its executions.
Given throttled processors are often used in reactive environments, in which different executions of a throttled processor might be performed by different threads (in a non-interleaved manner), this identifier should help identifying at the log trace the specific processor being executed independently of the thread ID.
Though it is not completely required that the identifier returned by this method is unique by construction, it should be unique enough to be of practical use as an identifier.
getProcessorIdentifier
in interface IThrottledTemplateProcessor
public TemplateSpec getTemplateSpec()
IThrottledTemplateProcessor
Return the TemplateSpec
this throttled template processor object is acting on.
getTemplateSpec
in interface IThrottledTemplateProcessor
public int processAll(Writer writer)
IThrottledTemplateProcessor
Process the whole template (all parts remaining), with no limit in the amount of chars written to output.
processAll
in interface IThrottledTemplateProcessor
writer
- the writer output should be written to.public int processAll(OutputStream outputStream, Charset charset)
IThrottledTemplateProcessor
Process the whole template (all parts remaining), with no limit in the amount of bytes written to output.
processAll
in interface IThrottledTemplateProcessor
outputStream
- the output stream output should be written to.charset
- the charset to be used for encoding the written output into bytes.public int process(int maxOutputInChars, Writer writer)
IThrottledTemplateProcessor
Process the template until at most the specified amount of chars has been written to output, then return control.
process
in interface IThrottledTemplateProcessor
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.public int process(int maxOutputInBytes, OutputStream outputStream, Charset charset)
IThrottledTemplateProcessor
Process the template until at most the specified amount of bytes has been written to output, then return control.
process
in interface IThrottledTemplateProcessor
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 © 2017 The THYMELEAF team. All rights reserved.