本文整理汇总了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));
}
}