Search in sources :

Example 1 with AnnotationDetector

use of org.atmosphere.util.annotation.AnnotationDetector in project atmosphere by Atmosphere.

the class DefaultAnnotationProcessor method scanForAnnotation.

private void scanForAnnotation(AtmosphereFramework f) {
    List<String> packages = f.customAnnotationPackages();
    AnnotationDetector detector = new AnnotationDetector(atmosphereReporter);
    try {
        if (!packages.isEmpty()) {
            for (String p : packages) {
                logger.trace("Package {} scanned for @AtmosphereAnnotation", p);
                detector.detect(p);
            }
        }
        // Now look for application defined annotation
        String path = IOUtils.realPath(f.getServletContext(), f.getHandlersPath());
        if (path != null) {
            detector.detect(new File(path));
        }
        String pathLibs = IOUtils.realPath(f.getServletContext(), f.getLibPath());
        if (pathLibs != null) {
            File libFolder = new File(pathLibs);
            File[] jars = libFolder.listFiles(new FilenameFilter() {

                @Override
                public boolean accept(File arg0, String arg1) {
                    return arg1.endsWith(".jar");
                }
            });
            if (jars != null) {
                for (File file : jars) {
                    detector.detect(file);
                }
            }
        }
        // https://github.com/Atmosphere/atmosphere/issues/1292
        if (!coreAnnotationsFound.get()) {
            fallbackToManualAnnotatedClasses(getClass(), f, handler);
        }
    } catch (IOException e) {
        logger.warn("Unable to scan annotation", e);
    } finally {
        detector.destroy();
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) AnnotationDetector(org.atmosphere.util.annotation.AnnotationDetector) IOException(java.io.IOException) File(java.io.File)

Aggregations

File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 AnnotationDetector (org.atmosphere.util.annotation.AnnotationDetector)1