提交 4f606cab 编写于 作者: wu-sheng's avatar wu-sheng

重命名部分类名,规范化接口参数。#36

上级 03e006bf
......@@ -26,7 +26,7 @@ public class ClassConstructorInterceptor {
try {
EnhancedClassInstanceContext context = new EnhancedClassInstanceContext();
accessor.setValue(context);
ConstructorContext interceptorContext = new ConstructorContext(
ConstructorInvokeContext interceptorContext = new ConstructorInvokeContext(obj,
allArguments);
interceptor.onConstruct(context, interceptorContext);
} catch (Throwable t) {
......
......@@ -37,7 +37,7 @@ public class ClassMethodInterceptor {
@SuperCall Callable<?> zuper,
@FieldValue(EnhanceClazz4Interceptor.contextAttrName) EnhancedClassInstanceContext instanceContext)
throws Exception {
InterceptorContext interceptorContext = new InterceptorContext(obj,
MethodInvokeContext interceptorContext = new MethodInvokeContext(obj,
method.getName(), allArguments);
try {
interceptor.beforeMethod(instanceContext, interceptorContext);
......
package com.ai.cloud.skywalking.plugin.interceptor;
public class ConstructorContext {
public class ConstructorInvokeContext {
/**
* 代理对象实例
*/
private Object objInst;
/**
* 构造函数参数
*/
private Object[] allArguments;
ConstructorContext(Object[] allArguments) {
ConstructorInvokeContext(Object objInst, Object[] allArguments) {
this.objInst = objInst;
this.allArguments = allArguments;
}
public Object inst(){
return objInst;
}
public Object[] allArguments(){
return this.allArguments;
......
package com.ai.cloud.skywalking.plugin.interceptor;
public interface IAroundInterceptor {
public void onConstruct(EnhancedClassInstanceContext context, ConstructorContext interceptorContext);
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext);
public void beforeMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext);
public void beforeMethod(EnhancedClassInstanceContext context, MethodInvokeContext interceptorContext);
public Object afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext, Object ret);
public Object afterMethod(EnhancedClassInstanceContext context, MethodInvokeContext interceptorContext, Object ret);
}
package com.ai.cloud.skywalking.plugin.interceptor;
public class InterceptorContext {
/**
* 方法执行拦截上下文
*
* @author wusheng
*
*/
public class MethodInvokeContext {
/**
* 代理类实例
*/
private Object objInst;
/**
* 方法名称
*/
private String methodName;
/**
* 方法参数
*/
private Object[] allArguments;
InterceptorContext(Object objInst, String methodName, Object[] allArguments) {
MethodInvokeContext(Object objInst, String methodName, Object[] allArguments) {
this.objInst = objInst;
this.methodName = methodName;
this.allArguments = allArguments;
......
package test.ai.cloud.plugin;
import com.ai.cloud.skywalking.plugin.interceptor.ConstructorContext;
import com.ai.cloud.skywalking.plugin.interceptor.ConstructorInvokeContext;
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.ai.cloud.skywalking.plugin.interceptor.IAroundInterceptor;
import com.ai.cloud.skywalking.plugin.interceptor.InterceptorContext;
import com.ai.cloud.skywalking.plugin.interceptor.MethodInvokeContext;
public class TestAroundInterceptor implements IAroundInterceptor {
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorContext interceptorContext) {
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
context.set("test.key", "123");
System.out.println("onConstruct, args size=" + interceptorContext.allArguments().length);
}
@Override
public void beforeMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext) {
public void beforeMethod(EnhancedClassInstanceContext context, MethodInvokeContext interceptorContext) {
System.out.println("beforeMethod : " + context.get("test.key", String.class));
}
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext, Object ret) {
public Object afterMethod(EnhancedClassInstanceContext context, MethodInvokeContext interceptorContext, Object ret) {
System.out.println("afterMethod: " + context.get("test.key", String.class));
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册