/**
 * JBoss, Home of Professional Open Source.
 * Copyright 2014-2020 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.pnc.termdbuilddriver;

import org.jboss.pnc.buildagent.api.ResponseMode;
import org.jboss.pnc.buildagent.api.TaskStatusUpdateEvent;
import org.jboss.pnc.buildagent.client.BuildAgentClient;
import org.jboss.pnc.buildagent.client.BuildAgentClientException;
import org.jboss.pnc.buildagent.client.BuildAgentSocketClient;
import org.jboss.pnc.buildagent.client.SocketClientConfiguration;
import org.jboss.pnc.buildagent.common.http.HttpClient;
import org.jboss.pnc.common.json.moduleconfig.TermdBuildDriverModuleConfig;
import org.jboss.pnc.termdbuilddriver.transfer.DefaultFileTranser;
import org.jboss.pnc.termdbuilddriver.transfer.FileTranser;

import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import java.io.IOException;
import java.net.URI;
import java.util.Optional;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;

/**
 * @author <a href="mailto:matejonnet@gmail.com">Matej Lazar</a>
 */
@ApplicationScoped
public class DefaultClientFactory implements ClientFactory {

    /**
     * Connect timeout in millis. See {@link java.net.URLConnection#setConnectTimeout(int)}
     */
    private final Optional<Integer> fileTransferConnectTimeout;

    /**
     * Connect timeout in millis. See {@link java.net.URLConnection#setReadTimeout(int)}
     */
    private final Optional<Integer> fileTransferReadTimeout;

    private final HttpClient httpClient;

    public DefaultClientFactory() throws IOException {
        fileTransferConnectTimeout = Optional.empty();
        fileTransferReadTimeout = Optional.empty();
        httpClient = new HttpClient();
    }

    public DefaultClientFactory(TermdBuildDriverModuleConfig config) throws IOException {
        fileTransferConnectTimeout = Optional.ofNullable(config.getFileTransferConnectTimeout());
        fileTransferReadTimeout = Optional.ofNullable(config.getFileTransferReadTimeout());
        httpClient = new HttpClient();
    }

    @Override
    public BuildAgentClient createBuildAgentClient(String terminalUrl, Consumer<TaskStatusUpdateEvent> onStatusUpdate)
            throws TimeoutException, InterruptedException, BuildAgentClientException {

        SocketClientConfiguration configuration = SocketClientConfiguration.newBuilder()
                .termBaseUrl(terminalUrl)
                .responseMode(ResponseMode.SILENT)
                .readOnly(false)
                .build();

        return new BuildAgentSocketClient(httpClient, Optional.empty(), onStatusUpdate, configuration);
    }

    @Override
    public FileTranser getFileTransfer(URI baseServerUri, int maxLogSize) {
        DefaultFileTranser defaultFileTranser = new DefaultFileTranser(baseServerUri, maxLogSize);
        fileTransferConnectTimeout.ifPresent(defaultFileTranser::setConnectTimeout);
        fileTransferReadTimeout.ifPresent(defaultFileTranser::setReadTimeout);
        return defaultFileTranser;
    }

    @PreDestroy
    public void destroy() throws IOException {
        httpClient.close();
    }
}

@@ -1362,16 +1362,73 @@
 Transer;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0Aimport
@@ -1817,24 +1817,119 @@
 tFactory %7B%0A%0A
+    private static final Logger logger = LoggerFactory.getLogger(DefaultClientFactory.class);%0A%0A
     /**%0A    
@@ -2491,32 +2491,90 @@
 w HttpClient();%0A
+        logger.info(%22DefaultClientFactory initialized.%22);%0A
     %7D%0A%0A    publi
@@ -2836,32 +2836,32 @@
 ReadTimeout());%0A
-
         httpClie
@@ -2879,24 +2879,116 @@
 tpClient();%0A
+        logger.info(%22DefaultClientFactory initialized with TermdBuildDriverModuleConfig.%22);%0A
     %7D%0A%0A    @

Add ClientFactory initialization logging.