Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
8c70efcc
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8c70efcc
编写于
3月 14, 2016
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改afterMethod接口,以及相关的依赖实现。允许afterMethod复写方法的返回值,用于进行特定的类包装。#36
上级
904d0cb2
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
18 addition
and
8 deletion
+18
-8
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/ClassMethodInterceptor.java
...skywalking/plugin/interceptor/ClassMethodInterceptor.java
+4
-2
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/IAroundInterceptor.java
...oud/skywalking/plugin/interceptor/IAroundInterceptor.java
+1
-1
skywalking-api/src/test/java/test/ai/cloud/plugin/PluginMainTest.java
...pi/src/test/java/test/ai/cloud/plugin/PluginMainTest.java
+11
-4
skywalking-api/src/test/java/test/ai/cloud/plugin/TestAroundInterceptor.java
...test/java/test/ai/cloud/plugin/TestAroundInterceptor.java
+2
-1
未找到文件。
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/ClassMethodInterceptor.java
浏览文件 @
8c70efcc
...
...
@@ -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
{
ret
urn
zuper
.
call
();
ret
=
zuper
.
call
();
}
finally
{
try
{
interceptor
.
afterMethod
(
instanceContext
,
interceptorContex
t
);
ret
=
interceptor
.
afterMethod
(
instanceContext
,
interceptorContext
,
re
t
);
}
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
浏览文件 @
8c70efcc
...
...
@@ -5,7 +5,7 @@ public interface IAroundInterceptor {
public
void
beforeMethod
(
EnhancedClassInstanceContext
context
,
InterceptorContext
interceptorContext
);
public
void
afterMethod
(
EnhancedClassInstanceContext
context
,
InterceptorContext
interceptorContex
t
);
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InterceptorContext
interceptorContext
,
Object
re
t
);
}
skywalking-api/src/test/java/test/ai/cloud/plugin/PluginMainTest.java
浏览文件 @
8c70efcc
...
...
@@ -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
){
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
浏览文件 @
8c70efcc
...
...
@@ -19,8 +19,9 @@ public class TestAroundInterceptor implements IAroundInterceptor {
}
@Override
public
void
afterMethod
(
EnhancedClassInstanceContext
context
,
InterceptorContext
interceptorContex
t
)
{
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InterceptorContext
interceptorContext
,
Object
re
t
)
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录