Search in sources :

Example 1 with AnnotationScannerListener

use of com.sun.jersey.spi.scanning.AnnotationScannerListener 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 AnnotationScannerListener

use of com.sun.jersey.spi.scanning.AnnotationScannerListener in project coprhd-controller by CoprHD.

the class PackageScanner method getModelClasses.

@SuppressWarnings("unchecked")
protected Collection<Class<?>> getModelClasses(Class<? extends Annotation>... annotations) {
    PackageNamesScanner clazzScanner = new PackageNamesScanner(this.packages);
    AnnotationScannerListener scannerListener = new AnnotationScannerListener(annotations);
    clazzScanner.scan(scannerListener);
    return scannerListener.getAnnotatedClasses();
}
Also used : PackageNamesScanner(com.sun.jersey.core.spi.scanning.PackageNamesScanner) AnnotationScannerListener(com.sun.jersey.spi.scanning.AnnotationScannerListener)

Example 3 with AnnotationScannerListener

use of com.sun.jersey.spi.scanning.AnnotationScannerListener in project coprhd-controller by CoprHD.

the class PackageScanner method scan.

/**
 * Scan model classes and load up CF information from them
 */
@SuppressWarnings("unchecked")
public void scan(Class<? extends Annotation>... annotations) {
    AnnotationScannerListener scannerListener = new AnnotationScannerListener(annotations);
    _scanner.scan(scannerListener);
    Iterator<Class<?>> it = scannerListener.getAnnotatedClasses().iterator();
    while (it.hasNext()) {
        processClass(it.next());
    }
}
Also used : AnnotationScannerListener(com.sun.jersey.spi.scanning.AnnotationScannerListener)

Example 4 with AnnotationScannerListener

use of com.sun.jersey.spi.scanning.AnnotationScannerListener in project coprhd-controller by CoprHD.

the class Documenter method getMessageBundleClasses.

@SuppressWarnings("unchecked")
public static List<Class<?>> getMessageBundleClasses() {
    final PackageNamesScanner scanner = new PackageNamesScanner(PACKAGES);
    final AnnotationScannerListener scannerListener = new AnnotationScannerListener(MessageBundle.class);
    scanner.scan(scannerListener);
    final List<Class<?>> list = new ArrayList<Class<?>>();
    for (final Class<?> clazz : scannerListener.getAnnotatedClasses()) {
        if (clazz.isEnum()) {
            continue;
        }
        list.add(clazz);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) PackageNamesScanner(com.sun.jersey.core.spi.scanning.PackageNamesScanner) AnnotationScannerListener(com.sun.jersey.spi.scanning.AnnotationScannerListener)

Example 5 with AnnotationScannerListener

use of com.sun.jersey.spi.scanning.AnnotationScannerListener in project joynr by bmwcarit.

the class AbstractJoynrServletModule method bindAnnotatedFilters.

/**
 * Sets up filters that are annotated with the {@link WebFilter} annotation.
 * Every class in the classpath is searched for the annotation.
 */
@SuppressWarnings("unchecked")
private void bindAnnotatedFilters() {
    String appsPackages = null;
    if (System.getProperties().containsKey(IO_JOYNR_APPS_PACKAGES)) {
        logger.info("Using property {} from system properties", IO_JOYNR_APPS_PACKAGES);
        appsPackages = System.getProperty(IO_JOYNR_APPS_PACKAGES);
    } else {
        Properties servletProperties = PropertyLoader.loadProperties("servlet.properties");
        if (servletProperties.containsKey(IO_JOYNR_APPS_PACKAGES)) {
            appsPackages = servletProperties.getProperty(IO_JOYNR_APPS_PACKAGES);
        }
    }
    if (appsPackages != null) {
        String[] packageNames = appsPackages.split(";");
        logger.info("Searching packages for @WebFilter annotation: {}", Arrays.toString(packageNames));
        PackageNamesScanner scanner = new PackageNamesScanner(packageNames);
        AnnotationScannerListener sl = new AnnotationScannerListener(WebFilter.class);
        scanner.scan(sl);
        for (Class<?> webFilterAnnotatedClass : sl.getAnnotatedClasses()) {
            if (Filter.class.isAssignableFrom(webFilterAnnotatedClass)) {
                bind(webFilterAnnotatedClass).in(Singleton.class);
                filter("/*").through((Class<? extends Filter>) webFilterAnnotatedClass);
                logger.info("Adding filter {} for '/*'", webFilterAnnotatedClass.getName());
            }
        }
    }
}
Also used : Properties(java.util.Properties) PackageNamesScanner(com.sun.jersey.core.spi.scanning.PackageNamesScanner) AnnotationScannerListener(com.sun.jersey.spi.scanning.AnnotationScannerListener)

Aggregations

AnnotationScannerListener (com.sun.jersey.spi.scanning.AnnotationScannerListener)6 PackageNamesScanner (com.sun.jersey.core.spi.scanning.PackageNamesScanner)4 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)1 FilesScanner (com.sun.jersey.core.spi.scanning.FilesScanner)1 Scanner (com.sun.jersey.core.spi.scanning.Scanner)1 IntrospectionException (java.beans.IntrospectionException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1