Search in sources :

Example 1 with Scanner

use of com.sun.jersey.core.spi.scanning.Scanner in project platformlayer by platformlayer.

the class JerseyAnnotationDiscovery method scan.

public void scan(URLClassLoader classLoader) {
    Scanner scanner = buildScanner(classLoader);
    AnnotationScannerListener listener = new AnnotationScannerListener(ANNOTATIONS);
    scanner.scan(listener);
    for (Class<?> clazz : listener.getAnnotatedClasses()) {
        for (Class<? extends Annotation> annotation : ANNOTATIONS) {
            if (clazz.isAnnotationPresent(annotation)) {
                AnnotationDictionary annotationDictionary = getAnnotationDictionary(annotation);
                annotationDictionary.add(clazz);
            }
        }
    }
}
Also used : FilesScanner(com.sun.jersey.core.spi.scanning.FilesScanner) Scanner(com.sun.jersey.core.spi.scanning.Scanner) AnnotationScannerListener(com.sun.jersey.spi.scanning.AnnotationScannerListener)

Example 2 with Scanner

use of com.sun.jersey.core.spi.scanning.Scanner in project platformlayer by platformlayer.

the class JerseyAnnotationDiscovery method buildScanner.

private Scanner buildScanner(URLClassLoader classLoader) {
    List<File> paths = Lists.newArrayList();
    for (URL url : classLoader.getURLs()) {
        if (!"file".equals(url.getProtocol())) {
            continue;
        }
        paths.add(new File(url.getFile()));
    }
    Scanner scanner = new FilesScanner(paths.toArray(new File[paths.size()]));
    return scanner;
}
Also used : FilesScanner(com.sun.jersey.core.spi.scanning.FilesScanner) Scanner(com.sun.jersey.core.spi.scanning.Scanner) FilesScanner(com.sun.jersey.core.spi.scanning.FilesScanner) File(java.io.File) URL(java.net.URL)

Aggregations

FilesScanner (com.sun.jersey.core.spi.scanning.FilesScanner)2 Scanner (com.sun.jersey.core.spi.scanning.Scanner)2 AnnotationScannerListener (com.sun.jersey.spi.scanning.AnnotationScannerListener)1 File (java.io.File)1 URL (java.net.URL)1