Class SpringWebFluxEngineContext
- Object
-
- org.thymeleaf.context.AbstractEngineContext
-
- org.thymeleaf.spring5.context.webflux.SpringWebFluxEngineContext
-
- All Implemented Interfaces:
org.thymeleaf.context.IContext
,org.thymeleaf.context.IEngineContext
,org.thymeleaf.context.IExpressionContext
,org.thymeleaf.context.ITemplateContext
,ISpringWebFluxContext
public class SpringWebFluxEngineContext extends org.thymeleaf.context.AbstractEngineContext implements org.thymeleaf.context.IEngineContext, ISpringWebFluxContext
Basic web implementation of the
IEngineContext
interface, based on the Spring WebFlux infrastructure.This is the context implementation that will be used by default for template processing in Spring WebFlux environments. Note that this is an internal implementation, and there is no reason for users' code to directly reference or use it instead of its implemented interfaces.
This class is NOT thread-safe. Thread-safety is not a requirement for context implementations.
- Since:
- 3.0.3
- Author:
- Daniel Fernández
-
-
Constructor Summary
Constructors Constructor Description SpringWebFluxEngineContext(org.thymeleaf.IEngineConfiguration configuration, org.thymeleaf.engine.TemplateData templateData, Map<String,Object> templateResolutionAttributes, org.springframework.web.server.ServerWebExchange exchange, Locale locale, Map<String,Object> variables)
Creates a new instance of thisIEngineContext
implementation binding engine execution to the Spring WebFlux request handling mechanisms, mainly modelled byServerWebExchange
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsVariable(String name)
void
decreaseLevel()
List<org.thymeleaf.model.IProcessableElementTag>
getElementStack()
List<org.thymeleaf.model.IProcessableElementTag>
getElementStackAbove(int contextLevel)
org.springframework.web.server.ServerWebExchange
getExchange()
Returns theServerWebExchange
object associated with the template execution.org.thymeleaf.inline.IInliner
getInliner()
org.springframework.http.server.reactive.ServerHttpRequest
getRequest()
Returns theServerHttpRequest
object associated with the template execution.org.springframework.http.server.reactive.ServerHttpResponse
getResponse()
Returns theServerHttpResponse
object associated with the template execution.Object
getSelectionTarget()
reactor.core.publisher.Mono<org.springframework.web.server.WebSession>
getSession()
Returns theWebSession
object associated with the template execution.String
getStringRepresentationByLevel()
org.thymeleaf.engine.TemplateData
getTemplateData()
List<org.thymeleaf.engine.TemplateData>
getTemplateStack()
Object
getVariable(String key)
Set<String>
getVariableNames()
boolean
hasSelectionTarget()
void
increaseLevel()
boolean
isVariableLocal(String name)
int
level()
void
removeVariable(String name)
void
setElementTag(org.thymeleaf.model.IProcessableElementTag elementTag)
void
setInliner(org.thymeleaf.inline.IInliner inliner)
void
setSelectionTarget(Object selectionTarget)
void
setTemplateData(org.thymeleaf.engine.TemplateData templateData)
void
setVariable(String name, Object value)
void
setVariables(Map<String,Object> variables)
String
toString()
-
Methods inherited from class org.thymeleaf.context.AbstractEngineContext
buildLink, getConfiguration, getExpressionObjects, getIdentifierSequences, getLocale, getMessage, getModelFactory, getTemplateMode, getTemplateResolutionAttributes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
SpringWebFluxEngineContext
public SpringWebFluxEngineContext(org.thymeleaf.IEngineConfiguration configuration, org.thymeleaf.engine.TemplateData templateData, Map<String,Object> templateResolutionAttributes, org.springframework.web.server.ServerWebExchange exchange, Locale locale, Map<String,Object> variables)
Creates a new instance of this
IEngineContext
implementation binding engine execution to the Spring WebFlux request handling mechanisms, mainly modelled byServerWebExchange
.Note that implementations of
IEngineContext
are not meant to be used in order to call the template engine (use implementations ofIContext
such asContext
orWebContext
instead). This is therefore mostly an internal implementation, and users should have no reason to ever call this constructor except in very specific integration/extension scenarios.- Parameters:
configuration
- the configuration instance being used.templateData
- the template data for the template to be processed.templateResolutionAttributes
- the template resolution attributes.exchange
- the web exchange object being used for request handling.locale
- the locale.variables
- the context variables, probably coming from anotherIContext
implementation.
-
-
Method Detail
-
getRequest
public org.springframework.http.server.reactive.ServerHttpRequest getRequest()
Description copied from interface:ISpringWebFluxContext
Returns the
ServerHttpRequest
object associated with the template execution.- Specified by:
getRequest
in interfaceISpringWebFluxContext
- Returns:
- the request object.
-
getResponse
public org.springframework.http.server.reactive.ServerHttpResponse getResponse()
Description copied from interface:ISpringWebFluxContext
Returns the
ServerHttpResponse
object associated with the template execution.- Specified by:
getResponse
in interfaceISpringWebFluxContext
- Returns:
- the response object.
-
getSession
public reactor.core.publisher.Mono<org.springframework.web.server.WebSession> getSession()
Description copied from interface:ISpringWebFluxContext
Returns the
WebSession
object associated with the template execution.The returned
Mono
will always return an instance, either matching the client's session id or a new session. Note that calling this method does not create the session object itself.- Specified by:
getSession
in interfaceISpringWebFluxContext
- Returns:
- the session object. Might be null if no session has been created.
-
getExchange
public org.springframework.web.server.ServerWebExchange getExchange()
Description copied from interface:ISpringWebFluxContext
Returns the
ServerWebExchange
object associated with the template execution.- Specified by:
getExchange
in interfaceISpringWebFluxContext
- Returns:
- the servlet context object.
-
containsVariable
public boolean containsVariable(String name)
- Specified by:
containsVariable
in interfaceorg.thymeleaf.context.IContext
-
getVariable
public Object getVariable(String key)
- Specified by:
getVariable
in interfaceorg.thymeleaf.context.IContext
-
getVariableNames
public Set<String> getVariableNames()
- Specified by:
getVariableNames
in interfaceorg.thymeleaf.context.IContext
-
setVariable
public void setVariable(String name, Object value)
- Specified by:
setVariable
in interfaceorg.thymeleaf.context.IEngineContext
-
setVariables
public void setVariables(Map<String,Object> variables)
- Specified by:
setVariables
in interfaceorg.thymeleaf.context.IEngineContext
-
removeVariable
public void removeVariable(String name)
- Specified by:
removeVariable
in interfaceorg.thymeleaf.context.IEngineContext
-
isVariableLocal
public boolean isVariableLocal(String name)
- Specified by:
isVariableLocal
in interfaceorg.thymeleaf.context.IEngineContext
-
hasSelectionTarget
public boolean hasSelectionTarget()
- Specified by:
hasSelectionTarget
in interfaceorg.thymeleaf.context.ITemplateContext
-
getSelectionTarget
public Object getSelectionTarget()
- Specified by:
getSelectionTarget
in interfaceorg.thymeleaf.context.ITemplateContext
-
setSelectionTarget
public void setSelectionTarget(Object selectionTarget)
- Specified by:
setSelectionTarget
in interfaceorg.thymeleaf.context.IEngineContext
-
getInliner
public org.thymeleaf.inline.IInliner getInliner()
- Specified by:
getInliner
in interfaceorg.thymeleaf.context.ITemplateContext
-
setInliner
public void setInliner(org.thymeleaf.inline.IInliner inliner)
- Specified by:
setInliner
in interfaceorg.thymeleaf.context.IEngineContext
-
getTemplateData
public org.thymeleaf.engine.TemplateData getTemplateData()
- Specified by:
getTemplateData
in interfaceorg.thymeleaf.context.ITemplateContext
-
setTemplateData
public void setTemplateData(org.thymeleaf.engine.TemplateData templateData)
- Specified by:
setTemplateData
in interfaceorg.thymeleaf.context.IEngineContext
-
getTemplateStack
public List<org.thymeleaf.engine.TemplateData> getTemplateStack()
- Specified by:
getTemplateStack
in interfaceorg.thymeleaf.context.ITemplateContext
-
setElementTag
public void setElementTag(org.thymeleaf.model.IProcessableElementTag elementTag)
- Specified by:
setElementTag
in interfaceorg.thymeleaf.context.IEngineContext
-
getElementStack
public List<org.thymeleaf.model.IProcessableElementTag> getElementStack()
- Specified by:
getElementStack
in interfaceorg.thymeleaf.context.ITemplateContext
-
getElementStackAbove
public List<org.thymeleaf.model.IProcessableElementTag> getElementStackAbove(int contextLevel)
- Specified by:
getElementStackAbove
in interfaceorg.thymeleaf.context.IEngineContext
-
level
public int level()
- Specified by:
level
in interfaceorg.thymeleaf.context.IEngineContext
-
increaseLevel
public void increaseLevel()
- Specified by:
increaseLevel
in interfaceorg.thymeleaf.context.IEngineContext
-
decreaseLevel
public void decreaseLevel()
- Specified by:
decreaseLevel
in interfaceorg.thymeleaf.context.IEngineContext
-
getStringRepresentationByLevel
public String getStringRepresentationByLevel()
-
-