Package org.springframework.core

Examples of org.springframework.core.ParameterNameDiscoverer


        if (factoryMethod.getTypeParameters().length > 0) {
          try {
            // Fully resolve parameter names and argument values.
            Class<?>[] paramTypes = factoryMethod.getParameterTypes();
            String[] paramNames = null;
            ParameterNameDiscoverer pnd = getParameterNameDiscoverer();
            if (pnd != null) {
              paramNames = pnd.getParameterNames(factoryMethod);
            }
            ConstructorArgumentValues cav = mbd.getConstructorArgumentValues();
            Set<ConstructorArgumentValues.ValueHolder> usedValueHolders =
                new HashSet<ConstructorArgumentValues.ValueHolder>(paramTypes.length);
            Object[] args = new Object[paramTypes.length];
View Full Code Here


          ClassUtils.forName("javax.validation.ParameterNameProvider", getClass().getClassLoader());
      Method parameterNameProviderMethod =
          Configuration.class.getMethod("parameterNameProvider", parameterNameProviderClass);
      final Object defaultProvider = ReflectionUtils.invokeMethod(
          Configuration.class.getMethod("getDefaultParameterNameProvider"), configuration);
      final ParameterNameDiscoverer discoverer = this.parameterNameDiscoverer;
      Object parameterNameProvider = Proxy.newProxyInstance(getClass().getClassLoader(),
          new Class<?>[] {parameterNameProviderClass}, new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
          if (method.getName().equals("getParameterNames")) {
            String[] result = null;
            if (args[0] instanceof Constructor) {
              result = discoverer.getParameterNames((Constructor<?>) args[0]);
            }
            else if (args[0] instanceof Method) {
              result = discoverer.getParameterNames((Method) args[0]);
            }
            if (result != null) {
              return Arrays.asList(result);
            }
            else {
View Full Code Here

   * @param beanKey the key associated with the MBean in the beans map
   * of the {@code MBeanExporter}
   * @return the {@code MBeanParameterInfo} array
   */
  protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey) {
    ParameterNameDiscoverer paramNameDiscoverer = getParameterNameDiscoverer();
    String[] paramNames = (paramNameDiscoverer != null ? paramNameDiscoverer.getParameterNames(method) : null);
    if (paramNames == null) {
      return new MBeanParameterInfo[0];
    }

    MBeanParameterInfo[] info = new MBeanParameterInfo[paramNames.length];
View Full Code Here

  @Before
  public void setUp() throws Exception {
    resolver = new RequestParamMethodArgumentResolver(null, true);

    ParameterNameDiscoverer paramNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();

    Method method = getClass().getMethod("params", String.class, String[].class,
        Map.class, MultipartFile.class, List.class, MultipartFile[].class,
        Part.class, List.class, Part[].class, Map.class,
        String.class, MultipartFile.class, List.class, Part.class,
View Full Code Here

            String[] paramNames = null;
            if (constructorPropertiesAnnotationAvailable) {
              paramNames = ConstructorPropertiesChecker.evaluateAnnotation(candidate, paramTypes.length);
            }
            if (paramNames == null) {
              ParameterNameDiscoverer pnd = this.beanFactory.getParameterNameDiscoverer();
              if (pnd != null) {
                paramNames = pnd.getParameterNames(candidate);
              }
            }
            args = createArgumentArray(
                beanName, mbd, resolvedValues, bw, paramTypes, paramNames, candidate, autowiring);
          }
View Full Code Here

          if (resolvedValues != null) {
            // Resolved constructor arguments: type conversion and/or autowiring necessary.
            try {
              String[] paramNames = null;
              ParameterNameDiscoverer pnd = this.beanFactory.getParameterNameDiscoverer();
              if (pnd != null) {
                paramNames = pnd.getParameterNames(candidate);
              }
              args = createArgumentArray(
                  beanName, mbd, resolvedValues, bw, paramTypes, paramNames, candidate, autowiring);
            }
            catch (UnsatisfiedDependencyException ex) {
View Full Code Here

            String[] paramNames = null;
            if (constructorPropertiesAnnotationAvailable) {
              paramNames = ConstructorPropertiesChecker.evaluateAnnotation(candidate, paramTypes.length);
            }
            if (paramNames == null) {
              ParameterNameDiscoverer pnd = this.beanFactory.getParameterNameDiscoverer();
              if (pnd != null) {
                paramNames = pnd.getParameterNames(candidate);
              }
            }
            argsHolder = createArgumentArray(
                beanName, mbd, resolvedValues, bw, paramTypes, paramNames, candidate, autowiring);
          }
View Full Code Here

          if (resolvedValues != null) {
            // Resolved constructor arguments: type conversion and/or autowiring necessary.
            try {
              String[] paramNames = null;
              ParameterNameDiscoverer pnd = this.beanFactory.getParameterNameDiscoverer();
              if (pnd != null) {
                paramNames = pnd.getParameterNames(candidate);
              }
              argsHolder = createArgumentArray(
                  beanName, mbd, resolvedValues, bw, paramTypes, paramNames, candidate, autowiring);
            }
            catch (UnsatisfiedDependencyException ex) {
View Full Code Here

    this.builder.build(this.nativeRequest, source);
  }

  @Test
  public void shouldNeedPathVaraibleName() throws Exception {
    ParameterNameDiscoverer parameterNameDiscoverer = mock(ParameterNameDiscoverer.class);
    given(this.context.getParameterNameDiscoverer()).willReturn(parameterNameDiscoverer);
    given(parameterNameDiscoverer.getParameterNames(any(Method.class))).willReturn(null);
    Map<String, String> source = new HashMap<String, String>();
    source.put("pv1", "1");
    setHandlerMethod("pathVariable");
    this.thrown.expect(IllegalStateException.class);
    this.thrown.expectMessage("No parameter name specified for argument of type [java.lang.String], and "
View Full Code Here

    verify(webBindingInitializer).initBinder(any(WebDataBinder.class), any(WebRequest.class));
  }

  @Test
  public void shouldNeedNameForSimpleRequestParamType() throws Exception {
    ParameterNameDiscoverer parameterNameDiscoverer = mock(ParameterNameDiscoverer.class);
    given(this.context.getParameterNameDiscoverer()).willReturn(parameterNameDiscoverer);
    given(parameterNameDiscoverer.getParameterNames(any(Method.class))).willReturn(null);
    Map<String, String> source = new HashMap<String, String>();
    source.put("xa", "1");
    setHandlerMethod("requestParamNotNamed");
    this.thrown.expect(IllegalStateException.class);
    this.thrown.expectMessage("No parameter name specified for argument of type [java.lang.String], and "
View Full Code Here

TOP

Related Classes of org.springframework.core.ParameterNameDiscoverer

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.