use of org.reflections.scanners.FieldAnnotationsScanner in project ocvn by devgateway.
the class ReflectionsConfiguration method reflections.
@Bean
public Reflections reflections() {
logger.debug("Starting reflections scanners...");
Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.devgateway.ocds.persistence.mongo")).setScanners(new SubTypesScanner(), new FieldAnnotationsScanner(), new MethodParameterScanner()));
logger.debug("Configured reflections bean.");
return reflections;
}
use of org.reflections.scanners.FieldAnnotationsScanner in project pwm by pwm-project.
the class ControlledPwmServletTest method getClassAndMethods.
private Map<Class<? extends ControlledPwmServlet>, Map<String, Method>> getClassAndMethods() {
Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("password.pwm")).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner(), new FieldAnnotationsScanner()));
Set<Class<? extends ControlledPwmServlet>> classes = reflections.getSubTypesOf(ControlledPwmServlet.class);
final Map<Class<? extends ControlledPwmServlet>, Map<String, Method>> returnMap = new HashMap<>();
for (final Class<? extends ControlledPwmServlet> controlledPwmServlet : classes) {
if (!Modifier.isAbstract(controlledPwmServlet.getModifiers())) {
final Map<String, Method> annotatedMethods = new HashMap<>();
for (Method method : JavaHelper.getAllMethodsForClass(controlledPwmServlet)) {
if (method.getAnnotation(ControlledPwmServlet.ActionHandler.class) != null) {
final String actionName = method.getAnnotation(ControlledPwmServlet.ActionHandler.class).action();
annotatedMethods.put(actionName, method);
}
}
returnMap.put(controlledPwmServlet, Collections.unmodifiableMap(annotatedMethods));
}
}
return Collections.unmodifiableMap(returnMap);
}
use of org.reflections.scanners.FieldAnnotationsScanner in project pwm by pwm-project.
the class RestServletTest method getClasses.
private Set<Class<? extends RestServlet>> getClasses() {
Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("password.pwm")).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner(), new FieldAnnotationsScanner()));
Set<Class<? extends RestServlet>> classes = reflections.getSubTypesOf(RestServlet.class);
return Collections.unmodifiableSet(classes);
}
use of org.reflections.scanners.FieldAnnotationsScanner in project disconf by knightliao.
the class ReflectionScanStatic method getReflection.
/**
* 通过扫描,获取反射对象
*/
private Reflections getReflection(List<String> packNameList) {
//
// filter
//
FilterBuilder filterBuilder = new FilterBuilder().includePackage(Constants.DISCONF_PACK_NAME);
for (String packName : packNameList) {
filterBuilder = filterBuilder.includePackage(packName);
}
Predicate<String> filter = filterBuilder;
//
// urls
//
Collection<URL> urlTotals = new ArrayList<URL>();
for (String packName : packNameList) {
Set<URL> urls = ClasspathHelper.forPackage(packName);
urlTotals.addAll(urls);
}
//
Reflections reflections = new Reflections(new ConfigurationBuilder().filterInputsBy(filter).setScanners(new SubTypesScanner().filterResultsBy(filter), new TypeAnnotationsScanner().filterResultsBy(filter), new FieldAnnotationsScanner().filterResultsBy(filter), new MethodAnnotationsScanner().filterResultsBy(filter), new MethodParameterScanner()).setUrls(urlTotals));
return reflections;
}
use of org.reflections.scanners.FieldAnnotationsScanner in project reflections by ronmamo.
the class ReflectionUtilsTest method getAllAndReflections.
@Test
public void getAllAndReflections() {
Reflections reflections = new Reflections(TestModel.class, new FieldAnnotationsScanner());
Set<Field> af1 = reflections.getFieldsAnnotatedWith(TestModel.AF1.class);
Set<? extends Field> allFields = ReflectionUtils.getAll(af1, withModifier(Modifier.PROTECTED));
assertTrue(allFields.size() == 1);
assertThat(allFields, names("f2"));
}
Aggregations