use of org.reflections.Reflections in project zhcet-web by zhcet-amu.
the class Hibernate5DDLExporter method mapAnnotatedClasses.
private MetadataSources mapAnnotatedClasses(ServiceRegistry serviceRegistry) {
MetadataSources sources = new MetadataSources(serviceRegistry);
final Reflections reflections = new Reflections();
for (final Class<?> mappedSuperClass : reflections.getTypesAnnotatedWith(MappedSuperclass.class)) {
sources.addAnnotatedClass(mappedSuperClass);
System.out.println("Mapped = " + mappedSuperClass.getName());
}
for (final Class<?> entityClasses : reflections.getTypesAnnotatedWith(Entity.class)) {
sources.addAnnotatedClass(entityClasses);
System.out.println("Mapped = " + entityClasses.getName());
}
return sources;
}
use of org.reflections.Reflections 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.Reflections 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();
}
}
}
use of org.reflections.Reflections in project cxf by apache.
the class Java2SwaggerMojo method loadResourceClasses.
private Set<Class<?>> loadResourceClasses(Class<? extends Annotation> clazz) throws MojoExecutionException {
resourceClasses = new LinkedHashSet<Class<?>>(this.resourcePackages.size());
Thread.currentThread().setContextClassLoader(getClassLoader());
for (String resourcePackage : resourcePackages) {
Set<Class<?>> c = new Reflections(resourcePackage).getTypesAnnotatedWith(clazz, true);
resourceClasses.addAll(c);
Set<Class<?>> inherited = new Reflections(resourcePackage).getTypesAnnotatedWith(clazz);
resourceClasses.addAll(inherited);
}
return resourceClasses;
}
use of org.reflections.Reflections in project startup-os by google.
the class ClassScanner method scanPackage.
public void scanPackage(String packagePrefix, Map<String, FlagData> flags) {
// TODO - figure out configuration builder.
Reflections reflections = new Reflections(new ConfigurationBuilder().filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(packagePrefix))).setUrls(ClasspathHelper.forPackage(packagePrefix)).setScanners(new FieldAnnotationsScanner()));
Set<Field> fields = reflections.getFieldsAnnotatedWith(FlagDesc.class);
for (Field field : fields) {
Class<?> clazz = field.getType();
if (!Flag.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException("Annotation '" + field + "' does not annotate a flag.");
}
if ((field.getModifiers() & Modifier.STATIC) == 0) {
throw new IllegalArgumentException("Flag '" + field + "' should be static but is not.");
}
Class<?> declaringClass = field.getDeclaringClass();
Flag<?> flag = getFlagMember(declaringClass, field);
FlagData flagData = createFlagData(declaringClass, field, flag);
if (flags.containsKey(flagData.getName())) {
throw new IllegalArgumentException(String.format("Flag '%s' is already defined here:\n%s", field, flags.get(flagData.getName())));
}
flags.put(flagData.getName(), flagData);
flag.setName(flagData.getName());
}
}
Aggregations