org.reflections.Configuration Java Examples

The following examples show how to use org.reflections.Configuration. 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 File: DocStringExtractor.java    From armeria with 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 File: ParameterParsingChain.java    From gauge-java with 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 File: DatabaseJobHistoryStore.java    From incubator-gobblin with 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 File: JarManagerService.java    From DBus with Apache License 2.0 4 votes vote down vote up
public ReflectionsPluginScanner(Configuration configuration) {
    super(configuration);
}
 
Example #5
Source File: PluginManager.java    From DBus with Apache License 2.0 4 votes vote down vote up
public ReflectionsPluginScanner(Configuration configuration) {
    super(configuration);
}