Search in sources :

Example 1 with PackageNamesScanner

use of com.sun.jersey.core.spi.scanning.PackageNamesScanner 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 2 with PackageNamesScanner

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

the class PackageScanner method setPackages.

/**
 * Package where model classes are defined
 *
 * @param packages
 */
public void setPackages(String... packages) {
    this.packages = packages;
    _scanner = new PackageNamesScanner(packages);
}
Also used : PackageNamesScanner(com.sun.jersey.core.spi.scanning.PackageNamesScanner)

Example 3 with PackageNamesScanner

use of com.sun.jersey.core.spi.scanning.PackageNamesScanner 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 4 with PackageNamesScanner

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

Example 5 with PackageNamesScanner

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

the class DBClient method init.

public void init() {
    try {
        System.out.println("Initializing db client ...");
        ctx = new ClassPathXmlApplicationContext("/dbutils-conf.xml");
        InternalDbClientImpl dbClient = (InternalDbClientImpl) ctx.getBean("dbclient");
        _geodbContext = (DbClientContext) ctx.getBean("geodbclientcontext");
        vdcConfHelper = (VdcConfigHelper) ctx.getBean("vdcConfHelper");
        geoEncryptionProvider = (EncryptionProviderImpl) ctx.getBean("geoEncryptionProvider");
        encryptionProvider = (EncryptionProviderImpl) ctx.getBean("encryptionProvider");
        dbClient.setBypassMigrationLock(skipMigrationCheck);
        dbClient.start();
        _dbClient = dbClient;
        // scan for classes with @Cf annotation
        System.out.println("Initializing column family map ...");
        AnnotationScannerListener scannerListener = new AnnotationScannerListener(Cf.class);
        String[] packages = { pkgs };
        PackageNamesScanner scanner = new PackageNamesScanner(packages);
        scanner.scan(scannerListener);
        Iterator<Class<?>> it = scannerListener.getAnnotatedClasses().iterator();
        while (it.hasNext()) {
            Class clazz = it.next();
            // The fields of SchemaRecord don't have Name annotation either.
            if (DataObject.class.isAssignableFrom(clazz)) {
                DataObjectType doType = TypeMap.getDoType(clazz);
                _cfMap.put(doType.getCF().getName(), clazz);
            }
        }
    } catch (Exception e) {
        System.err.println("Caught Exception: " + e);
        log.error("Caught Exception: ", e);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType) PackageNamesScanner(com.sun.jersey.core.spi.scanning.PackageNamesScanner) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) AnnotationScannerListener(com.sun.jersey.spi.scanning.AnnotationScannerListener)

Aggregations

PackageNamesScanner (com.sun.jersey.core.spi.scanning.PackageNamesScanner)5 AnnotationScannerListener (com.sun.jersey.spi.scanning.AnnotationScannerListener)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 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