本文整理汇总了Java中org.codehaus.groovy.runtime.InvokerInvocationException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java InvokerInvocationException.getCause方法的具体用法?Java InvokerInvocationException.getCause怎么用?Java InvokerInvocationException.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.runtime.InvokerInvocationException
的用法示例。
在下文中一共展示了InvokerInvocationException.getCause方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
public void execute(Task task) {
closure.setDelegate(task);
closure.setResolveStrategy(Closure.DELEGATE_FIRST);
ClassLoader original = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(closure.getClass().getClassLoader());
try {
if (closure.getMaximumNumberOfParameters() == 0) {
closure.call();
} else {
closure.call(task);
}
} catch (InvokerInvocationException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
}
throw e;
} finally {
Thread.currentThread().setContextClassLoader(original);
}
}
示例2: callControllerAwareMethod
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
/**
* Check whether the script declares a method with the given name that takes a
* corpus parameter, and if so, call it passing the corpus from the given
* controller. If the controller is not a CorpusController, do nothing.
*
* @throws ExecutionException
* if the script method throws an ExecutionException we re-throw it
*/
protected void callControllerAwareMethod(String methodName, Controller c)
throws ExecutionException {
if(!(c instanceof CorpusController)) { return; }
List<MetaMethod> metaMethods =
groovyScript.getMetaClass().respondsTo(groovyScript, methodName,
new Class[]{gate.Corpus.class});
if(!metaMethods.isEmpty()) {
try {
metaMethods.get(0).invoke(groovyScript,
new Corpus[]{((CorpusController)c).getCorpus()});
} catch(InvokerInvocationException iie) {
if(iie.getCause() instanceof ExecutionException) {
throw (ExecutionException)iie.getCause();
} else if(iie.getCause() instanceof RuntimeException) {
throw (RuntimeException)iie.getCause();
} else if(iie.getCause() instanceof Error) {
throw (Error)iie.getCause();
} else {
throw iie;
}
}
}
}
示例3: getProperty
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
public Object getProperty(String name) throws MissingPropertyException {
if (!includeProperties) {
throw propertyMissingException(name);
}
MetaProperty property = getMetaClass().hasProperty(bean, name);
if (property == null) {
return getMetaClass().invokeMissingProperty(bean, name, null, true);
}
if (property instanceof MetaBeanProperty && ((MetaBeanProperty) property).getGetter() == null) {
throw new GroovyRuntimeException(String.format(
"Cannot get the value of write-only property '%s' on %s.", name, getDisplayName()));
}
try {
return property.getProperty(bean);
} catch (InvokerInvocationException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
}
throw e;
}
}
示例4: callClosure
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
public static Object callClosure(Closure closure, Object... args) {
try {
return closure.call(args);
} catch (InvokerInvocationException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException)e.getCause();
} else {
throw e;
}
}
}
示例5: setBeanProperty
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
private void setBeanProperty(Object newValue) {
try {
propertyAccessor().write(bean, propertyName, newValue);
} catch (InvokerInvocationException iie) {
if (!(iie.getCause() instanceof PropertyVetoException)) {
throw iie;
}
// ignore veto exceptions, just let the binding fail like a validation does
}
}
示例6: call
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
static <T> T call(Closure<T> closure, Object... args) {
try {
return closure.call(args);
} catch (InvokerInvocationException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw e;
}
}
}
示例7: setProperty
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
public void setProperty(final String name, Object value) throws MissingPropertyException {
if (!includeProperties) {
throw propertyMissingException(name);
}
MetaClass metaClass = getMetaClass();
MetaProperty property = metaClass.hasProperty(bean, name);
if (property == null) {
getMetaClass().invokeMissingProperty(bean, name, null, false);
}
if (property instanceof MetaBeanProperty && ((MetaBeanProperty) property).getSetter() == null) {
throw new ReadOnlyPropertyException(name, bean.getClass()) {
@Override
public String getMessage() {
return String.format("Cannot set the value of read-only property '%s' on %s.", name,
getDisplayName());
}
};
}
try {
// Attempt type coercion before trying to set the property
value = argsTransformer.transform(bean, MetaProperty.getSetterName(name), value)[0];
metaClass.setProperty(bean, name, value);
} catch (InvokerInvocationException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
}
throw e;
}
}
示例8: invokeMethod
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
public Object invokeMethod(final String name, final Object... arguments) throws MissingMethodException {
try {
return getMetaClass().invokeMethod(bean, name, arguments);
} catch (InvokerInvocationException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
}
throw e;
}
}
示例9: getPropertyFor
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
public static Object getPropertyFor(ScriptProperties script, String property){
Object args = new Object[]{script, property};
for (GroovyObject modifier : dynamicModifiers) try {
return modifier.getMetaClass().invokeMethod(modifier, "getPropertyFor", args);
} catch (InvokerInvocationException exception){
if (exception.getCause() != PropertySelector.next) throw exception;
} catch (MissingMethodException ignored){}
throw PropertySelector.next;
}
示例10: invokeMethodFor
import org.codehaus.groovy.runtime.InvokerInvocationException; //导入方法依赖的package包/类
public static Object invokeMethodFor(ScriptProperties script, String name, Object[] args){
Object arguments = new Object[]{script, name, args};
for (GroovyObject modifier : dynamicModifiers) try {
return InvokerHelper.invokeMethod(modifier, "invokeMethodFor", arguments);
} catch (InvokerInvocationException exception){
if (exception.getCause() != PropertySelector.next) throw exception;
} catch (MissingMethodException ignored){}
throw PropertySelector.next;
}