use of org.reflections.scanners.SubTypesScanner in project kanonizo by kanonizo.
the class Util method getReflections.
public static Reflections getReflections() {
if (r == null) {
Set<URL> packages = new HashSet<>(ClasspathHelper.forPackage("org.kanonizo"));
packages.addAll(ClasspathHelper.forPackage("com.scythe"));
r = new Reflections(new ConfigurationBuilder().setUrls(packages).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner(), new FieldAnnotationsScanner()));
}
return r;
}
use of org.reflections.scanners.SubTypesScanner in project nd4j by deeplearning4j.
the class BasicNDArrayCompressor method loadCompressors.
protected void loadCompressors() {
/*
We scan classpath for NDArrayCompressor implementations and add them one by one to codecs map
*/
codecs = new ConcurrentHashMap<>();
Set<Class<? extends NDArrayCompressor>> classes = new Reflections(new ConfigurationBuilder().filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("org.nd4j")).exclude(// Consider only .class files (to avoid debug messages etc. on .dlls, etc
"^(?!.*\\.class$).*$")).setUrls(ClasspathHelper.forPackage("org.nd4j")).setScanners(new SubTypesScanner())).getSubTypesOf(NDArrayCompressor.class);
for (Class<? extends NDArrayCompressor> impl : classes) {
if (Modifier.isAbstract(impl.getModifiers()) || impl.isInterface())
continue;
try {
NDArrayCompressor compressor = impl.newInstance();
codecs.put(compressor.getDescriptor().toUpperCase(), compressor);
} catch (InstantiationException i) {
// we need catch there, to avoid exceptions at abstract classes
;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
use of org.reflections.scanners.SubTypesScanner in project serenity-jbehave by serenity-bdd.
the class ClassFinder method annotatedClassesInPackage.
public List<Class<?>> annotatedClassesInPackage(String packageName) {
Reflections reflections = new Reflections(packageName, new SubTypesScanner(), new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new ResourcesScanner(), getClassLoader());
Set<Class<?>> matchingClasses = new HashSet<>();
for (Class<? extends Annotation> expectedAnnotation : expectedAnnotations) {
matchingClasses.addAll(reflections.getTypesAnnotatedWith(expectedAnnotation));
matchingClasses.addAll(classesFrom(reflections.getMethodsAnnotatedWith(expectedAnnotation)));
}
return ImmutableList.copyOf(matchingClasses);
}
use of org.reflections.scanners.SubTypesScanner in project motech by motech.
the class ReflectionsUtil method getMdsInterfaces.
/**
* Finds all interfaces that extend the {@link MotechDataService} interface.
*
* @param bundle A bundle to look in.
* @return a list of classes that extend the MotechDataService interface.
*/
public static List<Class<? extends MotechDataService>> getMdsInterfaces(Bundle bundle) {
LOGGER.debug("Looking for MDS interfaces in bundle: {}", bundle.getSymbolicName());
Reflections reflections = configureReflection(bundle, new WrappedBundleClassLoader(bundle), new SubTypesScanner());
Set<Class<? extends MotechDataService>> set = reflections.getSubTypesOf(MotechDataService.class);
return new ArrayList<>(set);
}
use of org.reflections.scanners.SubTypesScanner in project apache-kafka-on-k8s by banzaicloud.
the class DelegatingClassLoader method scanPluginPath.
private PluginScanResult scanPluginPath(ClassLoader loader, URL[] urls) throws InstantiationException, IllegalAccessException {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setClassLoaders(new ClassLoader[] { loader });
builder.addUrls(urls);
builder.setScanners(new SubTypesScanner());
builder.useParallelExecutor();
Reflections reflections = new InternalReflections(builder);
return new PluginScanResult(getPluginDesc(reflections, Connector.class, loader), getPluginDesc(reflections, Converter.class, loader), getPluginDesc(reflections, HeaderConverter.class, loader), getPluginDesc(reflections, Transformation.class, loader));
}
Aggregations