use of org.reflections.util.ConfigurationBuilder in project swagger-core by swagger-api.
the class ReflectiveJaxrsScanner method getReflections.
protected Reflections getReflections() {
if (reflections == null) {
ConfigurationBuilder config = new ConfigurationBuilder();
acceptablePackages = new HashSet<String>();
if (resourcePackage != "") {
String[] parts = resourcePackage.split(",");
for (String pkg : parts) {
if (!"".equals(pkg)) {
acceptablePackages.add(pkg);
config.addUrls(ClasspathHelper.forPackage(pkg));
}
}
}
config.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new SubTypesScanner());
this.reflections = new Reflections(config);
}
return this.reflections;
}
use of org.reflections.util.ConfigurationBuilder in project ninja by ninjaframework.
the class JaxyRoutes method configureReflections.
private void configureReflections() {
ConfigurationBuilder builder = new ConfigurationBuilder();
Set<URL> packagesToScan = getPackagesToScanForRoutes();
builder.addUrls(packagesToScan);
builder.addScanners(new MethodAnnotationsScanner());
reflections = new Reflections(builder);
}
use of org.reflections.util.ConfigurationBuilder in project cloudstack by apache.
the class ReflectUtil method getClassesWithAnnotation.
// Gets all classes with some annotation from a package
public static Set<Class<?>> getClassesWithAnnotation(Class<? extends Annotation> annotation, String[] packageNames) {
Reflections reflections;
Set<Class<?>> classes = new HashSet<Class<?>>();
ConfigurationBuilder builder = new ConfigurationBuilder();
for (String packageName : packageNames) {
builder.addUrls(ClasspathHelper.forPackage(packageName));
}
builder.setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());
reflections = new Reflections(builder);
classes.addAll(reflections.getTypesAnnotatedWith(annotation));
return classes;
}
use of org.reflections.util.ConfigurationBuilder in project flink by apache.
the class CheckForbiddenMethodsUsage method testNoDefaultEncoding.
@Test
public void testNoDefaultEncoding() throws Exception {
final Reflections reflections = new Reflections(new ConfigurationBuilder().useParallelExecutor(Runtime.getRuntime().availableProcessors()).addUrls(ClasspathHelper.forPackage("org.apache.flink")).addScanners(new MemberUsageScanner()));
for (ForbiddenCall forbiddenCall : forbiddenCalls) {
final Set<Member> methodUsages = forbiddenCall.getUsages(reflections);
methodUsages.removeAll(forbiddenCall.getExclusions());
assertEquals("Unexpected calls: " + methodUsages, 0, methodUsages.size());
}
}
use of org.reflections.util.ConfigurationBuilder 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;
}
Aggregations