Java Code Examples for org.reflections.Configuration

The following examples show how to use org.reflections.Configuration. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: armeria   Source File: DocStringExtractor.java    License: Apache License 2.0 5 votes vote down vote up
private Map<String, String> getAllDocStrings0(ClassLoader classLoader) {
    final Configuration configuration = new ConfigurationBuilder()
            .filterInputsBy(new FilterBuilder().includePackage(path))
            .setUrls(ClasspathHelper.forPackage(path, classLoader))
            .addClassLoader(classLoader)
            .setScanners(new ResourcesScanner());
    if (configuration.getUrls() == null || configuration.getUrls().isEmpty()) {
        // No resource folders were found.
        return ImmutableMap.of();
    }

    final Reflections reflections = new Reflections(configuration);
    final Store store = reflections.getStore();
    if (!store.keySet().contains(ResourcesScanner.class.getSimpleName())) {
        // No resources were found.
        return ImmutableMap.of();
    }

    final Map<String, byte[]> files = reflections
            .getResources(this::acceptFile).stream()
            .map(f -> {
                try {
                    final URL url = classLoader.getResource(f);
                    if (url == null) {
                        throw new IllegalStateException("not found: " + f);
                    }
                    return Maps.immutableEntry(f, Resources.toByteArray(url));
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            })
            .collect(toImmutableMap(Entry::getKey, Entry::getValue));

    return getDocStringsFromFiles(files);
}
 
Example 2
Source Project: gauge-java   Source File: ParameterParsingChain.java    License: Apache License 2.0 5 votes vote down vote up
private Reflections createReflections() {
    Configuration config = new ConfigurationBuilder()
            .setScanners(new SubTypesScanner())
            .addUrls(ClasspathHelper.getUrls())
            .filterInputsBy(new FilterBuilder().include(".+\\.class"));
    return new Reflections(config);
}
 
Example 3
Source Project: incubator-gobblin   Source File: DatabaseJobHistoryStore.java    License: Apache License 2.0 5 votes vote down vote up
private static Configuration getConfigurationBuilder() {
  ConfigurationBuilder configurationBuilder=  ConfigurationBuilder.build("org.apache.gobblin.metastore.database",
      effectiveClassPathUrls(DatabaseJobHistoryStore.class.getClassLoader()));
  List<URL> filteredUrls = Lists.newArrayList(Iterables.filter(configurationBuilder.getUrls(), new Predicate<URL>() {
    @Override
    public boolean apply(@Nullable URL input) {
      return input != null && (!input.getProtocol().equals("file") || new File(input.getFile()).exists());
    }
  }));
  configurationBuilder.setUrls(filteredUrls);
  return configurationBuilder;
}
 
Example 4
Source Project: DBus   Source File: JarManagerService.java    License: Apache License 2.0 4 votes vote down vote up
public ReflectionsPluginScanner(Configuration configuration) {
    super(configuration);
}
 
Example 5
Source Project: DBus   Source File: PluginManager.java    License: Apache License 2.0 4 votes vote down vote up
public ReflectionsPluginScanner(Configuration configuration) {
    super(configuration);
}