Interface IEngineContextFactory
-
- All Known Implementing Classes:
StandardEngineContextFactory
public interface IEngineContextFactory
Common interface for all factory instances in charge of creating the
IEngineContext
implementations that will be used during template execution.Engine Contexts (implementations of
IEngineContext
) are the type of context really used by the engine during template processing. These factories will be called in order to createIEngineContext
instances from the originalIContext
implementations (the much simplercontext
objects that were used for calling the template engine).The specific implementation of this interface to be used for template processing can be obtained and set at
TemplateEngine
instances by means of itsTemplateEngine.getEngineContextFactory()
andTemplateEngine.setEngineContextFactory(IEngineContextFactory)
methods.Implementations of this interface should be thread-safe.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
- See Also:
StandardEngineContextFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IEngineContext
createEngineContext(IEngineConfiguration configuration, TemplateData templateData, Map<String,Object> templateResolutionAttributes, IContext context)
Creates a newIEngineContext
to be used for processing a specific template.
-
-
-
Method Detail
-
createEngineContext
IEngineContext createEngineContext(IEngineConfiguration configuration, TemplateData templateData, Map<String,Object> templateResolutionAttributes, IContext context)
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 anITemplateEngine
.process(...)
argument). Anyth:insert
orth: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 (seeIEngineContext.increaseLevel()
) and set the new, nested template data for that level (seeIEngineContext.setTemplateData(TemplateData)
).Note also that the
context
object passed here as an argument will normally correspond to the simpleIContext
implementation used for callingITemplateEngine
.process(...)
and, therefore, will normally be an object of classEngineContext
,WebContext
or similar.- Parameters:
configuration
- the engine configuration being used.templateData
- theTemplateData
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.- Returns:
- a new, freshly built engine context instance.
-
-