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

org.jboss.resteasy.client.jaxrs.engines.AsyncClientHttpEngine Maven / Gradle / Ivy

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

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;

import jakarta.ws.rs.client.InvocationCallback;

import org.jboss.resteasy.client.jaxrs.ClientHttpEngine;
import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation;
import org.jboss.resteasy.client.jaxrs.internal.ClientResponse;

/**
 * Interface for an async HttpClientEngine
 *
 * @author Markus Kull
 */
public interface AsyncClientHttpEngine extends ClientHttpEngine {

    /**
     * Interface for extracting a result out of a ClientResponse
     *
     * @param  Result-Type
     */
    interface ResultExtractor {
        /**
         * Extracts a result out of a Response
         *
         * @param response Response
         * @return result
         */
        T extractResult(ClientResponse response);
    }

    /**
     * Submits an asynchronous request.
     *
     * @param        type
     * @param request   Request
     * @param buffered  buffer the response?
     * @param callback  Optional callback receiving the result, which is run inside the io-thread. may be null.
     * @param extractor ResultExtractor for extracting a result out of a ClientResponse. Is run inside the io-thread
     * @return Future with the result or Exception
     */
     Future submit(ClientInvocation request, boolean buffered, InvocationCallback callback,
            ResultExtractor extractor);

    /**
     * Submits an asynchronous request.
     *
     * @param        type
     * @param request   Request
     * @param buffered  buffer the response?
     * @param extractor ResultExtractor for extracting a result out of a ClientResponse. Is run inside the io-thread
     * @return {@link CompletableFuture} with the result or Exception
     */
    default  CompletableFuture submit(ClientInvocation request, boolean buffered, ResultExtractor extractor) {
        return submit(request, buffered, extractor, null);
    }

    /**
     * Submits an asynchronous request.
     *
     * @param              type
     * @param request         Request
     * @param buffered        buffer the response?
     * @param extractor       ResultExtractor for extracting a result out of a ClientResponse. Is run inside the io-thread
     * @param executorService the executor to use for asynchronous execution
     * @return {@link CompletableFuture} with the result or Exception
     */
     CompletableFuture submit(ClientInvocation request, boolean buffered, ResultExtractor extractor,
            ExecutorService executorService);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy