com.liubs.shadowrpcfly.server.util.AnnotationScanner Maven / Gradle / Ivy
package com.liubs.shadowrpcfly.server.util;
import com.liubs.shadowrpcfly.logging.Logger;
import com.liubs.shadowrpcfly.server.annotation.ShadowServiceHolder;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author Liubsyy
* @date 2023/12/12 21:54
*/
public class AnnotationScanner {
private static final Logger logger = Logger.getLogger(AnnotationScanner.class);
public static List> scanAnnotations(String packageName, Class annotation) throws IOException {
List> allResults = new ArrayList<>();
Set> classes = PackageScanUtil.scanClasses(packageName, annotation);
classes.forEach(clazz->{
T shadowServiceAnno = clazz.getAnnotation(annotation);
if (shadowServiceAnno != null) {
allResults.add(new ShadowServiceHolder<>(shadowServiceAnno, clazz));
}
});
logger.info("scanAnnotations="+allResults);
return allResults;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy