用javassist实现应用执行轨迹及方法执行时间

颓废 2019年5月19日10:03:59评论499 views字数 559阅读1分51秒阅读模式
摘要

// 使用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"

用javassist实现应用执行轨迹及方法执行时间

// 使用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"

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
颓废
  • 本文由 发表于 2019年5月19日10:03:59
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   用javassist实现应用执行轨迹及方法执行时间http://cn-sec.com/archives/68410.html

发表评论

匿名网友 填写信息