@Override public boolean test(Method method) { RequestMapping annot = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); return annot != null && Arrays.equals(this.path, annot.path()) && Arrays.equals(this.method, annot.method()) && (this.params == null || Arrays.equals(this.params, annot.params())); } }
/** * 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(); }
/** * 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(); }
/** * 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(); }
@Override protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { RequestMapping annot = AnnotationUtils.findAnnotation(method, RequestMapping.class); if (annot != null) { return new RequestMappingInfo( new PatternsRequestCondition(annot.value(), getUrlPathHelper(), getPathMatcher(), true, true), new RequestMethodsRequestCondition(annot.method()), new ParamsRequestCondition(annot.params()), new HeadersRequestCondition(annot.headers()), new ConsumesRequestCondition(annot.consumes(), annot.headers()), new ProducesRequestCondition(annot.produces(), annot.headers()), null); } else { return null; } } }
@Override protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { RequestMapping annot = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (annot != null) { BuilderConfiguration options = new BuilderConfiguration(); options.setPatternParser(getPathPatternParser()); return paths(annot.value()).methods(annot.method()) .params(annot.params()).headers(annot.headers()) .consumes(annot.consumes()).produces(annot.produces()) .options(options).build(); } else { return null; } } }
@Override protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (annotation != null) { return new RequestMappingInfo( new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, 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()), null); } else { return null; } } }
/** * Returns the list of annotated query parameters. * * @param requestMapping the request mapping annotation * @return the list of query parameters or an empty list */ private List<String> getAnnotatedQueryParams(RequestMapping requestMapping) { List<String> annotatedQueryParams = new ArrayList<>(); if (requestMapping != null) { annotatedQueryParams.addAll(Arrays.asList(requestMapping.params())); } return annotatedQueryParams; }
private void checkUnsupportedProperties(@Nonnull RequestMapping requestMapping) { if (requestMapping.consumes().length > 0) { throw new UnsupportedOperationException("RequestMapping.consumes is not supported"); } if (requestMapping.headers().length > 0) { throw new UnsupportedOperationException("RequestMapping.headers is not supported"); } if (requestMapping.produces().length > 0) { throw new UnsupportedOperationException("RequestMapping.consumes is not supported"); } if (requestMapping.params().length > 0) { throw new UnsupportedOperationException("RequestMapping.params is not supported"); } }
/** * Checks the request mapping annotation value and adds the resulting @ApiParamDoc to the documentation * @param apiParamDocs * @param requestMapping */ private static void addRequestMappingParamDoc(Set<ApiParamDoc> apiParamDocs, RequestMapping requestMapping) { if (requestMapping.params().length > 0) { for (String param : requestMapping.params()) { String[] splitParam = param.split("="); if (splitParam.length > 1) { apiParamDocs.add(new ApiParamDoc(splitParam[0], "", JSONDocTypeBuilder.build(new JSONDocType(), String.class, null), "true", new String[] { splitParam[1] }, null, null)); } else { apiParamDocs.add(new ApiParamDoc(param, "", JSONDocTypeBuilder.build(new JSONDocType(), String.class, null), "true", new String[] {}, null, null)); } } } }
@Override protected boolean isHandlerMethod(Method method) { if (this.mappings.containsKey(method)) { return true; } RequestMapping mapping = AnnotationUtils.findAnnotation(method, RequestMapping.class); if (mapping != null) { String[] patterns = mapping.value(); RequestMethod[] methods = new RequestMethod[0]; String[] params = new String[0]; String[] headers = new String[0]; if (!hasTypeLevelMapping() || !Arrays.equals(mapping.method(), getTypeLevelMapping().method())) { methods = mapping.method(); } if (!hasTypeLevelMapping() || !Arrays.equals(mapping.params(), getTypeLevelMapping().params())) { params = mapping.params(); } if (!hasTypeLevelMapping() || !Arrays.equals(mapping.headers(), getTypeLevelMapping().headers())) { headers = mapping.headers(); } RequestMappingInfo mappingInfo = new RequestMappingInfo(patterns, methods, params, headers); this.mappings.put(method, mappingInfo); return true; } return false; }
requestMapping.params(), requestMapping.headers()); if (mappingInfo.phase == null) { mappingInfo.phase = determineDefaultPhase(method);
requestMapping.params(), requestMapping.headers()); if (mappingInfo.phase == null) { mappingInfo.phase = determineDefaultPhase(method);
String[] params = new String[0]; if (typeMapping != null) { params = PortletAnnotationMappingUtils.mergeStringArrays(typeMapping.params(), params); params = PortletAnnotationMappingUtils.mergeStringArrays(params, requestMapping.params()); if (predicate == null) { predicate = new MethodLevelMappingPredicate(params);
String[] params = mapping.params(); boolean registerHandlerType = true; if (modeKeys.length == 0 || params.length == 0) {
/** * Validate the given type-level mapping metadata against the current request, * checking HTTP request method and parameter conditions. * @param mapping the mapping metadata to validate * @param request current HTTP request * @throws Exception if validation failed */ protected void validateMapping(RequestMapping mapping, HttpServletRequest request) throws Exception { RequestMethod[] mappedMethods = mapping.method(); if (!ServletAnnotationMappingUtils.checkRequestMethod(mappedMethods, request)) { String[] supportedMethods = new String[mappedMethods.length]; for (int i = 0; i < mappedMethods.length; i++) { supportedMethods[i] = mappedMethods[i].name(); } throw new HttpRequestMethodNotSupportedException(request.getMethod(), supportedMethods); } String[] mappedParams = mapping.params(); if (!ServletAnnotationMappingUtils.checkParameters(mappedParams, request)) { throw new UnsatisfiedServletRequestParameterException(mappedParams, request.getParameterMap()); } String[] mappedHeaders = mapping.headers(); if (!ServletAnnotationMappingUtils.checkHeaders(mappedHeaders, request)) { throw new ServletRequestBindingException("Header conditions \"" + StringUtils.arrayToDelimitedString(mappedHeaders, ", ") + "\" not met for actual request"); } }
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation, RequestCondition<?> customCondition, Method method) { String className = method.getDeclaringClass().getSimpleName(); String classNameExceptAction = StringUtils.uncapitalize(className.substring(0, className.length() - 10)); String[] patterns = resolveEmbeddedValuesInPatterns(annotation.value()); if ((patterns != null) && (patterns.length == 0)) {// patterns = new String[] { classNameExceptAction + "!" + method.getName() }; } 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(), this.contentNegotiationManager), customCondition); }
String[] params = mapping.params(); boolean registerHandlerType = true; if (modeKeys.length == 0 || params.length == 0) {
/** * 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(); }