use of com.sun.faces.config.WebConfiguration.WebContextInitParameter.AnnotationScanPackages in project mojarra by eclipse-ee4j.
the class FilterClassesFromFacesInitializerAnnotationProvider method createAnnotatedMap.
// ---------------------------------------------------------- Private Methods
/**
* Go over the annotated set and converter it to a hash map.
*
* @param annotatedMap
* @param annotatedSet
*/
private Map<Class<? extends Annotation>, Set<Class<?>>> createAnnotatedMap(Set<Class<?>> annotatedSet) {
HashMap<Class<? extends Annotation>, Set<Class<?>>> annotatedMap = new HashMap<>();
if (isEmpty(annotatedSet)) {
return annotatedMap;
}
WebConfiguration webConfig = WebConfiguration.getInstance();
boolean annotationScanPackagesSet = webConfig.isSet(AnnotationScanPackages);
String[] annotationScanPackages = annotationScanPackagesSet ? webConfig.getOptionValue(AnnotationScanPackages).split("\\s+") : null;
Iterator<Class<?>> iterator = annotatedSet.iterator();
while (iterator.hasNext()) {
try {
Class<?> clazz = iterator.next();
stream(clazz.getAnnotations()).map(annotation -> annotation.annotationType()).filter(annotationType -> FACES_ANNOTATION_TYPE.contains(annotationType)).forEach(annotationType -> {
Set<Class<?>> classes = annotatedMap.computeIfAbsent(annotationType, e -> new HashSet<>());
if (annotationScanPackagesSet) {
if (matchesAnnotationScanPackages(clazz, annotationScanPackages)) {
classes.add(clazz);
}
} else {
classes.add(clazz);
}
});
} catch (NoClassDefFoundError ncdfe) {
}
}
return annotatedMap;
}
Aggregations