// 使用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"
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论