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

org.jboss.pnc.environmentdriver.BeanFactory Maven / Gradle / Ivy

Go to download

Environment driver provides REST endpoints to create and destroy Openshift objects

There is a newer version: 3.0.0
Show newest version
package org.jboss.pnc.environmentdriver;

import java.net.http.HttpClient;
import java.security.NoSuchAlgorithmException;
import java.time.Duration;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.net.ssl.SSLContext;

import org.eclipse.microprofile.context.ManagedExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Matej Lazar
 */
@ApplicationScoped
public class BeanFactory {

    public static final Logger userLogger = LoggerFactory.getLogger("org.jboss.pnc._userlog_.envdriver");

    @Inject
    Configuration configuration;

    @Inject
    ManagedExecutor executor;

    private HttpClient httpClient;

    @PostConstruct
    void init() throws NoSuchAlgorithmException {
        httpClient = java.net.http.HttpClient.newBuilder()
                .sslContext(SSLContext.getDefault())
                .executor(executor)
                .connectTimeout(Duration.ofSeconds(configuration.getHttpClientConnectTimeout()))
                .build();
    }

    @UserLogger
    @Produces
    @ApplicationScoped
    public Logger getUserLogger() {
        return userLogger;
    }

    @Produces
    @ApplicationScoped
    public HttpClient getHttpClient() {
        return httpClient;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy