本文整理汇总了Java中org.kuali.rice.krad.uif.component.MethodInvokerConfig.setTargetMethod方法的典型用法代码示例。如果您正苦于以下问题:Java MethodInvokerConfig.setTargetMethod方法的具体用法?Java MethodInvokerConfig.setTargetMethod怎么用?Java MethodInvokerConfig.setTargetMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.uif.component.MethodInvokerConfig
的用法示例。
在下文中一共展示了MethodInvokerConfig.setTargetMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkGetArgumentTypes
import org.kuali.rice.krad.uif.component.MethodInvokerConfig; //导入方法依赖的package包/类
protected void checkGetArgumentTypes(Class targetClass, String methodName, int argumentTypeSize, int expectedSize) {
MethodInvokerConfig methodInvokerConfig = new MethodInvokerConfig();
methodInvokerConfig.setTargetClass(targetClass);
methodInvokerConfig.setTargetMethod(methodName);
methodInvokerConfig.setArguments(new Object[argumentTypeSize]);
Class[] classes = methodInvokerConfig.getArgumentTypes();
Assert.assertEquals("Should return " + argumentTypeSize + " classes", expectedSize, classes.length);
}
示例2: invokeBusinessRuleMethod
import org.kuali.rice.krad.uif.component.MethodInvokerConfig; //导入方法依赖的package包/类
/**
* local helper method to invoke the business rule method
*
* @param rule the business rule class that the method to invoke belongs to
* @param event the document event the rule applies to
* @return a boolean to indicate whether the method invocation was a succes or not
*/
public boolean invokeBusinessRuleMethod(BusinessRule rule, DocumentEvent event) {
boolean success = true;
String methodName = event.getRuleMethodName();
MethodInvokerConfig methodInvoker = new MethodInvokerConfig();
methodInvoker.setTargetClass(rule.getClass());
methodInvoker.setTargetMethod(methodName);
Object[] arguments = new Object[1];
arguments[0] = event;
methodInvoker.setArguments(arguments);
// invoke rule method
try {
LOG.debug("Invoking rule method: " + methodInvoker.getTargetMethod() + " for class: " + rule.getClass()
.getName());
methodInvoker.prepare();
Class<?> methodReturnType = methodInvoker.getPreparedMethod().getReturnType();
if (StringUtils.equals("void", methodReturnType.getName())) {
methodInvoker.invoke();
} else {
success &= (Boolean) methodInvoker.invoke();
}
} catch (Exception e) {
LOG.error("Error invoking rule method for class: " + rule.getClass().getName(), e);
throw new RuntimeException("Error invoking rule method for class: " + rule.getClass().getName(), e);
}
return success;
}