Package org.springframework.web.method.support

Examples of org.springframework.web.method.support.CompositeUriComponentsContributor


        return annot.value()[0];
    }

    private static UriComponents applyContributors(UriComponentsBuilder builder, Method method, Object[] args) {

        CompositeUriComponentsContributor contributor = getConfiguredUriComponentsContributor();
        if (contributor == null) {
            logger.debug("Using default CompositeUriComponentsContributor");
            contributor = defaultUriComponentsContributor;
        }

        int paramCount = method.getParameterTypes().length;
        int argCount = args.length;

        Assert.isTrue(paramCount == argCount, "Number of method parameters " + paramCount +
                " does not match number of argument values " + argCount);

        Map<String, Object> uriVars = new HashMap<String, Object>();

        for (int i = 0; i < paramCount; i++) {
            MethodParameter param = new MethodParameter(method, i);
            param.initParameterNameDiscovery(parameterNameDiscoverer);
            contributor.contributeMethodArgument(param, args[i], builder, uriVars);
        }

        return builder.buildAndExpand(uriVars);
    }
View Full Code Here


    }
    return annot.value()[0];
  }

  private static UriComponents applyContributors(UriComponentsBuilder builder, Method method, Object... args) {
    CompositeUriComponentsContributor contributor = getConfiguredUriComponentsContributor();
    if (contributor == null) {
      logger.debug("Using default CompositeUriComponentsContributor");
      contributor = defaultUriComponentsContributor;
    }

    int paramCount = method.getParameterTypes().length;
    int argCount = args.length;
    if (paramCount != argCount) {
      throw new IllegalArgumentException("Number of method parameters " + paramCount +
          " does not match number of argument values " + argCount);
    }

    final Map<String, Object> uriVars = new HashMap<String, Object>();
    for (int i = 0; i < paramCount; i++) {
      MethodParameter param = new MethodParameter(method, i);
      param.initParameterNameDiscovery(parameterNameDiscoverer);
      contributor.contributeMethodArgument(param, args[i], builder, uriVars);
    }

    // We may not have all URI var values, expand only what we have
    return builder.build().expand(new UriComponents.UriTemplateVariables() {
      @Override
View Full Code Here

      this.conversionService = conversionService;
    }

    @Override
    public void afterPropertiesSet() {
      this.uriComponentsContributor = new CompositeUriComponentsContributor(
          this.handlerAdapter.getArgumentResolvers(), this.conversionService);
    }
View Full Code Here

   * Return an instance of {@link CompositeUriComponentsContributor} for use with
   * {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}.
   */
  @Bean
  public CompositeUriComponentsContributor mvcUriComponentsContributor() {
    return new CompositeUriComponentsContributor(
        requestMappingHandlerAdapter().getArgumentResolvers(), mvcConversionService());
  }
View Full Code Here

    assertSame(appContext.getBean(ConversionService.class), request.getAttribute(ConversionService.class.getName()));

    adapter.handle(request, response, handlerMethod);
    assertTrue(handler.recordedValidationError);

    CompositeUriComponentsContributor uriComponentsContributor = this.appContext.getBean(
        MvcUriComponentsBuilder.MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME,
        CompositeUriComponentsContributor.class);

    assertNotNull(uriComponentsContributor);
  }
View Full Code Here

  }

  @Test
  public void uriComponentsContributor() throws Exception {
    ApplicationContext context = initContext(WebConfig.class);
    CompositeUriComponentsContributor uriComponentsContributor = context.getBean(
        MvcUriComponentsBuilder.MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME,
        CompositeUriComponentsContributor.class);

    assertNotNull(uriComponentsContributor);
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.method.support.CompositeUriComponentsContributor

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.