Example usage for org.springframework.web.client RestTemplate RestTemplate

List of usage examples for org.springframework.web.client RestTemplate RestTemplate

Introduction

In this page you can find the example usage for org.springframework.web.client RestTemplate RestTemplate.

Prototype

public RestTemplate(List<HttpMessageConverter<?>> messageConverters) 

Source Link

Document

Create a new instance of the RestTemplate using the given list of HttpMessageConverter to use.

Usage

From source file:com.epam.reportportal.gateway.CompositeInfoEndpoint.java

@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired/*from  ww  w  .  jav a2s .  c o  m*/
public CompositeInfoEndpoint(RestTemplate loadBalancedRestTemplate, DiscoveryClient discoveryClient,
        EurekaClient eurekaClient) {
    this.restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(
            HttpClientBuilder.create().setSSLHostnameVerifier((s, sslSession) -> true).build()));

    this.loadBalancedRestTemplate = loadBalancedRestTemplate;
    this.discoveryClient = discoveryClient;
    this.eurekaClient = eurekaClient;
}

From source file:es.ujaen.dae.restClient.controllers.SessionBackingBean.java

public SessionBackingBean() {
    user = new UsersDTO();
    wall = new ArrayList();
    message = new CommentDTO();
    task = new TaskDTO();
    loggedIn = false;//from   w  w w. java 2 s .  c o m
    usersFound = new ArrayList();
    editTask = false;
    lTask = new ArrayList();
    hasNotifications = false;
    DefaultHttpClient httpClient = new DefaultHttpClient();
    ClientHttpRequestFactory rf = new HttpComponentsClientHttpRequestFactory(httpClient);
    template = new RestTemplate(rf);
}

From source file:org.obiba.mica.core.service.AgateRestService.java

protected RestTemplate newRestTemplate() {
    log.info("Connecting to Agate: {}", agateUrl);
    if (agateUrl.toLowerCase().startsWith("https://")) {
        if (httpRequestFactory == null) {
            httpRequestFactory = new HttpComponentsClientHttpRequestFactory(createHttpClient());
        }/*from  w  ww. j av a  2  s.c o  m*/
        return new RestTemplate(httpRequestFactory);
    } else {
        return new RestTemplate();
    }
}

From source file:org.springframework.http.server.reactive.ServerHttpsRequestIntegrationTests.java

@Before
public void setup() throws Exception {
    this.server.setHandler(new CheckRequestHandler());
    this.server.afterPropertiesSet();
    this.server.start();

    // Set dynamically chosen port
    this.port = this.server.getPort();

    SSLContextBuilder builder = new SSLContextBuilder();
    builder.loadTrustMaterial(new TrustSelfSignedStrategy());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(builder.build(),
            NoopHostnameVerifier.INSTANCE);
    CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpclient);/*from   w ww  . j a  v  a 2s.com*/
    this.restTemplate = new RestTemplate(requestFactory);
}

From source file:org.trustedanalytics.servicebroker.hdfs.config.hgm.HgmHttpsConfiguration.java

@Bean
@Qualifier("hgmRestTemplate")
public RestTemplate getHgmHttpsRestTemplate()
        throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
    SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).useTLS()
            .build();/*from   w w w  . j a v  a 2  s  .c  o  m*/
    SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext,
            new AllowAllHostnameVerifier());
    BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY,
            new UsernamePasswordCredentials(configuration.getUsername(), configuration.getPassword()));

    HttpClient httpClient = HttpClientBuilder.create().setSSLSocketFactory(connectionFactory)
            .setDefaultCredentialsProvider(credentialsProvider).build();

    ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
    return new RestTemplate(requestFactory);
}

From source file:io.bosh.client.SpringDirectorClientBuilder.java

public SpringDirectorClient build() {
    // TODO validate
    URI root = UriComponentsBuilder.newInstance().scheme("https").host(host).port(25555).build().toUri();
    RestTemplate restTemplate = new RestTemplate(createRequestFactory(host, username, password));
    restTemplate.getInterceptors().add(new ContentTypeClientHttpRequestInterceptor());
    handleTextHtmlResponses(restTemplate);
    return new SpringDirectorClient(root, restTemplate);
}

From source file:com.navercorp.pinpoint.plugin.spring.web.RestTemplateIT.java

@Test
public void test2() throws Exception {
    RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
    String forObject = restTemplate.getForObject(webServer.getCallHttpUrl(), String.class);

    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();//from   w w w .j  a v  a  2 s. co m

    verifier.verifyTrace(event("REST_TEMPLATE", RestTemplate.class.getConstructor()));
    verifier.verifyTrace(event("REST_TEMPLATE", AbstractClientHttpRequest.class.getMethod("execute"),
            annotation("http.status.code", 200)));
}

From source file:com.example.ResourceApp.java

@Bean
@HalJson
RestTemplate halJsonRestTemplate() {
    return new RestTemplate(Collections.singletonList(halJsonMappingJackson2HttpMessageConverter()));
}

From source file:io.pivotal.receptor.client.ReceptorClient.java

public ReceptorClient(String receptorHost, ClientHttpRequestFactory factory) {
    this(receptorHost, new RestTemplate(factory));
}