Search in sources :

Example 6 with AnnotationScannerListener

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

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