Search in sources :

Example 1 with WebappServiceLoader

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;
    }
}
Also used : ServletContainerInitializer(javax.servlet.ServletContainerInitializer) WebappServiceLoader(org.apache.catalina.startup.WebappServiceLoader) IOException(java.io.IOException) HandlesTypes(javax.servlet.annotation.HandlesTypes) IOException(java.io.IOException) HashSet(java.util.HashSet)

Aggregations

IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 ServletContainerInitializer (javax.servlet.ServletContainerInitializer)1 HandlesTypes (javax.servlet.annotation.HandlesTypes)1 WebappServiceLoader (org.apache.catalina.startup.WebappServiceLoader)1