Search in sources :

Example 1 with SchemaParser

use of com.thinkbiganalytics.discovery.parser.SchemaParser in project kylo by Teradata.

the class FileParserFactory method listSchemaParsers.

/**
 * Returns a list of available schema parsers. Parsers are guaranteed to be annotated with @SchemaParser and implement FileSchemaParser interface
 *
 * @return a list of file schema parsers
 */
public List<FileSchemaParser> listSchemaParsers() {
    List<FileSchemaParser> supportedParsers = new ArrayList<>();
    List<Class<SchemaParser>> supportedParsersClazzes = listSchemaParsersClasses();
    for (Class<SchemaParser> clazz : supportedParsersClazzes) {
        try {
            FileSchemaParser newInstance = (FileSchemaParser) clazz.newInstance();
            newInstance = (FileSchemaParser) SpringApplicationContext.autowire(newInstance);
            supportedParsers.add(newInstance);
        } catch (InstantiationException | IllegalAccessException e) {
            log.warn("Failed to instantiate registered schema parser [?]. Missing default constructor?", clazz.getAnnotation(SchemaParser.class).name(), e);
        }
    }
    return supportedParsers;
}
Also used : ArrayList(java.util.ArrayList) FileSchemaParser(com.thinkbiganalytics.discovery.parser.FileSchemaParser) FileSchemaParser(com.thinkbiganalytics.discovery.parser.FileSchemaParser) SchemaParser(com.thinkbiganalytics.discovery.parser.SchemaParser)

Aggregations

FileSchemaParser (com.thinkbiganalytics.discovery.parser.FileSchemaParser)1 SchemaParser (com.thinkbiganalytics.discovery.parser.SchemaParser)1 ArrayList (java.util.ArrayList)1