本文整理汇总了Java中org.springframework.web.util.DefaultUriTemplateHandler类的典型用法代码示例。如果您正苦于以下问题:Java DefaultUriTemplateHandler类的具体用法?Java DefaultUriTemplateHandler怎么用?Java DefaultUriTemplateHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultUriTemplateHandler类属于org.springframework.web.util包,在下文中一共展示了DefaultUriTemplateHandler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerRestTemplate
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
private String registerRestTemplate(final String id, final String factoryId, final String convertersId,
@Nullable final String baseUrl) {
return registry.register(id, RestTemplate.class, () -> {
LOG.debug("Client [{}]: Registering RestTemplate", id);
final BeanDefinitionBuilder restTemplate = genericBeanDefinition(RestTemplate.class);
restTemplate.addConstructorArgReference(factoryId);
final DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
handler.setBaseUrl(baseUrl);
restTemplate.addPropertyValue("uriTemplateHandler", handler);
final AbstractBeanDefinition converters = BeanDefinitionBuilder.genericBeanDefinition()
.setFactoryMethod("getConverters")
.getBeanDefinition();
converters.setFactoryBeanName(convertersId);
restTemplate.addPropertyValue("messageConverters", converters);
return restTemplate;
});
}
示例2: registerAsyncRestTemplate
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
private String registerAsyncRestTemplate(final String id, final String factoryId, final String convertersId,
@Nullable final String baseUrl) {
return registry.register(id, AsyncRestTemplate.class, () -> {
LOG.debug("Client [{}]: Registering AsyncRestTemplate", id);
final BeanDefinitionBuilder restTemplate = genericBeanDefinition(AsyncRestTemplate.class);
restTemplate.addConstructorArgReference(factoryId);
final DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
handler.setBaseUrl(baseUrl);
restTemplate.addPropertyValue("uriTemplateHandler", handler);
final AbstractBeanDefinition converters = BeanDefinitionBuilder.genericBeanDefinition()
.setFactoryMethod("getConverters")
.getBeanDefinition();
converters.setFactoryBeanName(convertersId);
restTemplate.addPropertyValue("messageConverters", converters);
return restTemplate;
});
}
示例3: registerTemplate
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
private void registerTemplate(final String id, final Class<?> type, final String factoryId,
@Nullable final String baseUrl, final BeanDefinition converters, final List<BeanMetadataElement> plugins) {
registry.registerIfAbsent(id, type, () -> {
log.debug("Client [{}]: Registering AsyncRestTemplate", id);
final DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
handler.setBaseUrl(baseUrl);
final BeanDefinitionBuilder template = genericBeanDefinition(type);
template.addConstructorArgReference(factoryId);
template.addPropertyValue("uriTemplateHandler", handler);
template.addPropertyValue("messageConverters", converters);
template.addPropertyValue("interceptors", plugins.stream()
.map(plugin -> genericBeanDefinition(PluginInterceptors.class)
.setFactoryMethod("adapt")
.addConstructorArgValue(plugin)
.getBeanDefinition())
.collect(toCollection(Registry::list)));
return template;
});
}
示例4: getForObjectWithCustomUriTemplateHandler
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
@Test
public void getForObjectWithCustomUriTemplateHandler() throws Exception {
DefaultUriTemplateHandler uriTemplateHandler = new DefaultUriTemplateHandler();
uriTemplateHandler.setParsePath(true);
template.setUriTemplateHandler(uriTemplateHandler);
URI expectedUri = new URI("http://example.com/hotels/1/pic/pics%2Flogo.png/size/150x150");
given(requestFactory.createRequest(expectedUri, HttpMethod.GET)).willReturn(request);
given(request.getHeaders()).willReturn(new HttpHeaders());
given(request.execute()).willReturn(response);
given(errorHandler.hasError(response)).willReturn(false);
given(response.getStatusCode()).willReturn(HttpStatus.OK);
given(response.getHeaders()).willReturn(new HttpHeaders());
given(response.getBody()).willReturn(null);
Map<String, String> uriVariables = new HashMap<String, String>(2);
uriVariables.put("hotel", "1");
uriVariables.put("publicpath", "pics/logo.png");
uriVariables.put("scale", "150x150");
String url = "http://example.com/hotels/{hotel}/pic/{publicpath}/size/{scale}";
template.getForObject(url, String.class, uriVariables);
verify(response).close();
}
示例5: init
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
@PostConstruct
public void init() {
DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
handler.setBaseUrl(url + ":" + port);
handler.setParsePath(true);
client = new TestRestTemplate();
client.setUriTemplateHandler(handler);
}
示例6: exampleRestTemplate
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
@Bean
public RestTemplate exampleRestTemplate(final ClientHttpRequestFactory requestFactory,
final ClientHttpMessageConverters converters) {
final RestTemplate template = new RestTemplate();
final DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
handler.setBaseUrl("https://www.example.com");
template.setUriTemplateHandler(handler);
template.setRequestFactory(requestFactory);
template.setMessageConverters(converters.getConverters());
return template;
}
示例7: exampleAsyncRestTemplate
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
@Bean
public AsyncRestTemplate exampleAsyncRestTemplate(final AsyncClientHttpRequestFactory requestFactory,
final ClientHttpMessageConverters converters) {
final AsyncRestTemplate template = new AsyncRestTemplate();
final DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
handler.setBaseUrl("https://www.example.com");
template.setUriTemplateHandler(handler);
template.setAsyncRequestFactory(requestFactory);
template.setMessageConverters(converters.getConverters());
return template;
}
示例8: defaultUriVariablesOf
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
private Map<String, ?> defaultUriVariablesOf(RestTemplate wrapper1) {
return ((DefaultUriTemplateHandler) wrapper1.getUriTemplateHandler()).getDefaultUriVariables();
}
示例9: createUriTemplateHandler
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
private static DefaultUriTemplateHandler createUriTemplateHandler(
VaultEndpointProvider endpointProvider) {
return new PrefixAwareUriTemplateHandler(endpointProvider);
}
示例10: LocalHostUriTemplateHandler
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
public LocalHostUriTemplateHandler(Environment environment) {
super(new DefaultUriTemplateHandler());
Assert.notNull(environment, "Environment must not be null");
this.environment = environment;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:LocalHostUriTemplateHandler.java
示例11: createUriTemplateHandler
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
/**
* Create a {@link UriTemplateHandler} that prefixes all {@link RestTemplate} calls
* with the configured {@literal baseUri}.
*
* @param baseUri the base URI for the CredHub server
* @return a configured {@link UriTemplateHandler}
*/
private static DefaultUriTemplateHandler createUriTemplateHandler(String baseUri) {
DefaultUriTemplateHandler uriTemplateHandler = new DefaultUriTemplateHandler();
uriTemplateHandler.setBaseUrl(baseUri);
return uriTemplateHandler;
}
示例12: RootUriTemplateHandler
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
/**
* Create a new {@link RootUriTemplateHandler} instance.
* @param rootUri the root URI to be used to prefix relative URLs
*/
public RootUriTemplateHandler(String rootUri) {
this(rootUri, new DefaultUriTemplateHandler());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:RootUriTemplateHandler.java
示例13: RootUriTemplateHandler
import org.springframework.web.util.DefaultUriTemplateHandler; //导入依赖的package包/类
/**
* Create a new {@link RootUriTemplateHandler} instance.
* @param rootUri the root URI to used to prefix relative URLs
*/
public RootUriTemplateHandler(String rootUri) {
this(rootUri, new DefaultUriTemplateHandler());
}