Package org.springframework.web.bind.annotation

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


   */
  public static ControllerLinkBuilder linkTo(Class<?> controller, Object... parameters) {

    Assert.notNull(controller);

    RequestMapping annotation = AnnotationUtils.findAnnotation(controller, RequestMapping.class);
    String[] mapping = annotation == null ? new String[0] : (String[]) AnnotationUtils.getValue(annotation);

    if (mapping.length > 1) {
      throw new IllegalStateException("Multiple controller mappings defined! Unable to build URI!");
    }
View Full Code Here


    //================================================ Helper Methods ==================================================

    protected String[] resolvePaths(String className) {
        Class clazz = loadClass(className);
        RequestMapping path = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);
        if (path == null) {
            String value = resolvePathFromServiceInterface(clazz);
            if (value == null) {
                throw new FatalBeanException("Could not resolve GWT remote service path - either define a @RemoteServiceRelativePath annotation on the" +
                        "remote service interface or define a @RequestMapping annotation on the service '" +
                        clazz.getName() + "' class hierarchy");
            }
            return new String[] { value };
        }
        return path.value();
    }
View Full Code Here

    if(widgetConfig!=null) {
      String requestPath = widgetConfig.getPath();
      if(!permissionMappings.containsKey(requestPath)) {
        HandlerMethodResolver handlerMethodResolver = new HandlerMethodResolver();
        handlerMethodResolver.init(handler.getClass());
        RequestMapping classRequestMapping = AnnotationUtils.findAnnotation(handler.getClass(), RequestMapping.class);
        String[] namespaces = classRequestMapping.value();
        Iterator<Method> iter = handlerMethodResolver.getHandlerMethods().iterator();
        while(iter.hasNext()) {
          Method method = iter.next();
          RequestMapping methodRequestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
          String[] paths = methodRequestMapping.value();
          List<String> mappingPaths = buildMappingPaths(namespaces, paths);
          Permission permission = AnnotationUtils.findAnnotation(method, Permission.class);
          for(String mappingPath : mappingPaths) {
            permissionMappings.put(mappingPath, permission);
          }
View Full Code Here

  protected void detectHandlers() throws BeansException {
    ApplicationContext context = getApplicationContext();
    String[] beanNames = context.getBeanNamesForType(Object.class);
    for (String beanName : beanNames) {
      Class<?> handlerType = context.getType(beanName);
      RequestMapping mapping = context.findAnnotationOnBean(beanName, RequestMapping.class);
      if (mapping != null) {
        // @RequestMapping found at type level
        this.cachedMappings.put(handlerType, mapping);
        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) {
          AbstractParameterMappingPredicate predicate = new TypeLevelMappingPredicate(
              params, mapping.headers(), mapping.method());
          for (String modeKey : modeKeys) {
            registerHandler(new PortletMode(modeKey), beanName, predicate);
          }
        }
      }
View Full Code Here

          }
          ActionMapping actionMapping = AnnotationUtils.findAnnotation(method, ActionMapping.class);
          RenderMapping renderMapping = AnnotationUtils.findAnnotation(method, RenderMapping.class);
          ResourceMapping resourceMapping = AnnotationUtils.findAnnotation(method, ResourceMapping.class);
          EventMapping eventMapping = AnnotationUtils.findAnnotation(method, EventMapping.class);
          RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
          if (actionMapping != null) {
            params = StringUtils.mergeStringArrays(params, actionMapping.params());
            predicate = new ActionMappingPredicate(actionMapping.value(), params);
          }
          else if (renderMapping != null) {
            params = StringUtils.mergeStringArrays(params, renderMapping.params());
            predicate = new RenderMappingPredicate(renderMapping.value(), params);
          }
          else if (resourceMapping != null) {
            predicate = new ResourceMappingPredicate(resourceMapping.value());
          }
          else if (eventMapping != null) {
            predicate = new EventMappingPredicate(eventMapping.value());
          }
          if (requestMapping != null) {
            modeKeys = requestMapping.value();
            if (typeMapping != null) {
              if (!PortletAnnotationMappingUtils.validateModeMapping(modeKeys, typeMapping.value())) {
                throw new IllegalStateException("Mode mappings conflict between method and type level: " +
                    Arrays.asList(modeKeys) + " versus " + Arrays.asList(typeMapping.value()));
              }
            }
            params = StringUtils.mergeStringArrays(params, requestMapping.params());
            if (predicate == null) {
              predicate = new MethodLevelMappingPredicate(params);
            }
          }
          if (predicate != null) {
View Full Code Here

  /**
   * Validate the given annotated handler against the current request.
   * @see #validateMapping
   */
  protected void validateHandler(Object handler, PortletRequest 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

   * @see #getCustomTypeCondition(Class)
   */
  @Override
  protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
    RequestMappingInfo info = null;
    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    if (methodAnnotation != null) {
      RequestCondition<?> methodCondition = getCustomMethodCondition(method);
      info = createRequestMappingInfo(methodAnnotation, methodCondition);
      RequestMapping typeAnnotation = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
      if (typeAnnotation != null) {
        RequestCondition<?> typeCondition = getCustomTypeCondition(handlerType);
        info = createRequestMappingInfo(typeAnnotation, typeCondition).combine(info);
      }
    }
View Full Code Here

   * @see #getCustomTypeCondition(Class)
   */
  @Override
  protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
    RequestMappingInfo info = null;
    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    if (methodAnnotation != null) {
      RequestCondition<?> methodCondition = getCustomMethodCondition(method);
      info = createRequestMappingInfo(methodAnnotation, methodCondition);
      RequestMapping typeAnnotation = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
      if (typeAnnotation != null) {
        RequestCondition<?> typeCondition = getCustomTypeCondition(handlerType);
        info = createRequestMappingInfo(typeAnnotation, typeCondition).combine(info);
      }
    }
View Full Code Here

   */
  @Override
  protected String[] determineUrlsForHandler(String beanName) {
    ApplicationContext context = getApplicationContext();
    Class<?> handlerType = context.getType(beanName);
    RequestMapping mapping = context.findAnnotationOnBean(beanName, RequestMapping.class);
    if (mapping != null) {
      // @RequestMapping found at type level
      this.cachedMappings.put(handlerType, mapping);
      Set<String> urls = new LinkedHashSet<String>();
      String[] typeLevelPatterns = mapping.value();
      if (typeLevelPatterns.length > 0) {
        // @RequestMapping specifies paths at type level
        String[] methodLevelPatterns = determineUrlsForHandlerMethods(handlerType, true);
        for (String typeLevelPattern : typeLevelPatterns) {
          if (!typeLevelPattern.startsWith("/")) {
View Full Code Here

    handlerTypes.add(handlerType);
    handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces()));
    for (Class<?> currentHandlerType : handlerTypes) {
      ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() {
        public void doWith(Method method) {
          RequestMapping mapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
          if (mapping != null) {
            String[] mappedPatterns = mapping.value();
            if (mappedPatterns.length > 0) {
              for (String mappedPattern : mappedPatterns) {
                if (!hasTypeLevelMapping && !mappedPattern.startsWith("/")) {
                  mappedPattern = "/" + mappedPattern;
                }
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.