hades
3 years ago
7 changed files with 118 additions and 95 deletions
@ -0,0 +1,28 @@
|
||||
package com.fr.design.record.analyzer.Interceptor; |
||||
|
||||
import com.fr.design.mod.ContentObjectManager; |
||||
import com.fr.third.net.bytebuddy.implementation.bind.annotation.AllArguments; |
||||
import com.fr.third.net.bytebuddy.implementation.bind.annotation.Origin; |
||||
import com.fr.third.net.bytebuddy.implementation.bind.annotation.RuntimeType; |
||||
import com.fr.third.net.bytebuddy.implementation.bind.annotation.SuperCall; |
||||
import java.lang.reflect.Method; |
||||
import java.util.concurrent.Callable; |
||||
|
||||
/** |
||||
* 收集 |
||||
* |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/6/17 |
||||
*/ |
||||
public class CollectInterceptor { |
||||
|
||||
@RuntimeType |
||||
public static Object intercept(@Origin Method method, |
||||
@SuperCall Callable<?> callable, |
||||
@AllArguments Object[] args) throws Exception { |
||||
Object result = callable.call(); |
||||
ContentObjectManager.getInstance().collect(result); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.design.record.analyzer.advice; |
||||
|
||||
import com.fr.design.mod.ContentObjectManager; |
||||
import com.fr.design.record.analyzer.DesignerAnalyzerAdvice; |
||||
import com.fr.third.net.bytebuddy.asm.Advice; |
||||
import com.fr.third.net.bytebuddy.implementation.bytecode.assign.Assigner; |
||||
import java.lang.reflect.Method; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/6/17 |
||||
*/ |
||||
public class CollectAdvice implements DesignerAnalyzerAdvice { |
||||
|
||||
@Advice.OnMethodExit(onThrowable = Exception.class) |
||||
public static void onMethodExit(@Advice.This(optional = true, typing = Assigner.Typing.DYNAMIC) Object self, |
||||
@Advice.Origin Method method, |
||||
@Advice.AllArguments(typing = Assigner.Typing.DYNAMIC) Object[] args, |
||||
@Advice.Return(readOnly = false, typing = Assigner.Typing.DYNAMIC) Object result) throws Exception { |
||||
ContentObjectManager.getInstance().collect(result); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
Loading…
Reference in new issue