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 the ISpringWebFluxTemplateEngine
from outside a ThymeleafReactiveView
.
This class is not thread-safe, and should not be shared across executions of templates.
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
org.springframework.web.server.ServerWebExchange |
getExchange()
Returns the
ServerWebExchange object associated with the template execution. |
org.springframework.core.ReactiveAdapterRegistry |
getReactiveAdapterRegistry() |
org.springframework.http.server.reactive.ServerHttpRequest |
getRequest()
Returns the
ServerHttpRequest object associated with the template execution. |
org.springframework.http.server.reactive.ServerHttpResponse |
getResponse()
Returns the
ServerHttpResponse object associated with the template execution. |
reactor.core.publisher.Mono<org.springframework.web.server.WebSession> |
getSession()
Returns the
WebSession object associated with the template execution. |
clearVariables, containsVariable, getLocale, getVariable, getVariableNames, removeVariable, setLocale, setVariable, setVariables
public SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange)
Build a new instance of this Spring WebFlux-specific context object.
exchange
- the Spring WebFlux exchange object, containing request, response and session. Cannot be null.public SpringWebFluxContext(org.springframework.web.server.ServerWebExchange exchange, Locale locale)
Build a new instance of this Spring WebFlux-specific context object.
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).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.
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.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.
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
(see IReactiveDataDriverContextVariable
). 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.public org.springframework.core.ReactiveAdapterRegistry getReactiveAdapterRegistry()
public org.springframework.http.server.reactive.ServerHttpRequest getRequest()
ISpringWebFluxContext
Returns the ServerHttpRequest
object associated with the template execution.
getRequest
in interface ISpringWebFluxContext
public reactor.core.publisher.Mono<org.springframework.web.server.WebSession> getSession()
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.
getSession
in interface ISpringWebFluxContext
public org.springframework.http.server.reactive.ServerHttpResponse getResponse()
ISpringWebFluxContext
Returns the ServerHttpResponse
object associated with the template execution.
getResponse
in interface ISpringWebFluxContext
public org.springframework.web.server.ServerWebExchange getExchange()
ISpringWebFluxContext
Returns the ServerWebExchange
object associated with the template execution.
getExchange
in interface ISpringWebFluxContext
Copyright © 2017 The THYMELEAF team. All rights reserved.