/** * Constructor for JobMethodInvocationFailedException. * @param methodInvoker the MethodInvoker used for reflective invocation * @param cause the root cause (as thrown from the target method) */ public JobMethodInvocationFailedException(MethodInvoker methodInvoker, Throwable cause) { super("Invocation of method '" + methodInvoker.getTargetMethod() + "' on target class [" + methodInvoker.getTargetClass() + "] failed", cause); }
/** * Constructor for JobMethodInvocationFailedException. * @param methodInvoker the MethodInvoker used for reflective invocation * @param cause the root cause (as thrown from the target method) */ public JobMethodInvocationFailedException(MethodInvoker methodInvoker, Throwable cause) { super("Invocation of method '" + methodInvoker.getTargetMethod() + "' on target class [" + methodInvoker.getTargetClass() + "] failed", cause); }
Class<?> targetClass = getTargetClass(); String targetMethod = getTargetMethod(); Assert.notNull(targetClass, "Either 'targetClass' or 'targetObject' is required");
int argCount = arguments.length; Class<?> targetClass = getTargetClass(); Assert.state(targetClass != null, "No target class set"); Method[] candidates = ReflectionUtils.getAllDeclaredMethods(targetClass);
MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod); Method[] memberMethods = invoker.getTargetClass().getMethods(); Method[] declaredMethods = invoker.getTargetClass().getDeclaredMethods();
Class<?> targetClass = getTargetClass(); String targetMethod = getTargetMethod(); Assert.notNull(targetClass, "Either 'targetClass' or 'targetObject' is required");
int argCount = arguments.length; Class<?> targetClass = getTargetClass(); Assert.state(targetClass != null, "No target class set"); Method[] candidates = ReflectionUtils.getAllDeclaredMethods(targetClass);
Class targetClass = getTargetClass(); String targetMethod = getTargetMethod(); if (targetClass == null) {
/** * Find a matching method with the specified name for the specified arguments. * @return a matching method, or <code>null</code> if none * @see #getTargetClass() * @see #getTargetMethod() * @see #getArguments() */ protected Method findMatchingMethod() { String targetMethod = getTargetMethod(); Object[] arguments = getArguments(); int argCount = arguments.length; Method[] candidates = ReflectionUtils.getAllDeclaredMethods(getTargetClass()); int minTypeDiffWeight = Integer.MAX_VALUE; Method matchingMethod = null; for (Method candidate : candidates) { if (candidate.getName().equals(targetMethod)) { Class[] paramTypes = candidate.getParameterTypes(); if (paramTypes.length == argCount) { int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments); if (typeDiffWeight < minTypeDiffWeight) { minTypeDiffWeight = typeDiffWeight; matchingMethod = candidate; } } } } return matchingMethod; }
/** * Constructor for JobMethodInvocationFailedException. * @param methodInvoker the MethodInvoker used for reflective invocation * @param cause the root cause (as thrown from the target method) */ public JobMethodInvocationFailedException(MethodInvoker methodInvoker, Throwable cause) { super("Invocation of method '" + methodInvoker.getTargetMethod() + "' on target class [" + methodInvoker.getTargetClass() + "] failed", cause); }
/** * Find a matching method with the specified name for the specified arguments. * @return a matching method, or <code>null</code> if none * @see #getTargetClass() * @see #getTargetMethod() * @see #getArguments() */ protected Method findMatchingMethod() { Method[] candidates = getTargetClass().getMethods(); int argCount = getArguments().length; Method matchingMethod = null; int numberOfMatchingMethods = 0; for (int i = 0; i < candidates.length; i++) { // Check if the inspected method has the correct name and number of parameters. if (candidates[i].getName().equals(getTargetMethod()) && candidates[i].getParameterTypes().length == argCount) { matchingMethod = candidates[i]; numberOfMatchingMethods++; } } // Only return matching method if exactly one found. if (numberOfMatchingMethods == 1) { return matchingMethod; } else { return null; } }
MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod); Method[] memberMethods = invoker.getTargetClass().getMethods(); Method[] declaredMethods = invoker.getTargetClass().getDeclaredMethods();
Class<?> targetClass = getTargetClass(); String targetMethod = getTargetMethod(); Assert.notNull(targetClass, "Either 'targetClass' or 'targetObject' is required");
int argCount = arguments.length; Class<?> targetClass = getTargetClass(); Assert.state(targetClass != null, "No target class set"); Method[] candidates = ReflectionUtils.getAllDeclaredMethods(targetClass);