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
IEngineContextinterface, 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 thisIEngineContextimplementation 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 booleancontainsVariable(String name)voiddecreaseLevel()List<org.thymeleaf.model.IProcessableElementTag>getElementStack()List<org.thymeleaf.model.IProcessableElementTag>getElementStackAbove(int contextLevel)org.springframework.web.server.ServerWebExchangegetExchange()Returns theServerWebExchangeobject associated with the template execution.org.thymeleaf.inline.IInlinergetInliner()org.springframework.http.server.reactive.ServerHttpRequestgetRequest()Returns theServerHttpRequestobject associated with the template execution.org.springframework.http.server.reactive.ServerHttpResponsegetResponse()Returns theServerHttpResponseobject associated with the template execution.ObjectgetSelectionTarget()reactor.core.publisher.Mono<org.springframework.web.server.WebSession>getSession()Returns theWebSessionobject associated with the template execution.StringgetStringRepresentationByLevel()org.thymeleaf.engine.TemplateDatagetTemplateData()List<org.thymeleaf.engine.TemplateData>getTemplateStack()ObjectgetVariable(String key)Set<String>getVariableNames()booleanhasSelectionTarget()voidincreaseLevel()booleanisVariableLocal(String name)intlevel()voidremoveVariable(String name)voidsetElementTag(org.thymeleaf.model.IProcessableElementTag elementTag)voidsetInliner(org.thymeleaf.inline.IInliner inliner)voidsetSelectionTarget(Object selectionTarget)voidsetTemplateData(org.thymeleaf.engine.TemplateData templateData)voidsetVariable(String name, Object value)voidsetVariables(Map<String,Object> variables)StringtoString()-
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
IEngineContextimplementation binding engine execution to the Spring WebFlux request handling mechanisms, mainly modelled byServerWebExchange.Note that implementations of
IEngineContextare not meant to be used in order to call the template engine (use implementations ofIContextsuch asContextorWebContextinstead). 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 anotherIContextimplementation.
-
-
Method Detail
-
getRequest
public org.springframework.http.server.reactive.ServerHttpRequest getRequest()
Description copied from interface:ISpringWebFluxContextReturns the
ServerHttpRequestobject associated with the template execution.- Specified by:
getRequestin interfaceISpringWebFluxContext- Returns:
- the request object.
-
getResponse
public org.springframework.http.server.reactive.ServerHttpResponse getResponse()
Description copied from interface:ISpringWebFluxContextReturns the
ServerHttpResponseobject associated with the template execution.- Specified by:
getResponsein interfaceISpringWebFluxContext- Returns:
- the response object.
-
getSession
public reactor.core.publisher.Mono<org.springframework.web.server.WebSession> getSession()
Description copied from interface:ISpringWebFluxContextReturns the
WebSessionobject associated with the template execution.The returned
Monowill 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:
getSessionin 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:ISpringWebFluxContextReturns the
ServerWebExchangeobject associated with the template execution.- Specified by:
getExchangein interfaceISpringWebFluxContext- Returns:
- the servlet context object.
-
containsVariable
public boolean containsVariable(String name)
- Specified by:
containsVariablein interfaceorg.thymeleaf.context.IContext
-
getVariable
public Object getVariable(String key)
- Specified by:
getVariablein interfaceorg.thymeleaf.context.IContext
-
getVariableNames
public Set<String> getVariableNames()
- Specified by:
getVariableNamesin interfaceorg.thymeleaf.context.IContext
-
setVariable
public void setVariable(String name, Object value)
- Specified by:
setVariablein interfaceorg.thymeleaf.context.IEngineContext
-
setVariables
public void setVariables(Map<String,Object> variables)
- Specified by:
setVariablesin interfaceorg.thymeleaf.context.IEngineContext
-
removeVariable
public void removeVariable(String name)
- Specified by:
removeVariablein interfaceorg.thymeleaf.context.IEngineContext
-
isVariableLocal
public boolean isVariableLocal(String name)
- Specified by:
isVariableLocalin interfaceorg.thymeleaf.context.IEngineContext
-
hasSelectionTarget
public boolean hasSelectionTarget()
- Specified by:
hasSelectionTargetin interfaceorg.thymeleaf.context.ITemplateContext
-
getSelectionTarget
public Object getSelectionTarget()
- Specified by:
getSelectionTargetin interfaceorg.thymeleaf.context.ITemplateContext
-
setSelectionTarget
public void setSelectionTarget(Object selectionTarget)
- Specified by:
setSelectionTargetin interfaceorg.thymeleaf.context.IEngineContext
-
getInliner
public org.thymeleaf.inline.IInliner getInliner()
- Specified by:
getInlinerin interfaceorg.thymeleaf.context.ITemplateContext
-
setInliner
public void setInliner(org.thymeleaf.inline.IInliner inliner)
- Specified by:
setInlinerin interfaceorg.thymeleaf.context.IEngineContext
-
getTemplateData
public org.thymeleaf.engine.TemplateData getTemplateData()
- Specified by:
getTemplateDatain interfaceorg.thymeleaf.context.ITemplateContext
-
setTemplateData
public void setTemplateData(org.thymeleaf.engine.TemplateData templateData)
- Specified by:
setTemplateDatain interfaceorg.thymeleaf.context.IEngineContext
-
getTemplateStack
public List<org.thymeleaf.engine.TemplateData> getTemplateStack()
- Specified by:
getTemplateStackin interfaceorg.thymeleaf.context.ITemplateContext
-
setElementTag
public void setElementTag(org.thymeleaf.model.IProcessableElementTag elementTag)
- Specified by:
setElementTagin interfaceorg.thymeleaf.context.IEngineContext
-
getElementStack
public List<org.thymeleaf.model.IProcessableElementTag> getElementStack()
- Specified by:
getElementStackin interfaceorg.thymeleaf.context.ITemplateContext
-
getElementStackAbove
public List<org.thymeleaf.model.IProcessableElementTag> getElementStackAbove(int contextLevel)
- Specified by:
getElementStackAbovein interfaceorg.thymeleaf.context.IEngineContext
-
level
public int level()
- Specified by:
levelin interfaceorg.thymeleaf.context.IEngineContext
-
increaseLevel
public void increaseLevel()
- Specified by:
increaseLevelin interfaceorg.thymeleaf.context.IEngineContext
-
decreaseLevel
public void decreaseLevel()
- Specified by:
decreaseLevelin interfaceorg.thymeleaf.context.IEngineContext
-
getStringRepresentationByLevel
public String getStringRepresentationByLevel()
-
-