本文整理汇总了Java中org.reflections.util.ConfigurationBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationBuilder.build方法的具体用法?Java ConfigurationBuilder.build怎么用?Java ConfigurationBuilder.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.reflections.util.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.build方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
@Override
public ReflectionsWrapper configure() {
reflections = (Reflections) cache.get(Reflections.class.getName());
if (reflections == null) {
ConfigurationBuilder cb = new ConfigurationBuilder();
Set<URL> classLocations = new LinkedHashSet<>();
try {
List<URL> urls = Collections.list(Thread.currentThread().getContextClassLoader().getResources(""));
for (URL url : urls) {
if (url.getPath().contains("/geemvc/target/")) {
classLocations.add(url);
}
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
cb = cb.addUrls(classLocations).addClassLoader(Thread.currentThread().getContextClassLoader());
cb = cb.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new SubTypesScanner());
reflections = cb.build();
// Reflections cachedReflections = (Reflections)
cache.putIfAbsent(Reflections.class.getName(), reflections);
// if (cachedReflections != null)
// reflections = cachedReflections;
}
return this;
}
示例2: getConfigurationBuilder
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
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;
}
示例3: addPluginSource
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public void addPluginSource(File file) throws InvalidPluginException {
try {
URL url = file.toURI().toURL();
URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{url});
Reflections reflections = new Reflections(ConfigurationBuilder.build(urlClassLoader, url));
workflowPluginClasses.addAll(reflections.getSubTypesOf(AlfredWorkflowPlugin.class));
workflowPluginClasses.addAll(reflections.getSubTypesOf(AbstractWorkflowPlugin.class));
} catch (MalformedURLException e) {
throw new InvalidPluginException(String.format("Invalid plugin: %s.", file.getPath()), e);
}
}
示例4: addClasses
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public void addClasses(ClassLoader classLoader, String packageName, Class<? extends Annotation> annotation) {
checkNotNull(classLoader);
checkNotNull(packageName);
checkNotNull(annotation);
ConfigurationBuilder configurationBuilder = ConfigurationBuilder.build(packageName, classLoader);
Reflections reflections = new Reflections(configurationBuilder);
classes.addAll(reflections.getTypesAnnotatedWith(annotation));
}
示例5: provide
import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
@Override
public Reflections provide() {
Reflections reflections = null;
try {
ConfigurationBuilder cb = new ConfigurationBuilder();
URL webappClassesPath = webappClassesPath();
URL geemvcLibPath = geemvcLibPath();
// TODO: Offer configuration for extra libs.
URL gensonLibPath = gensonLibPath();
cb = cb.addUrls(webappClassesPath, geemvcLibPath).addClassLoader(mainClassLoader());
if (gensonLibPath != null && !isExcluded(gensonLibPath.getPath())) {
cb = cb.addUrls(gensonLibPath);
}
// Add configured libraries configured.
cb = addConfiguredIncludes(cb);
// Give the developer a chance to add his own URLs.
Set<URL> urls = appendURLs();
if (urls != null && !urls.isEmpty()) {
for (URL url : urls) {
if (url != null) {
cb = cb.addUrls(url);
}
}
}
// Give the developer a chance to add his own class-loaders.
Set<ClassLoader> classLoaders = appendClassLoaders();
if (classLoaders != null && !classLoaders.isEmpty()) {
cb = cb.addClassLoaders(classLoaders);
}
// Set all scanners. Can be changed in the extend() method if necessary.
cb = cb.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new SubTypesScanner());
// Give the developer a chance to extend the ConfigurationBuilder without having to re-implement the whole class.
extend(cb);
// Finally build the reflections.
reflections = cb.build();
} catch (Exception e) {
throw new IllegalStateException(e);
}
return reflections;
}