All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.reactor.MonoProvider Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha4
Show newest version
package org.jboss.resteasy.reactor;

import java.util.concurrent.CompletionStage;
import java.util.function.Supplier;

import jakarta.ws.rs.ext.Provider;

import org.jboss.resteasy.spi.AsyncClientResponseProvider;
import org.jboss.resteasy.spi.AsyncResponseProvider;

import reactor.core.publisher.Mono;

@Provider
public class MonoProvider implements AsyncResponseProvider>, AsyncClientResponseProvider> {

    @Override
    public CompletionStage toCompletionStage(final Mono asyncResponse) {
        return asyncResponse.toFuture();
    }

    @Override
    public Mono fromCompletionStage(final CompletionStage completionStage) {
        return Mono.fromFuture(completionStage.toCompletableFuture());
    }

    @Override
    public Mono fromCompletionStage(final Supplier> completionStageSupplier) {
        return Mono.fromFuture(() -> completionStageSupplier.get().toCompletableFuture());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy