1
由於每個Groovy的對象實現的GroovyObject接口,我會嘗試重寫的InvokeMethod(),這裏是我的測試:不能覆蓋invokeMethod中從繼承的GroovyObject
class MyGrrovyClass {
static test(){
println 'i am in test'
}
Object invokeMethod(String name, Object args){
log.info('method intercepted')
def metaClass = InvokerHelper.getMetaClass(this)
def result = metaClass.invokeMethod(this, name, args)
return result
}
public static void main(String[] args) {
test()
}
}
但似乎不工作,我從來沒有見過的日誌信息在我的控制檯
我的第二個問題是:GroovyInterceptable是的GroovyObject的子接口,我重寫的GroovyObject直接invokeMethod中,我實現GroovyInterceptable接口invokeMethod中說之間有什麼區別?
感謝