org.thymeleaf.spring5.context.webflux.ReactiveContextVariableUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of thymeleaf-spring5 Show documentation
Show all versions of thymeleaf-spring5 Show documentation
Modern server-side Java template engine for both web and standalone environments
/*
* =============================================================================
*
* Copyright (c) 2011-2018, The THYMELEAF team (http://www.thymeleaf.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
package org.thymeleaf.spring5.context.webflux;
import org.reactivestreams.Publisher;
import org.springframework.core.ReactiveAdapter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.thymeleaf.spring5.view.reactive.ThymeleafReactiveView;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
*
* Utility class used by reactive context variable container/wrappers.
*
*
* @author Daniel Fernández
*
* @since 3.0.3
*
*/
class ReactiveContextVariableUtils {
/**
*
* Lazily resolve the reactive asynchronous object into a {@link Publisher}.
*
*
* The main aim of this method is to mirror the mechanism used by Spring for resolving
* asynchronous variables at the model of views (see Spring's
* {@link org.springframework.web.reactive.result.view.ViewResolutionResultHandler}):
*
*
* - {@code Flux
} or other multi-valued streams are resolved as
* {@code List} so that they are iterable.
* - {@code Mono
} or other single-valued streams are resolved as
* {@code T} so that they are directly referenceable just like any other object.
*
*
* @param asyncObj the asynchronous object being wrapped by this lazy variable.
* @param reactiveAdapterRegistry the Spring {@link ReactiveAdapterRegistry}.
* @return the resolved {@link Publisher}.
*/
static Publisher
© 2015 - 2024 Weber Informatics LLC | Privacy Policy