Loading skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/ClassMethodInterceptor.java +4 −2 Original line number Diff line number Diff line Loading @@ -45,15 +45,17 @@ public class ClassMethodInterceptor { logger.error("class[{}] before method[{}] intercept failue:{}", obj.getClass(), method.getName(), t.getMessage(), t); } Object ret = null; try { return zuper.call(); ret = zuper.call(); } finally { try { interceptor.afterMethod(instanceContext, interceptorContext); ret = interceptor.afterMethod(instanceContext, interceptorContext, ret); } catch (Throwable t) { logger.error("class[{}] after method[{}] intercept failue:{}", obj.getClass(), method.getName(), t.getMessage(), t); } } return ret; } } skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/IAroundInterceptor.java +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ public interface IAroundInterceptor { public void beforeMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext); public void afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext); public Object afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext, Object ret); } skywalking-api/src/test/java/test/ai/cloud/plugin/PluginMainTest.java +11 −4 Original line number Diff line number Diff line Loading @@ -8,12 +8,19 @@ import com.ai.cloud.skywalking.plugin.TracingBootstrap; public class PluginMainTest { @Test public void testMain() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException{ TracingBootstrap.main(new String[]{"test.ai.cloud.plugin.PluginMainTest"}); public void testMain() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { TracingBootstrap .main(new String[] { "test.ai.cloud.plugin.PluginMainTest" }); } public static void main(String[] args) { long start = System.currentTimeMillis(); BeInterceptedClass inst = new BeInterceptedClass(); inst.printabc(); long end = System.currentTimeMillis(); System.out.println(end - start + "ms"); } } skywalking-api/src/test/java/test/ai/cloud/plugin/TestAroundInterceptor.java +2 −1 Original line number Diff line number Diff line Loading @@ -19,8 +19,9 @@ public class TestAroundInterceptor implements IAroundInterceptor { } @Override public void afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext) { public Object afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext, Object ret) { System.out.println("afterMethod: " + context.get("test.key", String.class)); return ret; } } Loading
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/ClassMethodInterceptor.java +4 −2 Original line number Diff line number Diff line Loading @@ -45,15 +45,17 @@ public class ClassMethodInterceptor { logger.error("class[{}] before method[{}] intercept failue:{}", obj.getClass(), method.getName(), t.getMessage(), t); } Object ret = null; try { return zuper.call(); ret = zuper.call(); } finally { try { interceptor.afterMethod(instanceContext, interceptorContext); ret = interceptor.afterMethod(instanceContext, interceptorContext, ret); } catch (Throwable t) { logger.error("class[{}] after method[{}] intercept failue:{}", obj.getClass(), method.getName(), t.getMessage(), t); } } return ret; } }
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/IAroundInterceptor.java +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ public interface IAroundInterceptor { public void beforeMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext); public void afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext); public Object afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext, Object ret); }
skywalking-api/src/test/java/test/ai/cloud/plugin/PluginMainTest.java +11 −4 Original line number Diff line number Diff line Loading @@ -8,12 +8,19 @@ import com.ai.cloud.skywalking.plugin.TracingBootstrap; public class PluginMainTest { @Test public void testMain() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException{ TracingBootstrap.main(new String[]{"test.ai.cloud.plugin.PluginMainTest"}); public void testMain() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { TracingBootstrap .main(new String[] { "test.ai.cloud.plugin.PluginMainTest" }); } public static void main(String[] args) { long start = System.currentTimeMillis(); BeInterceptedClass inst = new BeInterceptedClass(); inst.printabc(); long end = System.currentTimeMillis(); System.out.println(end - start + "ms"); } }
skywalking-api/src/test/java/test/ai/cloud/plugin/TestAroundInterceptor.java +2 −1 Original line number Diff line number Diff line Loading @@ -19,8 +19,9 @@ public class TestAroundInterceptor implements IAroundInterceptor { } @Override public void afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext) { public Object afterMethod(EnhancedClassInstanceContext context, InterceptorContext interceptorContext, Object ret) { System.out.println("afterMethod: " + context.get("test.key", String.class)); return ret; } }