Package org.springframework.web.bind.annotation

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


    public Method resolveHandlerMethod(PortletRequest request, PortletResponse response) throws PortletException {
      String lookupMode = request.getPortletMode().toString();
      Map<RequestMappingInfo, Method> targetHandlerMethods = new LinkedHashMap<RequestMappingInfo, Method>();
      for (Method handlerMethod : getHandlerMethods()) {
        RequestMapping mapping = AnnotationUtils.findAnnotation(handlerMethod, RequestMapping.class);
        RequestMappingInfo mappingInfo = new RequestMappingInfo();
        mappingInfo.modes = mapping.value();
        mappingInfo.params = mapping.params();
        mappingInfo.action = isActionMethod(handlerMethod);
        mappingInfo.render = isRenderMethod(handlerMethod);
        boolean match = false;
        if (mappingInfo.modes.length > 0) {
          for (String mappedMode : mappingInfo.modes) {
View Full Code Here


    for (String beanName : beanNames) {
      Class<?> handlerType = context.getType(beanName);
      ListableBeanFactory bf = (context instanceof ConfigurableApplicationContext ?
          ((ConfigurableApplicationContext) context).getBeanFactory() : context);
      GenericBeanFactoryAccessor bfa = new GenericBeanFactoryAccessor(bf);
      RequestMapping mapping = bfa.findAnnotationOnBean(beanName, RequestMapping.class);
      if (mapping != null) {
        String[] modeKeys = mapping.value();
        String[] params = mapping.params();
        boolean registerHandlerType = true;
        if (modeKeys.length == 0 || params.length == 0) {
          registerHandlerType = !detectHandlerMethods(handlerType, beanName, mapping);
        }
        if (registerHandlerType) {
View Full Code Here

   */
  protected boolean detectHandlerMethods(Class handlerType, final String beanName, final RequestMapping typeMapping) {
    final Set<Boolean> handlersRegistered = new HashSet<Boolean>(1);
    ReflectionUtils.doWithMethods(handlerType, new ReflectionUtils.MethodCallback() {
      public void doWith(Method method) {
        RequestMapping mapping = method.getAnnotation(RequestMapping.class);
        if (mapping != null) {
          String[] modeKeys = mapping.value();
          if (modeKeys.length == 0) {
            if (typeMapping != null) {
              modeKeys = typeMapping.value();
            }
            else {
              throw new IllegalStateException(
                  "No portlet mode mappings specified - neither at type nor method level");
            }
          }
          String[] params = mapping.params();
          if (typeMapping != null) {
            PortletAnnotationMappingUtils.validateModeMapping(modeKeys, typeMapping.value());
            params = StringUtils.mergeStringArrays(typeMapping.params(), params);
          }
          ParameterMappingPredicate predicate = new ParameterMappingPredicate(params);
View Full Code Here

      Map<RequestMappingInfo, Method> targetHandlerMethods = new LinkedHashMap<RequestMappingInfo, Method>();
      Map<RequestMappingInfo, String> targetPathMatches = new LinkedHashMap<RequestMappingInfo, String>();
      String resolvedMethodName = null;
      for (Method handlerMethod : getHandlerMethods()) {
        RequestMappingInfo mappingInfo = new RequestMappingInfo();
        RequestMapping mapping = AnnotationUtils.findAnnotation(handlerMethod, RequestMapping.class);
        mappingInfo.paths = mapping.value();
        if (!hasTypeLevelMapping() || !Arrays.equals(mapping.method(), getTypeLevelMapping().method())) {
          mappingInfo.methods = mapping.method();
        }
        if (!hasTypeLevelMapping() || !Arrays.equals(mapping.params(), getTypeLevelMapping().params())) {
          mappingInfo.params = mapping.params();
        }
        boolean match = false;
        if (mappingInfo.paths.length > 0) {
          for (String mappedPath : mappingInfo.paths) {
            if (isPathMatch(mappedPath, lookupPath)) {
View Full Code Here

    ApplicationContext context = getApplicationContext();
    Class<?> handlerType = context.getType(beanName);
    ListableBeanFactory bf = (context instanceof ConfigurableApplicationContext ?
        ((ConfigurableApplicationContext) context).getBeanFactory() : context);
    GenericBeanFactoryAccessor bfa = new GenericBeanFactoryAccessor(bf);
    RequestMapping mapping = bfa.findAnnotationOnBean(beanName, RequestMapping.class);

    if (mapping != null) {
      // @RequestMapping found at type level
      this.cachedMappings.put(handlerType, mapping);
      Set<String> urls = new LinkedHashSet<String>();
      String[] paths = mapping.value();
      if (paths.length > 0) {
        // @RequestMapping specifies paths at type level
        for (String path : paths) {
          addUrlsForPath(urls, path);
        }
View Full Code Here

   */
  protected String[] determineUrlsForHandlerMethods(Class<?> handlerType) {
    final Set<String> urls = new LinkedHashSet<String>();
    ReflectionUtils.doWithMethods(handlerType, new ReflectionUtils.MethodCallback() {
      public void doWith(Method method) {
        RequestMapping mapping = method.getAnnotation(RequestMapping.class);
        if (mapping != null) {
          String[] mappedPaths = mapping.value();
          for (int i = 0; i < mappedPaths.length; i++) {
            addUrlsForPath(urls, mappedPaths[i]);
          }
        }
      }
View Full Code Here

  /**
   * Validate the given annotated handler against the current request.
   * @see #validateMapping
   */
  protected void validateHandler(Object handler, HttpServletRequest request) throws Exception {
    RequestMapping mapping = this.cachedMappings.get(handler.getClass());
    if (mapping == null) {
      mapping = AnnotationUtils.findAnnotation(handler.getClass(), RequestMapping.class);
    }
    if (mapping != null) {
      validateMapping(mapping, request);
View Full Code Here

            for (Method interfaceMethod : methods) {
                Method method = BridgeMethodResolver.findBridgedMethod(interfaceMethod);
                Class<?> responseClazz = method.getReturnType();

                RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
                RestRequestResource restRequestResource = AnnotationUtils.findAnnotation(method, RestRequestResource.class);
                boolean export = (restRequestResource != null ? restRequestResource.export() : true);

                // if the method declaring class is in the parent, get the return type from the service or converter (because of erasure)
                if (!marshallingServiceClass.equals(method.getDeclaringClass())) {
                    String restRequestResourceMethodName = (restRequestResource != null ? restRequestResource.methodName() : null);
                    String methodName = (StringUtils.hasText(restRequestResourceMethodName) ? restRequestResourceMethodName : method.getName());
                    Class<?>[] paramTypes = method.getParameterTypes();

                    try {
                        Method serviceMethod = ReflectionUtils.findMethod(serviceClass, methodName, paramTypes);
                        responseClazz = serviceMethod.getReturnType();
                    } catch(IllegalStateException e) {
                    }
                }

                if (export) {
                    boolean relative = (restRequestResource != null ? restRequestResource.relative() : true);

                    // just get first param if more than one
                    StringBuilder uri = new StringBuilder();

                    if (relative) {
                        for (String pattern : requestMapping.value()) {
                            // add REST resource path prefix to URI,
                            // if relative path is just '/' add an empty string
                            uri.append(restResource.path());
                            uri.append((!"/".equals(pattern) ? pattern : ""));

                            break;
                        }
                    } else {
                        uri.append(requestMapping.value()[0]);
                    }

                    String[] params = requestMapping.params();

                    if (params != null && params.length > 0) {
                        uri.append("?");

                        for (int i = 0; i < params.length; i++) {
                            String param = params[i];

                            uri.append(param);
                            uri.append("={");
                            uri.append(param);
                            uri.append("}");

                            if (i < (params.length - 1)) {
                                uri.append("&");
                            }
                        }
                    }

                    RequestMethod requestMethod = requestMapping.method()[0];

                    if (RequestMethod.POST.equals(requestMethod) || RequestMethod.PUT.equals(requestMethod)
                            || RequestMethod.DELETE.equals(requestMethod)) {
                        responseClazz = restResource.responseClass();
                    }
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 {
      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

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.