use of org.reflections.Reflections in project che by eclipse.
the class IDEInjectorGenerator method findGinModules.
/**
* Find all the Java files that have ExtensionGinModule annotation
*
* @throws IOException
*/
@SuppressWarnings("unchecked")
public static void findGinModules(File rootFolder) throws IOException {
Reflections reflection = new Reflections(getConfigurationBuilder());
Set<Class<?>> classes = reflection.getTypesAnnotatedWith(ExtensionGinModule.class);
for (Class clazz : classes) {
EXTENSIONS_FQN.add(clazz.getCanonicalName());
System.out.println(String.format("New Gin Module Found: %s", clazz.getCanonicalName()));
}
System.out.println(String.format("Found: %d Gin Modules", EXTENSIONS_FQN.size()));
}
use of org.reflections.Reflections in project Gaffer by gchq.
the class StreamUtil method openStreams.
public static InputStream[] openStreams(final Class clazz, final String folderPath, final boolean logErrors) {
if (null == folderPath) {
return new InputStream[0];
}
String folderPathChecked = folderPath;
if (!folderPathChecked.endsWith("/")) {
folderPathChecked = folderPathChecked + "/";
}
if (folderPathChecked.startsWith("/")) {
folderPathChecked = folderPathChecked.substring(1);
}
final Set<String> schemaFiles = new Reflections(new ConfigurationBuilder().setScanners(new ResourcesScanner()).setUrls(ClasspathHelper.forClass(clazz))).getResources(Pattern.compile(".*"));
final Iterator<String> itr = schemaFiles.iterator();
while (itr.hasNext()) {
if (!itr.next().startsWith(folderPathChecked)) {
itr.remove();
}
}
int index = 0;
final InputStream[] schemas = new InputStream[schemaFiles.size()];
for (final String schemaFile : schemaFiles) {
schemas[index] = openStream(clazz, schemaFile, logErrors);
index++;
}
return schemas;
}
use of org.reflections.Reflections in project kafka by apache.
the class PluginDiscovery method scanClasspathForPlugins.
public static synchronized void scanClasspathForPlugins() {
if (scanned)
return;
ReflectionsUtil.registerUrlTypes();
final Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forJavaClassPath()));
validConnectorPlugins = Collections.unmodifiableList(connectorPlugins(reflections));
validTransformationPlugins = Collections.unmodifiableList(transformationPlugins(reflections));
scanned = true;
}
use of org.reflections.Reflections in project deeplearning4j by deeplearning4j.
the class PlayUIServer method getCustomUIModules.
private List<UIModule> getCustomUIModules(List<Class<?>> excludeClasses) {
//Scan classpath for UI module instances, but ignore the 'excludeClasses' classes
List<String> classNames = Collections.singletonList(UIModule.class.getName());
Reflections reflections = new Reflections();
org.reflections.Store store = reflections.getStore();
Iterable<String> subtypesByName = store.getAll(org.reflections.scanners.SubTypesScanner.class.getSimpleName(), classNames);
Set<? extends Class<?>> subtypeClasses = Sets.newHashSet(ReflectionUtils.forNames(subtypesByName));
List<Class<?>> toCreate = new ArrayList<>();
for (Class<?> c : subtypeClasses) {
if (excludeClasses.contains(c))
continue;
;
toCreate.add(c);
}
List<UIModule> ret = new ArrayList<>(toCreate.size());
for (Class<?> c : toCreate) {
UIModule m;
try {
m = (UIModule) c.newInstance();
} catch (Exception e) {
log.warn("Could not create instance of custom UIModule of type {}; skipping", c, e);
continue;
}
log.debug("Created instance of custom UI module: {}", c);
ret.add(m);
}
return ret;
}
use of org.reflections.Reflections in project querydsl by querydsl.
the class ClassPathUtils method scanPackage.
/**
* Return the classes from the given package and subpackages using the supplied classloader
*
* @param classLoader classloader to be used
* @param pkg package to scan
* @return set of found classes
* @throws IOException
*/
public static Set<Class<?>> scanPackage(ClassLoader classLoader, String pkg) throws IOException {
Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(ClasspathHelper.forPackage(pkg, classLoader)).addClassLoader(classLoader).setScanners(new SubTypesScanner(false)));
Set<Class<?>> classes = new HashSet<Class<?>>();
for (String typeNames : reflections.getStore().get(SubTypesScanner.class.getSimpleName()).values()) {
Class<?> clazz = safeClassForName(classLoader, typeNames);
if (clazz != null) {
classes.add(clazz);
}
}
return classes;
}
Aggregations