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

com.checkmarx.sdk.config.CxConfig Maven / Gradle / Ivy

There is a newer version: 0.1.33
Show newest version
package com.checkmarx.sdk.config;

import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.web.client.RestTemplate;
import org.springframework.ws.client.core.WebServiceTemplate;
import java.nio.charset.Charset;

@Configuration
public class CxConfig {

    private final CxProperties properties;

    public CxConfig(CxProperties properties) {
        this.properties = properties;
    }

    // TODO: jeffa, verify that this is used.
    @Bean(name = "cxRestTemplate")
    public RestTemplate getRestTemplate() {
        RestTemplate restTemplate = new RestTemplate();

        HttpComponentsClientHttpRequestFactory requestFactory = new
                HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().useSystemProperties().build());
        requestFactory.setConnectTimeout(properties.getHttpConnectionTimeout());
        requestFactory.setReadTimeout(properties.getHttpReadTimeout());
        restTemplate.setRequestFactory(requestFactory);

        restTemplate.getMessageConverters()
                .add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
        return restTemplate;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy