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

io.femo.http.drivers.AsynchronousDriver Maven / Gradle / Ivy

Go to download

An easy to use HTTP API, that supports synchronous and asynchronous execution of HTTP request. On android only asynchronous driver is supported. This library has been backported to jdk 7 to retain compatibility with android!

The newest version!
package io.femo.http.drivers;

import io.femo.http.HttpDriver;
import io.femo.http.HttpRequest;

import java.net.URL;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by felix on 2/9/16.
 */
public class AsynchronousDriver extends DefaultDriver {

    private ExecutorService executorService;

    public AsynchronousDriver() {
        executorService = null;
    }

    public AsynchronousDriver(int threads) {
        this.executorService = Executors.newFixedThreadPool(threads);
    }

    @Override
    public HttpRequest url(URL url) {
        if(executorService == null)
            return new AsynchronousHttpRequest(url);
        return new AsynchronousExecutorHttpRequest(url, executorService);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy