本文整理匯總了Java中org.springframework.web.client.RestTemplate.getRequestFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java RestTemplate.getRequestFactory方法的具體用法?Java RestTemplate.getRequestFactory怎麽用?Java RestTemplate.getRequestFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.client.RestTemplate
的用法示例。
在下文中一共展示了RestTemplate.getRequestFactory方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: connect
import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
private T connect(final PathBuilder config) throws RestClientException {
final RestTemplate restTemplate = new RestTemplate(httpMessageConverters);
final SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
rf.setReadTimeout(2000);
rf.setConnectTimeout(2000);
config.addParam("t", RestfulContext.getToken());
final ResponseEntity<T> re = restTemplate.getForEntity(config.buildEndpointURI(), dtoType);
return re.getBody();
}
示例2: loginDataProvider
import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/**
* Creates a login call to remote webservice.
*
* @param config
* @return token | RestClientException
*/
public static String loginDataProvider(final PathBuilder config) {
final MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("u", config.getMaster_user());
map.add("p", config.getMaster_pw());
final RestTemplate restTemplate = new RestTemplate();
final SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
rf.setReadTimeout(3000);
rf.setConnectTimeout(30000);
try {
final URI uri = new URIBuilder().setScheme("http").setCharset(StandardCharsets.UTF_8).setHost(config
.getServer()).setPath("/ssp-data-provider/login/token").build();
final TokenWrapper result = restTemplate.postForObject(uri, map, TokenWrapper.class);
return result.getToken();
} catch (final URISyntaxException | RestClientException e) {
System.out.println("[WARNING] LoginService: " + e.getMessage());
}
return null;
}
示例3: TuPactRecordingServer
import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
protected TuPactRecordingServer(RestTemplate restTemplate, File pactFile, ObjectStringConverter objectConverter, MediaType contentType) {
this.restTemplate = restTemplate;
this.pactFile = pactFile;
this.objectConverter = objectConverter;
originalRequestFactory = restTemplate.getRequestFactory();
mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
this.contentType = contentType;
}
示例4: init
import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
@PostConstruct
public void init() {
restTemplate = new RestTemplate();
SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
rf.setReadTimeout(portalConfig.readTimeout());
rf.setConnectTimeout(portalConfig.connectTimeout());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(
Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM));
restTemplate.setMessageConverters(Arrays.asList(converter, new FormHttpMessageConverter()));
}
示例5: configureCloudFoundryRequestFactory
import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
protected void configureCloudFoundryRequestFactory(RestTemplate restTemplate) {
ClientHttpRequestFactory requestFactory = restTemplate.getRequestFactory();
if (!(requestFactory instanceof CloudFoundryClientHttpRequestFactory)) {
restTemplate.setRequestFactory(new CloudFoundryClientHttpRequestFactory(requestFactory));
}
}