List of usage examples for org.apache.commons.lang.reflect MethodUtils getAccessibleMethod
public static Method getAccessibleMethod(Method method)
Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method.
From source file:org.sglj.service.rmi.RmiUtils.java
public static Method getMatchingAccessibleMethod(Class<?> cls, String methodName, Class<?>[] parameterTypes, Collection<Method> callableMethods) { try {/* ww w.j av a2 s.co m*/ return cls.getMethod(methodName, parameterTypes); } catch (NoSuchMethodException e) { /* SWALLOW */ } // search through all methods Method bestMatch = null; for (Method method : callableMethods) { if (method.getName().equals(methodName)) { // compare parameters if (ClassUtils.isAssignable(parameterTypes, method.getParameterTypes(), true)) { // get accessible version of method Method accessibleMethod = MethodUtils.getAccessibleMethod(method); if (accessibleMethod != null) { if (bestMatch == null || compareParameterTypes(accessibleMethod.getParameterTypes(), bestMatch.getParameterTypes(), parameterTypes) < 0) { bestMatch = accessibleMethod; } } } } } return bestMatch; }