org.springframework.web.servlet.mvc.condition.RequestCondition Java Examples
The following examples show how to use
org.springframework.web.servlet.mvc.condition.RequestCondition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RequestMappingHandlerMapping.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * 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(); }
Example #2
Source File: ApiRequestMappingHandlerMapping.java From faster-framework-project with Apache License 2.0 | 6 votes |
private RequestCondition<ApiVersionCondition> createCondition(Class<?> clazz) { RequestMapping classRequestMapping = clazz.getAnnotation(RequestMapping.class); if (classRequestMapping == null) { return null; } StringBuilder mappingUrlBuilder = new StringBuilder(); if (classRequestMapping.value().length > 0) { mappingUrlBuilder.append(classRequestMapping.value()[0]); } String mappingUrl = mappingUrlBuilder.toString(); if (!mappingUrl.contains(VERSION_FLAG)) { return null; } ApiVersion apiVersion = clazz.getAnnotation(ApiVersion.class); return new ApiVersionCondition(new ApiVersionState.ApiVersionStateBuilder() .apiVersion(apiVersion) .packageVersion(parseVersionByPackage(clazz)) .minimumVersion(minimumVersion) .build()); }
Example #3
Source File: RequestMappingMethodHandlerMapping.java From stategen with GNU Affero General Public License v3.0 | 6 votes |
protected RequestMappingInfo createRequestMappingInfoByApiMethodAnno(RequestMapping requestMapping, RequestCondition<?> customCondition, Method method) { String[] patterns = resolveEmbeddedValuesInPatterns(requestMapping.value()); if (!method.isAnnotationPresent(RequestMapping.class) || CollectionUtil.isEmpty(patterns)) { RequestMappingResolveResult methodParsered = RequestMappingResolver.resolveOwnPath(method); String path = methodParsered.getPath(); patterns = new String[] { path }; } return new RequestMappingInfo( new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), this.useSuffixPatternMatch, this.useTrailingSlashMatch, this.fileExtensions), new RequestMethodsRequestCondition(requestMapping.method()), new ParamsRequestCondition(requestMapping.params()), new HeadersRequestCondition(requestMapping.headers()), new ConsumesRequestCondition(requestMapping.consumes(), requestMapping.headers()), new ProducesRequestCondition(requestMapping.produces(), requestMapping.headers(), this.contentNegotiationManager), customCondition); }
Example #4
Source File: RequestMappingMethodHandlerMapping.java From stategen with GNU Affero General Public License v3.0 | 6 votes |
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) { boolean isClass = element instanceof Class<?>; RequestMapping requestMappingAnno = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class); if (requestMappingAnno == null) { return null; } RequestCondition<?> condition = (isClass ? getCustomTypeCondition((Class<?>) element) : getCustomMethodCondition((Method) element)); ApiRequestMappingAutoWithMethodName apiRequestMappingAutoWithMethodNameAnno = AnnotatedElementUtils.findMergedAnnotation(element, ApiRequestMappingAutoWithMethodName.class); if (apiRequestMappingAutoWithMethodNameAnno == null) { return createRequestMappingInfo(requestMappingAnno, condition); } return createRequestMappingInfoByApiMethodAnno(requestMappingAnno, condition, (Method) element); }
Example #5
Source File: RequestMappingHandlerMapping.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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(); }
Example #6
Source File: RequestMappingHandlerMapping.java From java-technology-stack with MIT License | 6 votes |
/** * 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, @Nullable RequestCondition<?> customCondition) { RequestMappingInfo.Builder builder = RequestMappingInfo .paths(resolveEmbeddedValuesInPatterns(requestMapping.path())) .methods(requestMapping.method()) .params(requestMapping.params()) .headers(requestMapping.headers()) .consumes(requestMapping.consumes()) .produces(requestMapping.produces()) .mappingName(requestMapping.name()); if (customCondition != null) { builder.customCondition(customCondition); } return builder.options(this.config).build(); }
Example #7
Source File: RequestMappingHandlerMapping.java From spring-analysis-note with MIT License | 6 votes |
/** * 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, @Nullable RequestCondition<?> customCondition) { RequestMappingInfo.Builder builder = RequestMappingInfo .paths(resolveEmbeddedValuesInPatterns(requestMapping.path())) .methods(requestMapping.method()) .params(requestMapping.params()) .headers(requestMapping.headers()) .consumes(requestMapping.consumes()) .produces(requestMapping.produces()) .mappingName(requestMapping.name()); if (customCondition != null) { builder.customCondition(customCondition); } return builder.options(this.config).build(); }
Example #8
Source File: ApiRequestMappingHandlerMapping.java From AthenaServing with Apache License 2.0 | 6 votes |
/** * 创建匹配条件 * * @param clazz * @return */ private static RequestCondition<ApiVersionCondition> createCondition(Class<?> clazz) { RequestMapping classRequestMapping = AnnotationUtils.findAnnotation(clazz, RequestMapping.class); if (classRequestMapping == null) { return null; } StringBuilder mappingUrlBuilder = new StringBuilder(); if (classRequestMapping.value().length > 0) { mappingUrlBuilder.append(classRequestMapping.value()[0]); } String mappingUrl = mappingUrlBuilder.toString(); if (!mappingUrl.contains("{version}") || !mappingUrl.contains("{v}")) { return null; } ApiVersion apiVersion = AnnotationUtils.findAnnotation(clazz, ApiVersion.class); return apiVersion == null ? new ApiVersionCondition(1) : new ApiVersionCondition(apiVersion.value()); }
Example #9
Source File: RequestMappingInfo.java From spring-analysis-note with MIT License | 5 votes |
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, @Nullable ProducesRequestCondition produces, @Nullable 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); }
Example #10
Source File: RequestMappingHandlerMapping.java From spring-analysis-note with MIT License | 5 votes |
/** * Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)}, * supplying the appropriate custom {@link RequestCondition} depending on whether * the supplied {@code annotatedElement} is a class or method. * @see #getCustomTypeCondition(Class) * @see #getCustomMethodCondition(Method) */ @Nullable private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) { RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class); RequestCondition<?> condition = (element instanceof Class ? getCustomTypeCondition((Class<?>) element) : getCustomMethodCondition((Method) element)); return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null); }
Example #11
Source File: RequestMappingInfo.java From lams with GNU General Public License v2.0 | 5 votes |
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); }
Example #12
Source File: RequestMappingInfo.java From java-technology-stack with MIT License | 5 votes |
/** * Creates a new instance with the given request conditions. */ public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) { this(null, patterns, methods, params, headers, consumes, produces, custom); }
Example #13
Source File: RequestMappingInfo.java From java-technology-stack with MIT License | 5 votes |
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, @Nullable ProducesRequestCondition produces, @Nullable 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); }
Example #14
Source File: RequestMappingInfo.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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(null, patterns, methods, params, headers, consumes, produces, custom); }
Example #15
Source File: RequestMappingHandlerMapping.java From java-technology-stack with MIT License | 5 votes |
/** * Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)}, * supplying the appropriate custom {@link RequestCondition} depending on whether * the supplied {@code annotatedElement} is a class or method. * @see #getCustomTypeCondition(Class) * @see #getCustomMethodCondition(Method) */ @Nullable private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) { RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class); RequestCondition<?> condition = (element instanceof Class ? getCustomTypeCondition((Class<?>) element) : getCustomMethodCondition((Method) element)); return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null); }
Example #16
Source File: RequestMappingInfo.java From spring4-understanding with Apache License 2.0 | 5 votes |
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); }
Example #17
Source File: RequestMappingInfo.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * 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(null, patterns, methods, params, headers, consumes, produces, custom); }
Example #18
Source File: ContentHandlerMapping.java From spring-content with Apache License 2.0 | 5 votes |
/** * 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, method, this.getConfiguration().getBaseUri()); } return null; }
Example #19
Source File: RequestMappingInfo.java From spring-analysis-note with MIT License | 5 votes |
/** * Creates a new instance with the given request conditions. */ public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) { this(null, patterns, methods, params, headers, consumes, produces, custom); }
Example #20
Source File: CustomRequestMappingHandlerMapping.java From EasyReport with Apache License 2.0 | 4 votes |
private RequestCondition<ApiVesrsionCondition> createCondition(ApiVersion apiVersion) { return apiVersion == null ? null : new ApiVesrsionCondition(apiVersion.value()); }
Example #21
Source File: RequestMappingInfo.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public DefaultBuilder customCondition(RequestCondition<?> condition) { this.customCondition = condition; return this; }
Example #22
Source File: RequestMappingInfo.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Return the "custom" condition of this {@link RequestMappingInfo}, or {@code null}. */ public RequestCondition<?> getCustomCondition() { return this.customConditionHolder.getCondition(); }
Example #23
Source File: RequestMappingInfo.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Re-create a RequestMappingInfo with the given custom request condition. */ public RequestMappingInfo(RequestMappingInfo info, RequestCondition<?> customRequestCondition) { this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition, info.consumesCondition, info.producesCondition, customRequestCondition); }
Example #24
Source File: CustomRequestMappingHandlerMapping.java From EasyReport with Apache License 2.0 | 4 votes |
@Override protected RequestCondition<ApiVesrsionCondition> getCustomTypeCondition(Class<?> handlerType) { ApiVersion apiVersion = AnnotationUtils.findAnnotation(handlerType, ApiVersion.class); return createCondition(apiVersion); }
Example #25
Source File: RequestMappingInfo.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Re-create a RequestMappingInfo with the given custom request condition. */ public RequestMappingInfo(RequestMappingInfo info, RequestCondition<?> customRequestCondition) { this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition, info.consumesCondition, info.producesCondition, customRequestCondition); }
Example #26
Source File: RequestMappingInfo.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Returns the "custom" condition of this {@link RequestMappingInfo}; or {@code null}. */ public RequestCondition<?> getCustomCondition() { return this.customConditionHolder.getCondition(); }
Example #27
Source File: RequestMappingInfo.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public DefaultBuilder customCondition(RequestCondition<?> condition) { this.customCondition = condition; return this; }
Example #28
Source File: CustomRequestMappingHandlerMapping.java From EasyReport with Apache License 2.0 | 4 votes |
@Override protected RequestCondition<ApiVesrsionCondition> getCustomMethodCondition(Method method) { ApiVersion apiVersion = AnnotationUtils.findAnnotation(method, ApiVersion.class); return createCondition(apiVersion); }
Example #29
Source File: ApiRequestMappingHandlerMapping.java From faster-framework-project with Apache License 2.0 | 4 votes |
@Override protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) { return createCondition(handlerType); }
Example #30
Source File: ApiRequestMappingHandlerMapping.java From faster-framework-project with Apache License 2.0 | 4 votes |
@Override protected RequestCondition<?> getCustomMethodCondition(Method method) { return createCondition(method.getClass()); }