List of usage examples for org.springframework.util ReflectionUtils getAllDeclaredMethods
public static Method[] getAllDeclaredMethods(Class<?> leafClass)
From source file:org.kuali.rice.krad.uif.component.MethodInvokerConfig.java
/** * Finds the method on the target class that matches the target name and * returns the declared parameter types/*from ww w . j a va2 s .c o m*/ * * @return method parameter types */ protected Class[] getMethodArgumentTypes() { if (StringUtils.isNotBlank(staticMethod)) { int lastDotIndex = this.staticMethod.lastIndexOf('.'); if (lastDotIndex == -1 || lastDotIndex == this.staticMethod.length()) { throw new IllegalArgumentException("staticMethod must be a fully qualified class plus method name: " + "e.g. 'example.MyExampleClass.myExampleMethod'"); } String className = this.staticMethod.substring(0, lastDotIndex); String methodName = this.staticMethod.substring(lastDotIndex + 1); try { setTargetClass(resolveClassName(className)); } catch (ClassNotFoundException e) { throw new RuntimeException("Unable to get class for name: " + className); } setTargetMethod(methodName); } Method matchingCandidate = findMatchingMethod(); if (matchingCandidate != null) { return matchingCandidate.getParameterTypes(); } Method[] candidates = ReflectionUtils.getAllDeclaredMethods(getTargetClass()); for (Method candidate : candidates) { if (candidate.getName().equals(getTargetMethod())) { return candidate.getParameterTypes(); } } return null; }
From source file:org.springframework.beans.factory.support.ConstructorResolver.java
/** * Retrieve all candidate methods for the given class, considering * the {@link RootBeanDefinition#isNonPublicAccessAllowed()} flag. * Called as the starting point for factory method determination. *///w w w. j a v a 2 s. com private Method[] getCandidateMethods(final Class<?> factoryClass, final RootBeanDefinition mbd) { if (System.getSecurityManager() != null) { return AccessController.doPrivileged((PrivilegedAction<Method[]>) () -> (mbd.isNonPublicAccessAllowed() ? ReflectionUtils.getAllDeclaredMethods(factoryClass) : factoryClass.getMethods())); } else { return (mbd.isNonPublicAccessAllowed() ? ReflectionUtils.getAllDeclaredMethods(factoryClass) : factoryClass.getMethods()); } }
From source file:org.springframework.integration.handler.support.MessagingMethodInvokerHelper.java
private boolean canReturnExpectedType(AnnotatedMethodFilter filter, Class<?> targetType, TypeConverter typeConverter) {/* ww w . j av a 2s.c o m*/ if (this.expectedType == null) { return true; } List<Method> methods = filter.filter(Arrays.asList(ReflectionUtils.getAllDeclaredMethods(targetType))); for (Method method : methods) { if (typeConverter.canConvert(TypeDescriptor.valueOf(method.getReturnType()), this.expectedType)) { return true; } } return false; }
From source file:org.springframework.integration.util.MessagingMethodInvokerHelper.java
private boolean canReturnExpectedType(AnnotatedMethodFilter filter, Class<?> targetType, TypeConverter typeConverter) {/*from www. j av a 2 s. com*/ if (expectedType == null) { return true; } List<Method> methods = filter.filter(Arrays.asList(ReflectionUtils.getAllDeclaredMethods(targetType))); for (Method method : methods) { if (typeConverter.canConvert(TypeDescriptor.valueOf(method.getReturnType()), TypeDescriptor.valueOf(expectedType))) { return true; } } return false; }