【问题标题】:AOP AspectJ static field initialization with Annotated (marked) Classes带注释(标记)类的 AOP AspectJ 静态字段初始化
【发布时间】:2012-08-10 16:55:29
【问题描述】:

我有一个静态字段public static Class[] items; 我希望在应用程序开始时用具有@ItemExample 注释的类填充它。示例类(简化):

public class ItemUtil{
public static Class[] itemClasses;
public static void actionsWithAllItemClasses(
//call some general method of classes in array using reflection API
)
}



  @ItemExample
    public class Item1 extends GeneralItem{
     public static void generalMethod(){
    //Item 1 specific action
        }
    }

    @ItemExample
    public class Item2 extends GeneralItem{
    public static void generalMethod(){
    //Item2 specific action
         }
    }

所以在启动(部署,在 ServletCONtextListneres 开始执行之前)应用程序(在 Tomcat 中运行)item classes=={Item1.class, Item2.class} 的时间。另外我希望每个类都覆盖GeneralItemgeneralMethod(),但是这个方法是静态的,所以每个类都声明它自己的方法。

【问题讨论】:

    标签: java static annotations aop aspectj


    【解决方案1】:

    Google Reflections运行时搜索和

    Evo Class Index编译时搜索

    帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-02
      • 1970-01-01
      • 1970-01-01
      • 2014-10-06
      • 1970-01-01
      相关资源
      最近更新 更多