Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
2c050c05
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
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,发现更多精彩内容 >>
提交
2c050c05
编写于
12月 21, 2015
作者:
Z
zhangxin10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新添加turnOn属性,并提交测试类
上级
39fb666a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
24 addition
and
10 deletion
+24
-10
skywalking-sdk-plugin/spring-plugin/src/main/java/com/ai/cloud/skywalking/plugin/spring/TraceParser.java
...va/com/ai/cloud/skywalking/plugin/spring/TraceParser.java
+2
-0
skywalking-sdk-plugin/spring-plugin/src/main/java/com/ai/cloud/skywalking/plugin/spring/TracingEnhanceProcessor.java
...oud/skywalking/plugin/spring/TracingEnhanceProcessor.java
+14
-0
skywalking-sdk-plugin/spring-plugin/src/test/java/com/ai/cloud/skywalking/plugin/spring/TestBean.java
.../java/com/ai/cloud/skywalking/plugin/spring/TestBean.java
+5
-7
skywalking-sdk-plugin/spring-plugin/src/test/resources/springConfig-common.xml
.../spring-plugin/src/test/resources/springConfig-common.xml
+3
-3
未找到文件。
skywalking-sdk-plugin/spring-plugin/src/main/java/com/ai/cloud/skywalking/plugin/spring/TraceParser.java
浏览文件 @
2c050c05
...
...
@@ -16,9 +16,11 @@ public class TraceParser implements BeanDefinitionParser {
// 只能存在一个
throw
new
IllegalStateException
(
"Duplicate spring bean id "
);
}
boolean
turnOn
=
Boolean
.
parseBoolean
(
element
.
getAttribute
(
"turnOn"
));
RootBeanDefinition
rootBeanDefinition
=
new
RootBeanDefinition
();
rootBeanDefinition
.
setLazyInit
(
false
);
rootBeanDefinition
.
setBeanClass
(
TracingEnhanceProcessor
.
class
);
rootBeanDefinition
.
getPropertyValues
().
addPropertyValue
(
"turnOn"
,
turnOn
);
parserContext
.
getRegistry
().
registerBeanDefinition
(
TRACE_APPLICATION_BEAN_NAME
,
rootBeanDefinition
);
return
rootBeanDefinition
;
}
...
...
skywalking-sdk-plugin/spring-plugin/src/main/java/com/ai/cloud/skywalking/plugin/spring/TracingEnhanceProcessor.java
浏览文件 @
2c050c05
...
...
@@ -23,6 +23,16 @@ public class TracingEnhanceProcessor implements DisposableBean, BeanPostProcesso
private
final
Set
<
TracingPattern
>
beanSet
=
new
ConcurrentHashSet
<
TracingPattern
>();
private
boolean
turnOn
;
public
boolean
isTurnOn
()
{
return
turnOn
;
}
public
void
setTurnOn
(
boolean
turnOn
)
{
this
.
turnOn
=
turnOn
;
}
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
throws
BeansException
{
beanSet
.
addAll
(
applicationContext
.
getBeansOfType
(
TracingPattern
.
class
).
values
());
...
...
@@ -71,6 +81,10 @@ public class TracingEnhanceProcessor implements DisposableBean, BeanPostProcesso
@Override
public
Object
postProcessAfterInitialization
(
Object
bean
,
String
beanName
)
throws
BeansException
{
if
(!
turnOn
)
{
return
bean
;
}
String
packageName
=
bean
.
getClass
().
getPackage
().
getName
();
String
className
=
bean
.
getClass
().
getSimpleName
();
TracingPattern
matchClassBean
=
null
;
...
...
skywalking-sdk-plugin/spring-plugin/src/test/java/com/ai/cloud/skywalking/plugin/spring/
test/AppTest01
.java
→
skywalking-sdk-plugin/spring-plugin/src/test/java/com/ai/cloud/skywalking/plugin/spring/
TestBean
.java
浏览文件 @
2c050c05
package
com.ai.cloud.skywalking.plugin.spring
.test
;
package
com.ai.cloud.skywalking.plugin.spring
;
import
org.junit.Test
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
public
class
AppTest01
{
public
class
TestBean
{
public
void
testPrintln
(
String
value
){
System
.
out
.
println
(
value
);
}
@Test
public
void
testBean
(){
public
static
void
main
(
String
[]
args
){
ClassPathXmlApplicationContext
classPathXmlApplicationContext
=
new
ClassPathXmlApplicationContext
(
"classpath*:springConfig-common.xml"
);
AppTest01
appTest01
=
classPathXmlApplicationContext
.
getBean
(
AppTest01
.
class
);
appTest01
.
testPrintln
(
"Hello World"
);
TestBean
testBean
=
classPathXmlApplicationContext
.
getBean
(
TestBean
.
class
);
testBean
.
testPrintln
(
"Hello World"
);
}
}
skywalking-sdk-plugin/spring-plugin/src/test/resources/springConfig-common.xml
浏览文件 @
2c050c05
...
...
@@ -8,10 +8,10 @@
http://cloud.asiainfo.com/schema/skywalking
http://cloud.asiainfo.com/schema/skywalking/skywalking.xsd"
>
<skywalking:trace
turnOn=
"true"
/>
<skywalking:trace/>
<
skywalking:tracing-bean
className=
"AppTest01"
method=
"testPrintln*"
packageName=
"*"
/
>
<
!--<skywalking:tracing-bean className="AppTest01" method="testPrintln*" packageName="*"/>--
>
<bean
id=
"testBean"
class=
"com.ai.cloud.skywalking.plugin.spring.test.AppTest01"
/>
<bean
class=
"com.ai.cloud.skywalking.plugin.spring.TestBean"
/>
</beans>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录