本文整理汇总了Java中org.reflections.util.ConfigurationBuilder.setInputsFilter方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationBuilder.setInputsFilter方法的具体用法?Java ConfigurationBuilder.setInputsFilter怎么用?Java ConfigurationBuilder.setInputsFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.reflections.util.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.setInputsFilter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scan
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public static Iterable<URL> scan(String pattern) {
// lookup from classpath
ConfigurationBuilder rcp = new ConfigurationBuilder()//
.setUrls(ClasspathHelper.forClassLoader())//
.setScanners(new ResourcesScanner());
{
String path = pathChar.replaceFrom(pattern, '.');
rcp.setInputsFilter(in -> (false == in.startsWith("java.")) && Wildcard.match(in, path));
}
Set<String> scans = new Reflections(rcp).getResources(Predicates.alwaysTrue());
// transforms strings to urls
return Iterables.transform(scans, res -> getURL(res));
}
示例2: getClasspathResources
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private static Set<String> getClasspathResources(Set<String> filesExtensions)
{
Collection<URL> classpathJars = classpathJars();
System.out.println(classpathJars.size());
classpathJars.forEach(System.out::println);
ConfigurationBuilder configuration = new ConfigurationBuilder()
.setUrls(classpathJars)
.setScanners(new ResourcesScanner());
configuration.setInputsFilter(Assets::isValidResourcePath);
Reflections reflections = new Reflections(configuration);
Set<String> resources = reflections.getResources(getResourcePattern(filesExtensions));
return resources;
}
示例3: getClasspathResources
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public static Set<String> getClasspathResources(Set<String> filesExtensions, Predicate<String> inputsFilter)
{
Collection<URL> classpathJars = getUsedJars();
System.out.println(classpathJars.size());
classpathJars.forEach(System.out::println);
ConfigurationBuilder configuration = new ConfigurationBuilder().setUrls(classpathJars)
.setScanners(new ResourcesScanner());
configuration.setInputsFilter(inputsFilter);
Reflections reflections = new Reflections(configuration);
Set<String> resources = reflections.getResources(getResourcePattern(filesExtensions));
return resources;
}
示例4: searchClasses
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
/**
* This is not entirely reliable method.
* Maybe it would be better to rely on Spring ClassPathScanningCandidateComponentProvider
*/
public static void searchClasses(String packageName, Consumer<Class> consumer) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setScanners(new SubTypesScanner(false));
builder.setUrls(ClasspathHelper.forPackage(packageName, LOGGER.getClass().getClassLoader()));
builder.setInputsFilter(new FilterBuilder().includePackage(packageName));
Reflections reflections = new Reflections(builder);
Multimap<String, String> map = reflections.getStore().get(SubTypesScanner.class.getSimpleName());
Set<String> types = new HashSet<>();
for (String key : map.keySet()) {
Collection<String> col = map.get(key);
if (col == null) {
continue;
}
for (String c : col) {
String simpleName = c.replaceFirst(packageName + "\\.", "");
if (simpleName.contains(".")) {
continue;
}
types.add(c);
}
}
for (String type : types) {
try {
Class clazz = Class.forName(type);
consumer.accept(clazz);
} catch (ClassNotFoundException e) {
LOGGER.error("Error during loading class {}. ", type);
}
}
}