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);
}
Aggregations