use of org.reflections.scanners.SubTypesScanner in project asterixdb by apache.
the class TypeComputerTest method test.
@Test
public void test() throws Exception {
// Several exceptional type computers.
Set<String> exceptionalTypeComputers = new HashSet<>();
exceptionalTypeComputers.add("InjectFailureTypeComputer");
exceptionalTypeComputers.add("RecordAddFieldsTypeComputer");
exceptionalTypeComputers.add("OpenRecordConstructorResultType");
exceptionalTypeComputers.add("RecordRemoveFieldsTypeComputer");
exceptionalTypeComputers.add("ClosedRecordConstructorResultType");
exceptionalTypeComputers.add("LocalAvgTypeComputer");
exceptionalTypeComputers.add("BooleanOnlyTypeComputer");
exceptionalTypeComputers.add("AMissingTypeComputer");
exceptionalTypeComputers.add("NullableDoubleTypeComputer");
exceptionalTypeComputers.add("RecordMergeTypeComputer");
exceptionalTypeComputers.add("BooleanOrMissingTypeComputer");
// Tests all usual type computers.
Reflections reflections = new Reflections("org.apache.asterix.om.typecomputer", new SubTypesScanner(false));
Set<Class<? extends IResultTypeComputer>> classes = reflections.getSubTypesOf(IResultTypeComputer.class);
for (Class<? extends IResultTypeComputer> c : classes) {
if (exceptionalTypeComputers.contains(c.getSimpleName()) || Modifier.isAbstract(c.getModifiers())) {
continue;
}
System.out.println("Test type computer: " + c.getName());
Assert.assertTrue(testTypeComputer(c));
}
}
use of org.reflections.scanners.SubTypesScanner in project cas by apereo.
the class ConfigurationMetadataGenerator method locatePropertiesClassForType.
private Class locatePropertiesClassForType(final ClassOrInterfaceType type) {
if (cachedPropertiesClasses.containsKey(type.getNameAsString())) {
return cachedPropertiesClasses.get(type.getNameAsString());
}
final Predicate<String> filterInputs = s -> s.contains(type.getNameAsString());
final Predicate<String> filterResults = s -> s.endsWith(type.getNameAsString());
final String packageName = ConfigurationMetadataGenerator.class.getPackage().getName();
final Reflections reflections = new Reflections(new ConfigurationBuilder().filterInputsBy(filterInputs).setUrls(ClasspathHelper.forPackage(packageName)).setScanners(new TypeElementsScanner().includeFields(false).includeMethods(false).includeAnnotations(false).filterResultsBy(filterResults), new SubTypesScanner(false)));
final Class clz = reflections.getSubTypesOf(Serializable.class).stream().filter(c -> c.getSimpleName().equalsIgnoreCase(type.getNameAsString())).findFirst().orElseThrow(() -> new IllegalArgumentException("Cant locate class for " + type.getNameAsString()));
cachedPropertiesClasses.put(type.getNameAsString(), clz);
return clz;
}
use of org.reflections.scanners.SubTypesScanner in project cas by apereo.
the class JpaServiceRegistryConfiguration method jpaServicePackagesToScan.
@Bean
public List<String> jpaServicePackagesToScan() {
final Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(CentralAuthenticationService.NAMESPACE)).setScanners(new SubTypesScanner(false)));
final Set<Class<? extends AbstractRegisteredService>> subTypes = reflections.getSubTypesOf(AbstractRegisteredService.class);
return subTypes.stream().map(t -> t.getPackage().getName()).collect(Collectors.toList());
}
use of org.reflections.scanners.SubTypesScanner in project sldeditor by robward-scisys.
the class RegisterClasses method registerRenderers.
/**
* Register renderer converters.
*
* @param classLoadersList the class loaders list
* @param data the data
*/
private static void registerRenderers(List<ClassLoader> classLoadersList, ConversionData data) {
logger.info("Renderers supported:");
Reflections reflections = new Reflections(new ConfigurationBuilder().setScanners(new SubTypesScanner(false), new ResourcesScanner()).setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))).filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.sldeditor.importdata.esri.renderer"))));
Set<Class<? extends Object>> allClasses = reflections.getSubTypesOf(Object.class);
for (Class<? extends Object> claszz : allClasses) {
try {
if (validClass(claszz, EsriRendererInterface.class)) {
EsriRendererInterface rendererObj = (EsriRendererInterface) claszz.newInstance();
logger.info(rendererObj.getRendererClass().getName());
data.addRenderer(rendererObj);
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
use of org.reflections.scanners.SubTypesScanner in project sldeditor by robward-scisys.
the class RegisterClasses method registerTextBackground.
/**
* Register text background converters.
*
* @param classLoadersList the class loaders list
* @param data the data
*/
private static void registerTextBackground(List<ClassLoader> classLoadersList, ConversionData data) {
logger.info("Text backgrounds supported:");
Reflections reflections = new Reflections(new ConfigurationBuilder().setScanners(new SubTypesScanner(false), new ResourcesScanner()).setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))).filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.sldeditor.importdata.esri.textbackground"))));
Set<Class<? extends Object>> allClasses = reflections.getSubTypesOf(Object.class);
for (Class<? extends Object> claszz : allClasses) {
try {
if (validClass(claszz, EsriTextBackgroundInterface.class)) {
EsriTextBackgroundInterface textBackgroundObj = (EsriTextBackgroundInterface) claszz.newInstance();
logger.info(textBackgroundObj.getBackgroundClass().getName());
data.addTextBackground(textBackgroundObj);
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Aggregations