public final class StandardEngineContextFactory extends Object implements IEngineContextFactory
Standard implementation of the IEngineContextFactory
interface.
This factory will examine the context being passed as a parameter and, depending on whether
this context object implements the IWebContext
interface or not (i.e. whether support for the
Servlet API should be enabled or not), return a WebEngineContext
or an EngineContext
instance as a result.
This is the default factory implementation used by TemplateEngine
.
Constructor and Description |
---|
StandardEngineContextFactory() |
Modifier and Type | Method and Description |
---|---|
IEngineContext |
createEngineContext(IEngineConfiguration configuration,
TemplateData templateData,
Map<String,Object> templateResolutionAttributes,
IContext context)
Creates a new
IEngineContext to be used for processing a specific template. |
public IEngineContext createEngineContext(IEngineConfiguration configuration, TemplateData templateData, Map<String,Object> templateResolutionAttributes, IContext context)
IEngineContextFactory
Creates a new IEngineContext
to be used for processing a specific template.
Note this factory method will be only called once during the processing of a template. Once a engine context
instance has been created, the engine will try to reuse it for any nested processing operations as far as
possible. This means that, e.g., the templateData specified here will only be the root-level
template data (the one for the template that is actually being used as an
ITemplateEngine
.process(...) argument). Any th:insert or
th:replace operations inside that template will not ask this factory to create a new engine context,
but instead just increase the nesting level of the already-existing one
(see IEngineContext.increaseLevel()
) and set the new, nested template data for that level
(see IEngineContext.setTemplateData(TemplateData)
).
Note also that the context object passed here as an argument will normally correspond to the
simple IContext
implementation used for calling
ITemplateEngine
.process(...) and, therefore, will normally be an object
of class EngineContext
, WebContext
or similar.
createEngineContext
in interface IEngineContextFactory
configuration
- the engine configuration being used.templateData
- the TemplateData
to be applied at level 0, i.e. the top-level template being processed.templateResolutionAttributes
- the template resolution attributes specified for processing this template.context
- the context, normally the one used for calling the Template Engine itself.Copyright © 2016 The THYMELEAF team. All rights reserved.