Package org.springframework.web.bind.annotation

Examples of org.springframework.web.bind.annotation.RequestMapping


     *            Method - get the request mapping for this method
     * @return String - the value of the RequestMapping annotation on this
     *         method
     */
    public static String getMethodRequestMappingValue(Method method) {
        RequestMapping requestMapping = method
                .getAnnotation(RequestMapping.class);
        String requestMappingValue = "";
        if (requestMapping != null) {
            String[] requestMappingValues = requestMapping.value();
            if (requestMappingValues != null && requestMappingValues.length > 0) {
                requestMappingValue = requestMappingValues[0];
            }
        }

View Full Code Here


        if (controllerApi != null) {
            resourcePath = controllerApi.basePath();
        }

        if (controllerApi == null || resourcePath.isEmpty()) {
            RequestMapping controllerRequestMapping = controllerClass.getAnnotation(RequestMapping.class);
            if (controllerRequestMapping != null && controllerRequestMapping.value() != null &&
                    controllerRequestMapping.value().length > 0) {
                resourcePath = controllerRequestMapping.value()[0];
            } else {
                resourcePath = controllerClass.getName();
            }
        }
        if (!resourcePath.startsWith("/")) {
View Full Code Here

                documentationOperation.setResponseClass(clazz);
            }
        }

        String httpMethod = "";
        RequestMapping methodRequestMapping = method.getAnnotation(RequestMapping.class);
        for (RequestMethod requestMethod : methodRequestMapping.method()) {
            httpMethod += requestMethod.name() + " ";
        }
        httpMethod = httpMethod.trim();
        if(StringUtils.isEmpty(httpMethod) || " ".equals(httpMethod)) {
            httpMethod = HttpMethod.GET.toString();
        }
        documentationOperation.setHttpMethod(httpMethod);
        documentationOperation.addConsumes(getConsumes(method, methodRequestMapping));
        documentationOperation.addProduces(getProduces(method, methodRequestMapping));

        // get ApiOperation information
        ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
        if (apiOperation != null) {
            documentationOperation.setHttpMethod(apiOperation.httpMethod());
            documentationOperation.setResponseClass(apiOperation.response());
            documentationOperation.setResponseContainer(apiOperation.responseContainer());
            documentationOperation.addProduces(apiOperation.produces());
            documentationOperation.addConsumes(apiOperation.consumes());
            documentationOperation.setSummary(apiOperation.value());
            documentationOperation.setNotes(apiOperation.notes());
            documentationOperation.setPosition(apiOperation.position());
            documentationOperation.addProtocols(apiOperation.protocols());
            documentationOperation.addAuthorizations(apiOperation.authorizations());
        }

        ApiResponse apiResponse = method.getAnnotation(ApiResponse.class);
        if (apiResponse != null) {
            addResponse(documentationOperation, apiResponse);
        }

        ApiResponses apiResponses = method.getAnnotation(ApiResponses.class);
        if (apiResponses != null) {
            ApiResponse[] responses = apiResponses.value();
            for (ApiResponse response : responses) {
                addResponse(documentationOperation, response);
            }
        }

        ApiParameterParser apiParameterParser = new ApiParameterParser(ignorableAnnotations, models);
        List<Parameter> documentationParameters = apiParameterParser.parseApiParametersAndArgumentModels(method);
        documentationOperation.setParameters(documentationParameters);
        addUnusedPathVariables(documentationOperation, methodRequestMapping.value());

        return documentationOperation.toScalaOperation();
    }
View Full Code Here

    }

    private List<String> getConsumes(Method method, RequestMapping methodRequestMapping) {
        List<String> consumes = Arrays.asList(methodRequestMapping.consumes());
        if(consumes.isEmpty()) {
            RequestMapping controllerRequestMapping = method.getDeclaringClass().getAnnotation(RequestMapping.class);
            if(controllerRequestMapping != null) {
                consumes = Arrays.asList(controllerRequestMapping.consumes());
            }
        }

        return consumes;
    }
View Full Code Here

    }

    private List<String> getProduces(Method method, RequestMapping methodRequestMapping) {
        List<String> produces = Arrays.asList(methodRequestMapping.produces());
        if(produces.isEmpty()) {
            RequestMapping controllerRequestMapping = method.getDeclaringClass().getAnnotation(RequestMapping.class);
            if(controllerRequestMapping != null) {
                produces = Arrays.asList(controllerRequestMapping.produces());
            }
        }

        return produces;
    }
View Full Code Here

        }
      }
    } else {
      if (method.getReturnType().equals(Void.TYPE)) {

        RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
        RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

        String path = null;
        if (hasValue(classAnnotation)) {
          path = classAnnotation.value()[0];
        }

        if (hasValue(methodAnnotation)) {
          String methodPath = methodAnnotation.value()[0];
          if (path != null) {
View Full Code Here

        }
      }
    } else {
      if (method.getReturnType().equals(Void.TYPE)) {

        RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
        RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

        String path = null;
        if (hasValue(classAnnotation)) {
          path = classAnnotation.value()[0];
        }

        if (hasValue(methodAnnotation)) {
          String methodPath = methodAnnotation.value()[0];
          if (path != null) {
View Full Code Here

        }
      }
    } else {
      if (method.getReturnType().equals(Void.TYPE)) {

        RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
        RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

        String path = null;
        if (hasValue(classAnnotation)) {
          path = classAnnotation.value()[0];
        }

        if (hasValue(methodAnnotation)) {
          String methodPath = methodAnnotation.value()[0];
          if (path != null) {
View Full Code Here

  public MethodInfo(final Class<?> clazz, final Method method) {

    this.method = method;

    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    if (methodAnnotation != null) {

      RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

      String path = null;
      if (hasValue(classAnnotation)) {
        path = classAnnotation.value()[0];
      }

      if (hasValue(methodAnnotation)) {
        String methodPath = methodAnnotation.value()[0];
        if (path != null) {
View Full Code Here

  private boolean isValidFormPostMethod(final Class<?> clazz, final Method method) {
    if (AnnotationUtils.findAnnotation(clazz, Controller.class) == null) {
      return false;
    }

    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);

    if (methodAnnotation == null) {
      return false;
    }

    RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

    boolean hasValue = false;

    if (classAnnotation != null) {
      hasValue = (classAnnotation.value() != null && classAnnotation.value().length > 0);
    }

    if (!hasValue) {
      hasValue = (methodAnnotation.value() != null && methodAnnotation.value().length > 0);
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.bind.annotation.RequestMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.