use of groovy.lang.GroovyInterceptable in project groovy-core by groovy.
the class CallSiteArray method createCallCurrentSite.
private static CallSite createCallCurrentSite(CallSite callSite, GroovyObject receiver, Object[] args, Class sender) {
CallSite site;
if (receiver instanceof GroovyInterceptable)
site = new PogoInterceptableSite(callSite);
else {
MetaClass metaClass = receiver.getMetaClass();
if (receiver.getClass() != metaClass.getTheClass() && !metaClass.getTheClass().isInterface()) {
site = new PogoInterceptableSite(callSite);
} else if (metaClass instanceof MetaClassImpl) {
site = ((MetaClassImpl) metaClass).createPogoCallCurrentSite(callSite, sender, args);
} else
site = new PogoMetaClassSite(callSite, metaClass);
}
replaceCallSite(callSite, site);
return site;
}
use of groovy.lang.GroovyInterceptable in project groovy by apache.
the class CallSiteArray method createCallCurrentSite.
private static CallSite createCallCurrentSite(CallSite callSite, GroovyObject receiver, Object[] args, Class sender) {
CallSite site;
if (receiver instanceof GroovyInterceptable)
site = new PogoInterceptableSite(callSite);
else {
MetaClass metaClass = receiver.getMetaClass();
if (receiver.getClass() != metaClass.getTheClass() && !metaClass.getTheClass().isInterface()) {
site = new PogoInterceptableSite(callSite);
} else if (metaClass instanceof MetaClassImpl) {
site = ((MetaClassImpl) metaClass).createPogoCallCurrentSite(callSite, sender, args);
} else
site = new PogoMetaClassSite(callSite, metaClass);
}
replaceCallSite(callSite, site);
return site;
}
use of groovy.lang.GroovyInterceptable in project groovy by apache.
the class InvokerHelper method invokePogoMethod.
static Object invokePogoMethod(Object object, String methodName, Object arguments) {
GroovyObject groovy = (GroovyObject) object;
boolean intercepting = groovy instanceof GroovyInterceptable;
try {
// if it's a pure interceptable object (even intercepting toString(), clone(), ...)
if (intercepting) {
return groovy.invokeMethod(methodName, asUnwrappedArray(arguments));
}
//else try a statically typed method or a GDK method
return groovy.getMetaClass().invokeMethod(object, methodName, asArray(arguments));
} catch (MissingMethodException e) {
if (e instanceof MissingMethodExecutionFailed) {
throw (MissingMethodException) e.getCause();
} else if (!intercepting && e.getMethod().equals(methodName) && object.getClass() == e.getType()) {
// in case there's nothing else, invoke the object's own invokeMethod()
return groovy.invokeMethod(methodName, asUnwrappedArray(arguments));
} else {
throw e;
}
}
}
Aggregations