Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
六月暴雪飞梨花
SkyWalking
提交
f4d20579
S
SkyWalking
项目概览
六月暴雪飞梨花
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
f4d20579
编写于
6月 09, 2016
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. 完善toString方法
上级
e1a3de2a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
107 addition
and
5 deletion
+107
-5
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java
...ywalking/plugin/interceptor/EnhanceClazz4Interceptor.java
+2
-2
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/MethodMatcher.java
...ai/cloud/skywalking/plugin/interceptor/MethodMatcher.java
+31
-0
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/AnyMethodMatcher.java
...ywalking/plugin/interceptor/matcher/AnyMethodMatcher.java
+6
-1
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/MethodExclusiveMatcher.java
...ng/plugin/interceptor/matcher/MethodExclusiveMatcher.java
+24
-0
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/MethodRegexMatcher.java
...alking/plugin/interceptor/matcher/MethodRegexMatcher.java
+1
-0
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/MethodsExclusiveMatcher.java
...g/plugin/interceptor/matcher/MethodsExclusiveMatcher.java
+15
-0
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/PrivateMethodMatcher.java
...king/plugin/interceptor/matcher/PrivateMethodMatcher.java
+24
-0
skywalking-api/src/test/java/test/ai/cloud/matcher/TestMatcherDefine.java
...rc/test/java/test/ai/cloud/matcher/TestMatcherDefine.java
+4
-2
未找到文件。
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java
浏览文件 @
f4d20579
...
...
@@ -121,8 +121,8 @@ public class EnhanceClazz4Interceptor {
interceptor
);
for
(
MethodMatcher
methodMatcher
:
methodMatchers
)
{
logger
.
debug
(
"prepare to enhance class {}
method [{}]
"
,
enhanceOriginClassName
,
methodMatcher
.
getMethodMatchDescribe
()
);
logger
.
debug
(
"prepare to enhance class {}
{}
"
,
enhanceOriginClassName
,
methodMatcher
);
newClassBuilder
=
newClassBuilder
.
method
(
methodMatcher
.
builderMatcher
()).
intercept
(
MethodDelegation
.
to
(
classMethodInterceptor
));
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/MethodMatcher.java
浏览文件 @
f4d20579
...
...
@@ -90,4 +90,35 @@ public abstract class MethodMatcher {
}
}
@Override
public
String
toString
()
{
StringBuilder
stringBuilder
=
new
StringBuilder
(
" the method named "
+
getMethodMatchDescribe
());
if
(
getModifier
()
!=
null
)
{
stringBuilder
.
append
(
" with "
+
getModifier
()
+
" modifier"
);
}
if
(
getArgNum
()
>
-
1
)
{
stringBuilder
.
append
(
","
+
getArgNum
()
+
" arguments"
);
}
if
(
getArgTypeArray
()
!=
null
)
{
stringBuilder
.
append
(
",argument type are "
);
for
(
Class
argType
:
getArgTypeArray
())
{
stringBuilder
.
append
(
argType
.
getName
());
}
}
return
stringBuilder
.
toString
();
}
protected
int
getArgNum
()
{
return
argNum
;
}
protected
Class
<?>[]
getArgTypeArray
()
{
return
argTypeArray
;
}
protected
Modifier
getModifier
()
{
return
modifier
;
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/AnyMethodMatcher.java
浏览文件 @
f4d20579
...
...
@@ -9,11 +9,16 @@ import static net.bytebuddy.matcher.ElementMatchers.any;
public
class
AnyMethodMatcher
extends
MethodMatcher
{
public
AnyMethodMatcher
()
{
super
(
"
*
"
);
super
(
"
any method
"
);
}
@Override
public
ElementMatcher
.
Junction
<
MethodDescription
>
builderMatcher
()
{
return
any
();
}
@Override
public
String
toString
()
{
return
getMethodMatchDescribe
();
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/MethodExclusiveMatcher.java
浏览文件 @
f4d20579
...
...
@@ -38,4 +38,28 @@ public class MethodExclusiveMatcher extends MethodMatcher {
ElementMatcher
.
Junction
<
MethodDescription
>
matcher
=
named
(
getMethodMatchDescribe
());
return
not
(
mergeArgumentsIfNecessary
(
matcher
));
}
@Override
public
String
toString
()
{
StringBuilder
stringBuilder
=
new
StringBuilder
(
"any method exclude "
);
stringBuilder
.
append
(
" method named "
+
getMethodMatchDescribe
());
if
(
getModifier
()
!=
null
)
{
stringBuilder
.
append
(
getModifier
());
}
if
(
getArgNum
()
>
-
1
)
{
stringBuilder
.
append
(
" with "
+
getArgNum
()
+
" arguments"
);
}
if
(
getArgTypeArray
()
!=
null
)
{
stringBuilder
.
append
(
" with "
);
for
(
Class
argType
:
getArgTypeArray
())
{
stringBuilder
.
append
(
argType
.
getName
());
}
}
return
stringBuilder
.
toString
();
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/MethodRegexMatcher.java
浏览文件 @
f4d20579
...
...
@@ -38,4 +38,5 @@ public class MethodRegexMatcher extends MethodMatcher {
ElementMatcher
.
Junction
<
MethodDescription
>
matcher
=
nameMatches
(
getMethodMatchDescribe
());
return
mergeArgumentsIfNecessary
(
matcher
);
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/MethodsExclusiveMatcher.java
浏览文件 @
f4d20579
...
...
@@ -46,4 +46,19 @@ public class MethodsExclusiveMatcher extends MethodMatcher {
return
not
(
result
);
}
@Override
public
String
toString
()
{
StringBuilder
stringBuilder
=
new
StringBuilder
(
"any method exclude the method(s) as follow:\n "
);
int
i
=
0
;
for
(
MethodMatcher
methodMatcher
:
matchers
)
{
if
(
i
==
0
)
{
stringBuilder
.
append
(
methodMatcher
.
toString
()
+
" or "
);
i
++;
}
else
{
stringBuilder
.
append
(
methodMatcher
.
toString
());
}
}
return
stringBuilder
.
toString
();
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/matcher/PrivateMethodMatcher.java
0 → 100644
浏览文件 @
f4d20579
package
com.ai.cloud.skywalking.plugin.interceptor.matcher
;
import
com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
net.bytebuddy.matcher.ElementMatchers
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
any
;
public
class
PrivateMethodMatcher
extends
MethodMatcher
{
public
PrivateMethodMatcher
()
{
super
(
"any private method"
);
}
@Override
public
ElementMatcher
.
Junction
<
MethodDescription
>
builderMatcher
()
{
return
any
().
and
(
ElementMatchers
.<
MethodDescription
>
isPrivate
());
}
@Override
public
String
toString
()
{
return
getMethodMatchDescribe
();
}
}
skywalking-api/src/test/java/test/ai/cloud/matcher/TestMatcherDefine.java
浏览文件 @
f4d20579
...
...
@@ -4,6 +4,7 @@ import com.ai.cloud.skywalking.plugin.interceptor.IAroundInterceptor;
import
com.ai.cloud.skywalking.plugin.interceptor.InterceptorDefine
;
import
com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher
;
import
com.ai.cloud.skywalking.plugin.interceptor.matcher.MethodsExclusiveMatcher
;
import
com.ai.cloud.skywalking.plugin.interceptor.matcher.PrivateMethodMatcher
;
import
com.ai.cloud.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher
;
/**
...
...
@@ -18,8 +19,9 @@ public class TestMatcherDefine implements InterceptorDefine {
@Override
public
MethodMatcher
[]
getBeInterceptedMethodsMatchers
()
{
return
new
MethodMatcher
[]{
new
MethodsExclusiveMatcher
(
"set"
,
"get"
),
new
SimpleMethodMatcher
(
MethodMatcher
.
Modifier
.
Private
,
"set"
)
new
PrivateMethodMatcher
(),
new
MethodsExclusiveMatcher
(
new
SimpleMethodMatcher
(
"set"
),
new
SimpleMethodMatcher
(
MethodMatcher
.
Modifier
.
Public
,
"get"
)),
new
SimpleMethodMatcher
(
MethodMatcher
.
Modifier
.
Private
,
"set"
,
1
)
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录