Package org.springframework.web.bind.annotation

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


  protected void detectHandlers() throws BeansException {
    String[] beanNames = getApplicationContext().getBeanNamesForType(Object.class);
    for (String beanName : beanNames) {
      ApplicationContext context = getApplicationContext();
      Class<?> handlerType = context.getType(beanName);
      RequestMapping mapping = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
      if (mapping == null && context instanceof ConfigurableApplicationContext &&
          context.containsBeanDefinition(beanName)) {
        ConfigurableApplicationContext cac = (ConfigurableApplicationContext) context;
        BeanDefinition bd = cac.getBeanFactory().getMergedBeanDefinition(beanName);
        if (bd instanceof AbstractBeanDefinition) {
          AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
          if (abd.hasBeanClass()) {
            Class<?> beanClass = abd.getBeanClass();
            mapping = AnnotationUtils.findAnnotation(beanClass, 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

   * annotation on the handler class and on any of its methods.
   */
  protected String[] determineUrlsForHandler(String beanName) {
    ApplicationContext context = getApplicationContext();
    Class<?> handlerType = context.getType(beanName);
    RequestMapping mapping = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);

    if (mapping == null && context instanceof ConfigurableApplicationContext &&
        context.containsBeanDefinition(beanName)) {
      ConfigurableApplicationContext cac = (ConfigurableApplicationContext) context;
      BeanDefinition bd = cac.getBeanFactory().getMergedBeanDefinition(beanName);
      if (bd instanceof AbstractBeanDefinition) {
        AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
        if (abd.hasBeanClass()) {
          Class<?> beanClass = abd.getBeanClass();
          mapping = AnnotationUtils.findAnnotation(beanClass, 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

    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

  public MethodInfo(final Method method) {

    this.method = method;

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

      RequestMapping classAnnotation = AnnotationUtils.findAnnotation(method.getDeclaringClass(),
          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

    @Override
    protected boolean isHandlerMethod(Method method) {
      if (this.mappings.containsKey(method)) {
        return true;
      }
      RequestMapping mapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
      if (mapping != null) {
        RequestMappingInfo mappingInfo = new RequestMappingInfo();
        mappingInfo.patterns = 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();
        }
        if (!hasTypeLevelMapping() || !Arrays.equals(mapping.headers(), getTypeLevelMapping().headers())) {
          mappingInfo.headers = mapping.headers();
        }
        this.mappings.put(method, mappingInfo);
        return true;
      }
      return false;
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

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.