private Object resolveParameter(
      Parameter parameter, MethodInvocationContext methodInvocationContext)
      throws ParameterResolutionException {

    try {
      final List<MethodParameterResolver> matchingResolvers = new ArrayList<>();
      extensionRegistry
          .stream(MethodParameterResolver.class, ApplicationOrder.FORWARD)
          .forEach(
              registeredExtensionPoint -> {
                if (registeredExtensionPoint
                    .getExtensionPoint()
                    .supports(parameter, methodInvocationContext, extensionContext))
                  matchingResolvers.add(registeredExtensionPoint.getExtensionPoint());
              });

      if (matchingResolvers.size() == 0) {
        throw new ParameterResolutionException(
            String.format(
                "No MethodParameterResolver registered for parameter [%s] in method [%s].",
                parameter, methodInvocationContext.getMethod().toGenericString()));
      }
      if (matchingResolvers.size() > 1) {
        // @formatter:off
        String resolverNames =
            matchingResolvers
                .stream()
                .map(resolver -> resolver.getClass().getName())
                .collect(joining(", "));
        // @formatter:on
        throw new ParameterResolutionException(
            String.format(
                "Discovered multiple competing MethodParameterResolvers for parameter [%s] in method [%s]: %s",
                parameter, methodInvocationContext.getMethod().toGenericString(), resolverNames));
      }
      return matchingResolvers.get(0).resolve(parameter, methodInvocationContext, extensionContext);
    } catch (Throwable ex) {
      if (ex instanceof ParameterResolutionException) {
        throw (ParameterResolutionException) ex;
      }
      throw new ParameterResolutionException(
          String.format(
              "Failed to resolve parameter [%s] in method [%s]",
              parameter, methodInvocationContext.getMethod().toGenericString()),
          ex);
    }
  }
 /**
  * Resolve the array of parameters for the configured method.
  *
  * @return the array of Objects to be used as parameters in the method invocation; never {@code
  *     null} though potentially empty
  */
 private Object[] resolveParameters(MethodInvocationContext methodInvocationContext)
     throws ParameterResolutionException {
   // @formatter:off
   return Arrays.stream(methodInvocationContext.getMethod().getParameters())
       .map(param -> resolveParameter(param, methodInvocationContext))
       .toArray(Object[]::new);
   // @formatter:on
 }
 public Object invoke(MethodInvocationContext methodInvocationContext) {
   return ReflectionUtils.invokeMethod(
       methodInvocationContext.getMethod(),
       methodInvocationContext.getInstance(),
       resolveParameters(methodInvocationContext));
 }