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

com.cloudconvert.executor.AsyncRequestExecutor Maven / Gradle / Ivy

Go to download

CloudConvert is an online file converter API - more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats supported.

There is a newer version: 1.2.1
Show newest version
package com.cloudconvert.executor;

import com.cloudconvert.client.http.AsyncCloseableHttpClientProvider;
import com.cloudconvert.dto.result.AsyncResult;
import com.cloudconvert.dto.result.FutureAsyncResult;
import com.cloudconvert.extractor.ResultExtractor;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.concurrent.Future;

public class AsyncRequestExecutor extends AbstractRequestExecutor {

    public AsyncRequestExecutor(
        final ResultExtractor resultExtractor,
        final AsyncCloseableHttpClientProvider asyncCloseableHttpClientProvider
    ) throws IOException {
        this(resultExtractor, asyncCloseableHttpClientProvider, null);
    }

    public AsyncRequestExecutor(
        final ResultExtractor resultExtractor,
        final AsyncCloseableHttpClientProvider asyncCloseableHttpClientProvider,
        @Nullable final FutureCallback httpResponseFutureCallback
    ) throws IOException {
        super(resultExtractor, asyncCloseableHttpClientProvider);
    }

    public  AsyncResult execute(@NotNull final HttpUriRequest httpUriRequest, @NotNull final TypeReference typeReference) throws IOException {
        final Future httpResponseFuture = getCloseableHttpClient().execute(httpUriRequest, null);

        return FutureAsyncResult.builder().resultExtractor(getResultExtractor()).future(httpResponseFuture).typeReference(typeReference).build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy