本文整理汇总了Java中org.apache.commons.lang3.ClassUtils.getPublicMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ClassUtils.getPublicMethod方法的具体用法?Java ClassUtils.getPublicMethod怎么用?Java ClassUtils.getPublicMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.ClassUtils
的用法示例。
在下文中一共展示了ClassUtils.getPublicMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: objectGetterGet
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* Returns the value of the object getter it there is any for the wrapped java object.
*
* @param key Key that should be searched using the object getter.
* @return Value of the property of the wrapped java object
*/
protected Object objectGetterGet(Object key) {
Method method = null;
Object result = Scriptable.NOT_FOUND;
if (object instanceof ObjectGetter) {
Object value = ((ObjectGetter)object).get(key);
try {
method = ClassUtils.getPublicMethod(objectClass, ObjectGetter.METHOD_NAME, ObjectGetter.METHOD_ARG_TYPES);
} catch (Exception e) {
throw new InternalException(e);
}
if (value != ObjectGetter.UNDEFINED_VALUE) {
result = value;
}
}
if (result != Scriptable.NOT_FOUND && method != null) {
//result = new JavaMethodRedirectedWrapper(result, object, method);
}
return result;
}
示例2: getObjectGetterMetod
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* Returns method of the class that equals to the object getter method.
*
* @param clazz Class which should contain the object getter method.
* @return Object getter method.
*/
private static Method getObjectGetterMetod(Class<?> clazz) {
try {
return ClassUtils.getPublicMethod(clazz, ObjectGetter.METHOD_NAME, ObjectGetter.METHOD_ARG_TYPES);
} catch (Exception e) {
throw new InternalException(e);
}
}
示例3: invoke
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* Invoke a public method on a class instance
*
* @param instance
* object on which the method should be called
* @param methodName
* name of the method to be called
* @throws SecurityException
* if a security violation occurred while looking for the method
* @throws IllegalArgumentException
* if the method parameters (none given) do not match the
* signature of the method
* @throws JMeterException
* if something went wrong in the invoked method
*/
public static void invoke(Object instance, String methodName)
throws SecurityException, IllegalArgumentException, JMeterException
{
Method m;
try {
m = ClassUtils.getPublicMethod(instance.getClass(), methodName, new Class [] {});
m.invoke(instance, (Object [])null);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new JMeterException(e);
}
}