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

com.firefly.reactive.adapter.http.ReactiveHTTPsClientSingleton Maven / Gradle / Ivy

There is a newer version: 5.0.0-dev6
Show newest version
package com.firefly.reactive.adapter.http;

import com.firefly.client.http2.SimpleHTTPClientConfiguration;
import com.firefly.utils.lang.AbstractLifeCycle;

/**
 * @author Pengtao Qiu
 */
public class ReactiveHTTPsClientSingleton extends AbstractLifeCycle {
    private static ReactiveHTTPsClientSingleton ourInstance = new ReactiveHTTPsClientSingleton();

    public static ReactiveHTTPsClientSingleton getInstance() {
        return ourInstance;
    }

    private ReactiveHTTPClient httpClient;

    private ReactiveHTTPsClientSingleton() {
        start();
    }

    public ReactiveHTTPClient httpsClient() {
        return httpClient;
    }

    @Override
    protected void init() {
        SimpleHTTPClientConfiguration configuration = new SimpleHTTPClientConfiguration();
        configuration.setSecureConnectionEnabled(true);
        httpClient = new ReactiveHTTPClient(configuration);
    }

    @Override
    protected void destroy() {
        if (httpClient != null) {
            httpClient.stop();
            httpClient = null;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy