Class 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 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 by ServerWebExchange.

        Note that implementations of IEngineContext are not meant to be used in order to call the template engine (use implementations of IContext such as Context or WebContext 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 another IContext 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 interface ISpringWebFluxContext
        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 interface ISpringWebFluxContext
        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 interface ISpringWebFluxContext
        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 interface ISpringWebFluxContext
        Returns:
        the servlet context object.
      • containsVariable

        public boolean containsVariable​(String name)
        Specified by:
        containsVariable in interface org.thymeleaf.context.IContext
      • getVariable

        public Object getVariable​(String key)
        Specified by:
        getVariable in interface org.thymeleaf.context.IContext
      • getVariableNames

        public Set<String> getVariableNames()
        Specified by:
        getVariableNames in interface org.thymeleaf.context.IContext
      • setVariable

        public void setVariable​(String name,
                                Object value)
        Specified by:
        setVariable in interface org.thymeleaf.context.IEngineContext
      • setVariables

        public void setVariables​(Map<String,​Object> variables)
        Specified by:
        setVariables in interface org.thymeleaf.context.IEngineContext
      • removeVariable

        public void removeVariable​(String name)
        Specified by:
        removeVariable in interface org.thymeleaf.context.IEngineContext
      • isVariableLocal

        public boolean isVariableLocal​(String name)
        Specified by:
        isVariableLocal in interface org.thymeleaf.context.IEngineContext
      • hasSelectionTarget

        public boolean hasSelectionTarget()
        Specified by:
        hasSelectionTarget in interface org.thymeleaf.context.ITemplateContext
      • getSelectionTarget

        public Object getSelectionTarget()
        Specified by:
        getSelectionTarget in interface org.thymeleaf.context.ITemplateContext
      • setSelectionTarget

        public void setSelectionTarget​(Object selectionTarget)
        Specified by:
        setSelectionTarget in interface org.thymeleaf.context.IEngineContext
      • getInliner

        public org.thymeleaf.inline.IInliner getInliner()
        Specified by:
        getInliner in interface org.thymeleaf.context.ITemplateContext
      • setInliner

        public void setInliner​(org.thymeleaf.inline.IInliner inliner)
        Specified by:
        setInliner in interface org.thymeleaf.context.IEngineContext
      • getTemplateData

        public org.thymeleaf.engine.TemplateData getTemplateData()
        Specified by:
        getTemplateData in interface org.thymeleaf.context.ITemplateContext
      • setTemplateData

        public void setTemplateData​(org.thymeleaf.engine.TemplateData templateData)
        Specified by:
        setTemplateData in interface org.thymeleaf.context.IEngineContext
      • getTemplateStack

        public List<org.thymeleaf.engine.TemplateData> getTemplateStack()
        Specified by:
        getTemplateStack in interface org.thymeleaf.context.ITemplateContext
      • setElementTag

        public void setElementTag​(org.thymeleaf.model.IProcessableElementTag elementTag)
        Specified by:
        setElementTag in interface org.thymeleaf.context.IEngineContext
      • getElementStack

        public List<org.thymeleaf.model.IProcessableElementTag> getElementStack()
        Specified by:
        getElementStack in interface org.thymeleaf.context.ITemplateContext
      • getElementStackAbove

        public List<org.thymeleaf.model.IProcessableElementTag> getElementStackAbove​(int contextLevel)
        Specified by:
        getElementStackAbove in interface org.thymeleaf.context.IEngineContext
      • level

        public int level()
        Specified by:
        level in interface org.thymeleaf.context.IEngineContext
      • increaseLevel

        public void increaseLevel()
        Specified by:
        increaseLevel in interface org.thymeleaf.context.IEngineContext
      • decreaseLevel

        public void decreaseLevel()
        Specified by:
        decreaseLevel in interface org.thymeleaf.context.IEngineContext
      • getStringRepresentationByLevel

        public String getStringRepresentationByLevel()