List of usage examples for org.springframework.web.servlet.mvc.method RequestMappingInfo getMethodsCondition
public RequestMethodsRequestCondition getMethodsCondition()
From source file:springfox.documentation.spring.web.readers.operation.ApiOperationReader.java
@Override // @Cacheable(value = "operations", keyGenerator = OperationsKeyGenerator.class) public List<Operation> read(RequestMappingContext outerContext) { RequestMappingInfo requestMappingInfo = outerContext.getRequestMappingInfo(); String requestMappingPattern = outerContext.getRequestMappingPattern(); RequestMethodsRequestCondition requestMethodsRequestCondition = requestMappingInfo.getMethodsCondition(); List<Operation> operations = newArrayList(); Set<RequestMethod> requestMethods = requestMethodsRequestCondition.getMethods(); Set<RequestMethod> supportedMethods = supportedMethods(requestMethods); //Setup response message list Integer currentCount = 0;//from w w w . j ava 2 s . c o m for (RequestMethod httpRequestMethod : supportedMethods) { OperationContext operationContext = new OperationContext(new OperationBuilder(nameGenerator), httpRequestMethod, outerContext.getHandlerMethod(), currentCount, requestMappingInfo, outerContext.getDocumentationContext(), requestMappingPattern); Operation operation = pluginsManager.operation(operationContext); if (!operation.isHidden()) { operations.add(operation); currentCount++; } } Collections.sort(operations, outerContext.operationOrdering()); return operations; }
From source file:de.codecentric.boot.admin.web.PrefixHandlerMapping.java
private RequestMappingInfo withPrefix(RequestMappingInfo mapping) { List<String> newPatterns = getPatterns(mapping); PatternsRequestCondition patterns = new PatternsRequestCondition( newPatterns.toArray(new String[newPatterns.size()])); return new RequestMappingInfo(patterns, mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition()); }
From source file:org.jm.swagger.SpringMVCAPIReader.java
/** * NickName right now defaults to the method name * /* w ww . ja va2s . co m*/ * @param requestMappingInfo * @return */ private DocumentationOperation processRequestMapping(RequestMappingInfo requestMappingInfo, String nickName) { DocumentationOperation documentationOperation = new DocumentationOperation(); //GET/POST Set<RequestMethod> requestMethods = requestMappingInfo.getMethodsCondition().getMethods(); String value = Joiner.on(",").join(requestMethods); documentationOperation.setHttpMethod(value); documentationOperation.setNickname(nickName); documentationOperation.setSummary("summary"); return documentationOperation; }
From source file:org.springbyexample.mvc.method.annotation.ServiceHandlerMapping.java
/** * Register handler.// w w w . j a va 2s . c o m */ private void registerHandler(Class<?> marshallingServiceClass, Method method) { ApplicationContext ctx = getApplicationContext(); RestResource restResource = AnnotationUtils.findAnnotation(marshallingServiceClass, RestResource.class); Class<?> serviceClass = restResource.service(); RestRequestResource restRequestResource = AnnotationUtils.findAnnotation(method, RestRequestResource.class); boolean export = (restRequestResource != null ? restRequestResource.export() : true); boolean relative = (restRequestResource != null ? restRequestResource.relative() : true); if (export) { Class<?> handlerServiceClass = serviceClass; String methodName = method.getName(); Class<?>[] paramTypes = method.getParameterTypes(); if (restRequestResource != null) { // explicit service specified if (restRequestResource.service() != ServiceValueConstants.DEFAULT_SERVICE_CLASS) { handlerServiceClass = restRequestResource.service(); } // explicit method name specified if (StringUtils.hasText(restRequestResource.methodName())) { methodName = restRequestResource.methodName(); } } Object handler = ctx.getBean(handlerServiceClass); Method serviceMethod = ClassUtils.getMethod(handlerServiceClass, methodName, paramTypes); RequestMappingInfo mapping = getMappingForMethod(method, marshallingServiceClass); if (relative) { List<String> patterns = new ArrayList<String>(); for (String pattern : mapping.getPatternsCondition().getPatterns()) { // add REST resource path prefix to URI, // if relative path is just '/' add an empty string patterns.add(restResource.path() + (!"/".equals(pattern) ? pattern : "")); } // create a new mapping based on the patterns (patterns are unmodifiable in existing RequestMappingInfo) mapping = new RequestMappingInfo( new PatternsRequestCondition(patterns.toArray(ArrayUtils.EMPTY_STRING_ARRAY), getUrlPathHelper(), getPathMatcher(), useSuffixPatternMatch(), useTrailingSlashMatch()), mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition()); } // need to set param types to use in createHandlerMethod before calling registerHandlerMethod restBridgedMethod = BridgeMethodResolver.findBridgedMethod(method); // mapping is key, HandlerMethod is value registerHandlerMethod(handler, serviceMethod, mapping); processConverters(restRequestResource, mapping, serviceMethod); } }
From source file:org.springframework.web.servlet.DispatcherServletMod.java
/** * getHandleName/* w ww . ja v a 2 s.com*/ */ protected boolean detectOnlyGetMethod(RequestMappingInfo info) { for (RequestMethod method : info.getMethodsCondition().getMethods()) { if (method != RequestMethod.GET) return false; } return true; }