本文整理汇总了Java中org.springframework.web.servlet.mvc.condition.RequestCondition类的典型用法代码示例。如果您正苦于以下问题:Java RequestCondition类的具体用法?Java RequestCondition怎么用?Java RequestCondition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestCondition类属于org.springframework.web.servlet.mvc.condition包,在下文中一共展示了RequestCondition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRequestMappingInfo
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
/**
* Create a {@link RequestMappingInfo} from the supplied
* {@link RequestMapping @RequestMapping} annotation, which is either
* a directly declared annotation, a meta-annotation, or the synthesized
* result of merging annotation attributes within an annotation hierarchy.
*/
protected RequestMappingInfo createRequestMappingInfo(
RequestMapping requestMapping, RequestCondition<?> customCondition) {
return RequestMappingInfo
.paths(resolveEmbeddedValuesInPatterns(requestMapping.path()))
.methods(requestMapping.method())
.params(requestMapping.params())
.headers(requestMapping.headers())
.consumes(requestMapping.consumes())
.produces(requestMapping.produces())
.mappingName(requestMapping.name())
.customCondition(customCondition)
.options(this.config)
.build();
}
示例2: createRequestMappingInfo
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation,
RequestCondition<?> customCondition,Object handler) {
//XXX: not used RequestMapping
if(annotation == null){
return createRequestMappingInfo(customCondition, handler);
}
String[] value = annotation.value();
String[] patterns = resolveEmbeddedValuesInPatterns(value);
//XXX:thining
//XXX:增加 RequestMapping value is null 时 默认使用方法名称(包括驼峰式和小写式)
if(patterns == null ||(patterns != null && patterns.length == 0)){
patterns = getPathMaping(handler);
}
return new RequestMappingInfo(
new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(),
this.useSuffixPatternMatch(), this.useTrailingSlashMatch(), this.getFileExtensions()),
new RequestMethodsRequestCondition(annotation.method()),
new ParamsRequestCondition(annotation.params()),
new HeadersRequestCondition(annotation.headers()),
new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
new ProducesRequestCondition(annotation.produces(), annotation.headers(), this.getContentNegotiationManager()),
customCondition);
}
示例3: getMappingForMethod
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo info = super.getMappingForMethod(method, handlerType);
if (info == null)
return null;
ApiVersion methodAnnotation = AnnotationUtils.findAnnotation(method, ApiVersion.class);
if (methodAnnotation != null) {
RequestCondition<?> methodCondition = getCustomMethodCondition(method);
// Concatenate our ApiVersion with the usual request mapping
info = createApiVersionInfo(methodAnnotation, methodCondition).combine(info);
} else {
ApiVersion typeAnnotation = AnnotationUtils.findAnnotation(handlerType, ApiVersion.class);
if (typeAnnotation != null) {
RequestCondition<?> typeCondition = getCustomTypeCondition(handlerType);
// Concatenate our ApiVersion with the usual request mapping
info = createApiVersionInfo(typeAnnotation, typeCondition).combine(info);
}
}
return info;
}
示例4: getMappingForMethod
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
/**
* Uses method and type-level @{@link RequestMapping} annotations to create
* the RequestMappingInfo.
* @return the created RequestMappingInfo, or {@code null} if the method
* does not have a {@code @RequestMapping} annotation.
* @see #getCustomMethodCondition(Method)
* @see #getCustomTypeCondition(Class)
*/
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo info = null;
RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
if (methodAnnotation != null) {
RequestCondition<?> methodCondition = getCustomMethodCondition(method);
info = createRequestMappingInfo(methodAnnotation, methodCondition);
RequestMapping typeAnnotation = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
if (typeAnnotation != null) {
RequestCondition<?> typeCondition = getCustomTypeCondition(handlerType);
info = createRequestMappingInfo(typeAnnotation, typeCondition).combine(info);
}
}
return info;
}
示例5: getCustomTypeCondition
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
@Override
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) {
VersionedResource versionResourceAnnotation = AnnotationUtils.findAnnotation(handlerType, VersionedResource.class);
if (versionResourceAnnotation != null) {
if (StringUtils.isEmpty(versionResourceAnnotation.media())) {
throw new IllegalArgumentException("Media cannot be null in class annotation");
}
return createCondition(versionResourceAnnotation.media(), versionResourceAnnotation.from(), versionResourceAnnotation.to(), "");
}
return null;
}
开发者ID:fintonic,项目名称:versioning-spring-boot-starter,代码行数:13,代码来源:VersionRequestMappingHandlerMapping.java
示例6: getCustomMethodCondition
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
@Override
protected RequestCondition<?> getCustomMethodCondition(Method method) {
VersionedResource methodAnnotation = AnnotationUtils.findAnnotation(method, VersionedResource.class);
if (methodAnnotation != null && StringUtils.isEmpty(methodAnnotation.from())) {
throw new IllegalArgumentException("From must be declared in method");
}
RequestMapping requestMappingClass = AnnotationUtils.findAnnotation(method.getDeclaringClass(), RequestMapping.class);
String classPath = processPathRequestMapping("", requestMappingClass);
String classMehodReq = processMethodRequestMapping(RequestMethod.GET.name(),requestMappingClass);
RequestMapping requestMappingMethod = AnnotationUtils.findAnnotation(method, RequestMapping.class);
String path = processPathRequestMapping(classPath, requestMappingMethod);
String methodReq = processMethodRequestMapping(classMehodReq, requestMappingMethod);
path = path.concat("#").concat(methodReq);
if (methodAnnotation != null) {
VersionedResource classAnnotation = AnnotationUtils.findAnnotation(method.getDeclaringClass(), VersionedResource.class);
if (classAnnotation == null && StringUtils.isEmpty(methodAnnotation.media())) {
throw new IllegalArgumentException("Media must be declared");
}
PathVersionMap.INSTANCE.checkColisionPathWithVersion(path, methodAnnotation.from(), methodAnnotation.to());
return createCondition(methodAnnotation.media(), methodAnnotation.from(), methodAnnotation.to(), path);
} else {
return null;
}
}
开发者ID:fintonic,项目名称:versioning-spring-boot-starter,代码行数:31,代码来源:VersionRequestMappingHandlerMapping.java
示例7: RequestMappingInfo
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
public RequestMappingInfo(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) {
this.name = (StringUtils.hasText(name) ? name : null);
this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition());
this.paramsCondition = (params != null ? params : new ParamsRequestCondition());
this.headersCondition = (headers != null ? headers : new HeadersRequestCondition());
this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition());
this.producesCondition = (produces != null ? produces : new ProducesRequestCondition());
this.customConditionHolder = new RequestConditionHolder(custom);
}
示例8: createRequestMappingInfo2
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
/**
* Created a RequestMappingInfo from a RequestMapping annotation.
*/
protected RequestMappingInfo createRequestMappingInfo2(RequestMapping annotation, Method method) {
String[] patterns;
if (method != null && annotation.value().length == 0) {
patterns = new String[] { this.createPattern(method.getName()) };
}
else {
patterns = resolveEmbeddedValuesInPatterns(annotation.value());
}
Map<String, String> headerMap = new LinkedHashMap<String, String>();
ExtensiveDomain extensiveDomain = new ExtensiveDomain();
requestMappingInfoBuilder.getHeaders(annotation, method, extensiveDomain, headerMap);
// System.out.println("headerMap:" + headerMap);
String[] headers = new String[headerMap.size()];
{
int i = 0;
for (Entry<String, String> entry : headerMap.entrySet()) {
String header = entry.getKey() + "=" + entry.getValue();
headers[i] = header;
i++;
}
}
RequestCondition<?> customCondition = new ServerNameRequestCondition(extensiveDomain, headers);
return new RequestMappingInfo(new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), false, this.useTrailingSlashMatch(), this.getFileExtensions()),
new RequestMethodsRequestCondition(annotation.method()), new ParamsRequestCondition(annotation.params()), new HeadersRequestCondition(),
new ConsumesRequestCondition(annotation.consumes(), headers), new ProducesRequestCondition(annotation.produces(), headers, getContentNegotiationManager()), customCondition);
}
示例9: getCustomMethodCondition
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
/**
* Store requests have to be handled by different RequestMappings
* based on whether the request is targeting a Store or content associated
* with an Entity
*/
@Override
protected RequestCondition<?> getCustomMethodCondition(Method method) {
StoreType typeAnnotation = AnnotationUtils.findAnnotation(method, StoreType.class);
if (typeAnnotation != null) {
return new StoreCondition(typeAnnotation, this.contentStores);
}
return null;
}
示例10: createApiVersionInfo
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
private RequestMappingInfo createApiVersionInfo(ApiVersion annotation, RequestCondition<?> customCondition) {
String[] values = annotation.value();
String[] patterns = new String[values.length];
for (int i = 0; i < values.length; i++) {
// Build the URL prefix
patterns[i] = prefix + values[i];
}
return new RequestMappingInfo(
new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), useSuffixPatternMatch(),
useTrailingSlashMatch(), getFileExtensions()),
new RequestMethodsRequestCondition(), new ParamsRequestCondition(), new HeadersRequestCondition(),
new ConsumesRequestCondition(), new ProducesRequestCondition(), customCondition);
}
示例11: createRequestMappingInfo
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation, RequestCondition<?> customCondition) {
return new RequestMappingInfo(
new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), false, true),
new RequestMethodsRequestCondition(annotation.method()),
new ParamsRequestCondition(annotation.params()),
new HeadersRequestCondition(annotation.headers()),
new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
new ProducesRequestCondition(annotation.produces(), annotation.headers()),
customCondition);
}
示例12: createRequestMappingInfo
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
/**
* Created a RequestMappingInfo from a RequestMapping annotation.
*/
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation, RequestCondition<?> customCondition) {
String[] patterns = resolveEmbeddedValuesInPatterns(annotation.value());
return new RequestMappingInfo(
new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(),
this.useSuffixPatternMatch, this.useTrailingSlashMatch, this.fileExtensions),
new RequestMethodsRequestCondition(annotation.method()),
new ParamsRequestCondition(annotation.params()),
new HeadersRequestCondition(annotation.headers()),
new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
new ProducesRequestCondition(annotation.produces(), annotation.headers(), getContentNegotiationManager()),
customCondition);
}
示例13: RequestMappingInfo
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
/**
* Creates a new instance with the given request conditions.
*/
public RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
ProducesRequestCondition produces, RequestCondition<?> custom) {
this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition());
this.paramsCondition = (params != null ? params : new ParamsRequestCondition());
this.headersCondition = (headers != null ? headers : new HeadersRequestCondition());
this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition());
this.producesCondition = (produces != null ? produces : new ProducesRequestCondition());
this.customConditionHolder = new RequestConditionHolder(custom);
}
示例14: getCustomTypeCondition
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
@Override
protected RequestCondition<ApiVersionCondition> getCustomTypeCondition(Class<?> handlerType) {
ApiVersion apiVersion = AnnotationUtils.findAnnotation(handlerType, ApiVersion.class);
return createCondition(apiVersion);
}
示例15: getCustomMethodCondition
import org.springframework.web.servlet.mvc.condition.RequestCondition; //导入依赖的package包/类
@Override
protected RequestCondition<ApiVersionCondition> getCustomMethodCondition(Method method) {
ApiVersion apiVersion = AnnotationUtils.findAnnotation(method, ApiVersion.class);
return createCondition(apiVersion);
}