// 使用javassist实现对对类的修改:
// 例如方法:
public void helloworld() {
System.out.println("hello world");
}
// 更改后伪代码如下
public void helloworld() {
try {
org.jiucheng.agent.Inject.before();
System.out.println("hello world");
}catch(Exception e) {
org.jiucheng.agent.Inject.exception(e);
throw e;
}finnally {
org.jiucheng.agent.Inject.after();
}
}
源码地址:http://git.oschina.net/jiucheng_org/jiucheng-agent
安装包:http://dev.jiucheng.org/jiucheng-agent.tar.gz
需要在tomcat的catalina.sh文件首行添加如下内容:
JAVA_OPTS="-javaagent:/www/helloworld/jiucheng-agent/lib/jiucheng-agent-0.0.1-SNAPSHOT.jar"
- 左青龙
- 微信扫一扫
- 右白虎
- 微信扫一扫
评论