I have a static field public static Class[] items; I want it to be filled at the start of the application with classes which have @ItemExample annotaion. Example classes(simplified):
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
}
}
So at the starting(deployment, before ServletCOntextListneres start executing) time of application (Run in Tomcat) item classes=={Item1.class, Item2.class}. Also I would like each class to override the generalMethod() of GeneralItem, but this method is static, so each class declares it’s own method.
Google Reflections Runtime search and
Evo Class Index Compile Time search
Helped.