3

我想在我的 Eclipse(Helios) 中添加一个插件,用于记录我的函数开始和结束。更准确地说,我正在寻找这样的东西。

TestClass {

    private static final Logger logger = Logger.getLog("TestClass");

    public void displayHello () {
        System.out.println("Fooo");
    }
}

添加插件并启用功能日志记录后,我期待以下内容

TestClass {
  private static final Logger logger = Logger.getLog("TestClass");
   public void displayHello () {
     logger.debug ("displayHello() - Started");
     System.out.println("Fooo");
     logger.debug ("displayHello() - Ended");
   }
 }

我记得以前用过一些方法来获得相同的东西,但现在无法回忆起来。有人可以帮我解决这个问题吗?

谢谢阿尼什

4

2 回答 2

2

你应该看看AspectJSpring AOP它支持这样的东西,

execution(* com.java.test..*.*(..))

这将涵盖项目所有子包中的所有方法。所以不需要一一定义所有的方法。

于 2012-12-25T07:08:02.013 回答
0

Since the question is about Eclipse plugins, I am assuming that the places you want to log do not necessarily exist in a single plugin. AspectJ is a good suggestion. However, standard AspectJ or Spring AOP will not be sufficient since it is classloader based. You will need to use Equinox Weaving.

Equinox Weaving performs load-time weaving in an OSGi-aware way. Essentially, you create your plugins and augment your manifest files with the proper weaving configuration.

于 2012-12-27T05:24:26.693 回答