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
ISpringWebFluxContextinterfaces, easily usable as a context for calling theISpringWebFluxTemplateEnginefrom 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.ServerWebExchangegetExchange()Returns theServerWebExchangeobject associated with the template execution.org.springframework.core.ReactiveAdapterRegistrygetReactiveAdapterRegistry()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.reactor.core.publisher.Mono<org.springframework.web.server.WebSession>getSession()Returns theWebSessionobject 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:ISpringWebFluxContextReturns the
ServerHttpRequestobject associated with the template execution.- Specified by:
getRequestin interfaceISpringWebFluxContext- Returns:
- the request 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.
-
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.
-
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.
-
-