Class SpringWebFluxContext
- Object
-
- org.thymeleaf.context.AbstractContext
-
- org.thymeleaf.spring5.context.webflux.SpringWebFluxContext
-
- All Implemented Interfaces:
org.thymeleaf.context.IContext
,ISpringWebFluxContext
- Direct Known Subclasses:
SpringWebFluxExpressionContext
public class SpringWebFluxContext extends org.thymeleaf.context.AbstractContext implements ISpringWebFluxContext
Basic Spring WebFlux-oriented implementation of the
ISpringWebFluxContext
interfaces, easily usable as a context for calling theISpringWebFluxTemplateEngine
from outside aThymeleafReactiveView
.This class is not thread-safe, and should not be shared across executions of templates.
- Since:
- 3.0.8
- Author:
- Daniel Fernández
-
-
Constructor Summary
Constructors Constructor Description SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange)
Build a new instance of this Spring WebFlux-specific context object.SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange, Locale locale)
Build a new instance of this Spring WebFlux-specific context object.SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange, Locale locale, Map<String,Object> variables)
Build a new instance of this Spring WebFlux-specific context object.SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange, org.springframework.core.ReactiveAdapterRegistry reactiveAdapterRegistry, Locale locale, Map<String,Object> variables)
Build a new instance of this Spring WebFlux-specific context object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.web.server.ServerWebExchange
getExchange()
Returns theServerWebExchange
object associated with the template execution.org.springframework.core.ReactiveAdapterRegistry
getReactiveAdapterRegistry()
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.reactor.core.publisher.Mono<org.springframework.web.server.WebSession>
getSession()
Returns theWebSession
object associated with the template execution.-
Methods inherited from class org.thymeleaf.context.AbstractContext
clearVariables, containsVariable, getLocale, getVariable, getVariableNames, removeVariable, setLocale, setVariable, setVariables
-
-
-
-
Constructor Detail
-
SpringWebFluxContext
public SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange)
Build a new instance of this Spring WebFlux-specific context object.
- Parameters:
exchange
- the Spring WebFlux exchange object, containing request, response and session. Cannot be null.
-
SpringWebFluxContext
public SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange, Locale locale)
Build a new instance of this Spring WebFlux-specific context object.
- Parameters:
exchange
- the Spring WebFlux exchange object, containing request, response and session. Cannot be null.locale
- the locale to be used for executing Thymeleaf. Can be null (Locale.getDefault() will be used).
-
SpringWebFluxContext
public SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange, Locale locale, Map<String,Object> variables)
Build a new instance of this Spring WebFlux-specific context object.
- Parameters:
exchange
- the Spring WebFlux exchange object, containing request, response and session. Cannot be null.locale
- the locale to be used for executing Thymeleaf. Can be null (Locale.getDefault() will be used).variables
- the variables to be used for executing Thymeleaf. Can be null.
-
SpringWebFluxContext
public SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange, org.springframework.core.ReactiveAdapterRegistry reactiveAdapterRegistry, Locale locale, Map<String,Object> variables)
Build a new instance of this Spring WebFlux-specific context object.
- Parameters:
exchange
- the Spring WebFlux exchange object, containing request, response and session. Cannot be null.reactiveAdapterRegistry
- the Spring WebFlux reactive adapter object, used in cases when it is needed to turn non-Reactor reactive streams (RxJava, etc.) into Reactor equivalents (Flux, Mono) in order to be used by Thymeleaf as data drivers (seeIReactiveDataDriverContextVariable
). Can be null.locale
- the locale to be used for executing Thymeleaf. Can be null (Locale.getDefault() will be used).variables
- the variables to be used for executing Thymeleaf. Can be null.
-
-
Method Detail
-
getReactiveAdapterRegistry
public org.springframework.core.ReactiveAdapterRegistry getReactiveAdapterRegistry()
-
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.
-
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.
-
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.
-
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.
-
-