Search in sources :

Example 1 with BaseFileSystem

use of com.alibaba.alink.common.io.filesystem.BaseFileSystem in project Alink by alibaba.

the class AnnotationUtils method loadFileSystemClasses.

@SuppressWarnings("unchecked")
private static Map<String, Class<? extends BaseFileSystem<?>>> loadFileSystemClasses() {
    Reflections reflections = new Reflections("com.alibaba.alink");
    Map<String, Class<? extends BaseFileSystem<?>>> map = new HashMap<>();
    Set<Class<?>> set = reflections.getTypesAnnotatedWith(FSAnnotation.class);
    for (Class<?> clazz : set) {
        if (!BaseFileSystem.class.isAssignableFrom(clazz)) {
            LOG.error("DB class annotated with @DBAnnotation should be subclass of BaseDB: {}", clazz.getCanonicalName());
            continue;
        }
        FSAnnotation annotation = clazz.getAnnotation(FSAnnotation.class);
        String name = annotation.name();
        Class<? extends BaseFileSystem<?>> origin = map.put(name, (Class<? extends BaseFileSystem<?>>) clazz);
        if (origin != null) {
            LOG.error("Multiple DB class with same name {}: {} and {}", name, origin.getCanonicalName(), clazz.getCanonicalName());
        }
    }
    return ImmutableMap.copyOf(map);
}
Also used : HashMap(java.util.HashMap) BaseFileSystem(com.alibaba.alink.common.io.filesystem.BaseFileSystem) Reflections(org.reflections.Reflections)

Aggregations

BaseFileSystem (com.alibaba.alink.common.io.filesystem.BaseFileSystem)1 HashMap (java.util.HashMap)1 Reflections (org.reflections.Reflections)1