for (ServletContainerInitializer sc : initializers) {
if(interestList == null) {
interestList = new HashMap<Class<?>, List<Class<? extends ServletContainerInitializer>>>();
}
Class<? extends ServletContainerInitializer> sciClass = sc.getClass();
HandlesTypes ann = (HandlesTypes) sciClass.getAnnotation(HandlesTypes.class);
if(ann == null) {
// This initializer does not contain @HandlesTypes
// This means it should always be called for all web apps
// So map it with a special token
List<Class<? extends ServletContainerInitializer>> currentInitializerList =
interestList.get(ServletContainerInitializerUtil.class);
if(currentInitializerList == null) {
List<Class<? extends ServletContainerInitializer>> arr =
new ArrayList<Class<? extends ServletContainerInitializer>>();
arr.add(sciClass);
interestList.put(ServletContainerInitializerUtil.class, arr);
} else {
currentInitializerList.add(sciClass);
}
} else {
Class[] interestedClasses = ann.value();
if( (interestedClasses != null) && (interestedClasses.length != 0) ) {
for(Class c : interestedClasses) {
List<Class<? extends ServletContainerInitializer>> currentInitializerList =
interestList.get(c);
if(currentInitializerList == null) {