List of usage examples for org.springframework.web.client RestTemplate RestTemplate
public RestTemplate(List<HttpMessageConverter<?>> messageConverters)
From source file:io.pivotal.dockerhub.client.DockerHubTemplate.java
public DockerHubTemplate(String dockerHubHost, ClientHttpRequestFactory factory) { this(dockerHubHost, new RestTemplate(factory)); }
From source file:org.trustedanalytics.platformcontext.ApplicationConfiguration.java
@Bean @Scope(value = SCOPE_REQUEST, proxyMode = TARGET_CLASS) protected RestTemplate restTemplateWithOAuth2Token() { /*Default SimpleClientHttpRequestFactory caused random "Unexpected end of file" errors while createing requests to Clound Controller*/ HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); return new RestTemplate(factory); }
From source file:com.navercorp.pinpoint.demo.gateway.configuration.GatewayConfiguration.java
@Bean public RestTemplate restTemplate() { return new RestTemplate(httpRequestFactory()); }
From source file:fi.helsinki.opintoni.config.LeikiConfiguration.java
@Bean public RestTemplate leikiRestTemplate() { final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setObjectMapper(objectMapper); RestTemplate restTemplate = new RestTemplate(Collections.singletonList(converter)); restTemplate.setInterceptors(Lists.newArrayList(new LoggingInterceptor())); return restTemplate; }
From source file:HCEngine.java
@Override public ResponseEntity<String> submit(JCurlRequestOptions requestOptions) throws Exception { ResponseEntity<String> stringResponseEntity = null; try (CloseableHttpClient hc = createCloseableHttpClient()) { for (int i = 0; i < requestOptions.getCount(); i++) { final HttpHeaders headers = new HttpHeaders(); for (Map.Entry<String, String> e : requestOptions.getHeaderMap().entrySet()) { headers.put(e.getKey(), Collections.singletonList(e.getValue())); }/*from w w w .j ava2s . c o m*/ final HttpEntity<Void> requestEntity = new HttpEntity<>(headers); RestTemplate template = new RestTemplate(new HttpComponentsClientHttpRequestFactory(hc)); stringResponseEntity = template.exchange(requestOptions.getUrl(), HttpMethod.GET, requestEntity, String.class); System.out.println(stringResponseEntity.getBody()); } return stringResponseEntity; } }
From source file:org.stilavia.service.zalando.RequestContext.java
public RequestContext(String host, ZalandoApi.Domain domain, String clientId) { this.host = host; this.domain = domain; this.clientId = clientId; this.httpClient = HttpClientBuilder.create().build(); this.requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); restTemplate = new RestTemplate(requestFactory); restTemplate.setMessageConverters(Arrays .<HttpMessageConverter<?>>asList(new MappingJackson2HttpMessageConverter(new ObjectMapper()))); }
From source file:org.springframework.cloud.stream.binder.rabbit.admin.RabbitManagementUtils.java
public static RestTemplate buildRestTemplate(String adminUri, String user, String password) { BasicCredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(user, password)); HttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build(); // Set up pre-emptive basic Auth because the rabbit plugin doesn't currently support challenge/response for PUT // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local; from the apache docs... // auth cache BasicScheme basicAuth = new BasicScheme(); URI uri;/*from w w w. j a v a 2 s. c om*/ try { uri = new URI(adminUri); } catch (URISyntaxException e) { throw new RabbitAdminException("Invalid URI", e); } authCache.put(new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()), basicAuth); // Add AuthCache to the execution context final HttpClientContext localContext = HttpClientContext.create(); localContext.setAuthCache(authCache); RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(httpClient) { @Override protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) { return localContext; } }); restTemplate.setMessageConverters( Collections.<HttpMessageConverter<?>>singletonList(new MappingJackson2HttpMessageConverter())); return restTemplate; }
From source file:org.openschedule.api.impl.AbstractOpenSchedulApiBinding.java
/** * Constructs the API template without user authorization. This is useful for accessing operations on a provider's API that do not require user authorization. *///w w w.j a v a 2 s . c o m protected AbstractOpenSchedulApiBinding() { restTemplate = new RestTemplate(ClientHttpRequestFactorySelector.getRequestFactory()); restTemplate.setMessageConverters(getMessageConverters()); configureRestTemplate(restTemplate); }
From source file:org.keycloak.adapters.springsecurity.service.KeycloakDirectAccessGrantService.java
@PostConstruct public void init() { template = new RestTemplate(requestFactory); }
From source file:org.springframework.xd.dirt.security.SingleNodeApplicationWithSslTest.java
@Before public void setUpRestTemplate() throws Exception { SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory( new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build()); HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory( httpClient);// ww w. j av a 2 s . co m restTemplate = new RestTemplate(requestFactory); }