use of org.apache.catalina.startup.WebappServiceLoader in project meecrowave by apache.
the class MeecrowaveContextConfig method processServletContainerInitializers.
@Override
protected void processServletContainerInitializers() {
// use our finder
if (!configuration.isTomcatScanning()) {
return;
}
try {
new WebappServiceLoader<ServletContainerInitializer>(context).load(ServletContainerInitializer.class).forEach(sci -> {
final Set<Class<?>> classes = new HashSet<>();
initializerClassMap.put(sci, classes);
final HandlesTypes ht;
try {
ht = sci.getClass().getAnnotation(HandlesTypes.class);
} catch (final Exception | NoClassDefFoundError e) {
return;
}
if (ht == null) {
return;
}
Stream.of(ht.value()).forEach(t -> {
if (t.isAnnotation()) {
final Class<? extends Annotation> annotation = Class.class.cast(t);
classes.addAll(finder.findAnnotatedClasses(annotation));
} else if (t.isInterface()) {
classes.addAll(finder.findImplementations(t));
} else {
classes.addAll(finder.findSubclasses(t));
}
});
});
} catch (final IOException e) {
ok = false;
}
}
Aggregations