本文整理匯總了Java中org.reflections.util.FilterBuilder.include方法的典型用法代碼示例。如果您正苦於以下問題:Java FilterBuilder.include方法的具體用法?Java FilterBuilder.include怎麽用?Java FilterBuilder.include使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.reflections.util.FilterBuilder
的用法示例。
在下文中一共展示了FilterBuilder.include方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GuiceApplication
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
protected GuiceApplication(String... basePackages) {
final ConfigurationBuilder confBuilder = new ConfigurationBuilder();
final FilterBuilder filterBuilder = new FilterBuilder();
if (basePackages.length == 0) {
basePackages = new String[] {};
}
logger.info("op=create, auto_scan_packages={}", (Object[]) basePackages);
for (String pkg : basePackages) {
confBuilder.addUrls(ClasspathHelper.forPackage(pkg));
filterBuilder.include(FilterBuilder.prefix(pkg));
}
confBuilder.filterInputsBy(filterBuilder)
.setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());
this.reflections = new Reflections(confBuilder);
}
示例2: createReflections
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
/**
* Creates a {@link org.reflections.Reflections} with the given packages (configuration)
*
* @param scanPackages
*/
private void createReflections(String[] scanPackages) {
if (scanPackages.length < 1) {
LOGGER.warn("No package defined in configuration (scanPackages)!");
return;
}
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
FilterBuilder filterBuilder = new FilterBuilder();
for (String packageName : scanPackages) {
configurationBuilder.addUrls(ClasspathHelper.forPackage(packageName));
filterBuilder.include(FilterBuilder.prefix(packageName));
}
configurationBuilder.filterInputsBy(filterBuilder).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());
this.reflections = new Reflections(configurationBuilder);
}
示例3: buildReflections
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
private Reflections buildReflections(String packages) {
String[] packagesArray = packages.replaceAll(" ", "").split(",");
FilterBuilder filter = new FilterBuilder();
Set<URL> urls = new HashSet();
for (String packageStr : packagesArray) {
urls.addAll(ClasspathHelper.forPackage(packageStr));
filter.include(FilterBuilder.prefix(packageStr));
}
return new Reflections(new ConfigurationBuilder()
.addUrls(urls)
.filterInputsBy(filter)
.setScanners(new TypeAnnotationsScanner(), new SubTypesScanner()));
}
示例4: findFactories
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
public List<RuleFactory> findFactories(List<String> packages) {
List<RuleFactory> resultL = new ArrayList<>();
FilterBuilder fb = new FilterBuilder();
for(String packageName: packages) {
fb.include(FilterBuilder.prefix(packageName));
}
try {
doPackage(fb, resultL);
} catch (Exception e) {
e.printStackTrace();
}
return resultL;
}
示例5: getDataMapperNames
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
@Override
public List<String> getDataMapperNames() {
List<ClassLoader> classLoadersList = new LinkedList<>();
classLoadersList.add(ClasspathHelper.contextClassLoader());
classLoadersList.add(ClasspathHelper.staticClassLoader());
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner());
cb.setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])));
FilterBuilder fb = new FilterBuilder();
for (Package aPackage : getSearchPackages()) {
fb.include(FilterBuilder.prefix(aPackage.getName()));
}
cb.filterInputsBy(fb);
Reflections reflections = new Reflections(cb);
Set<Class<?>> subTypesOf =
reflections.getSubTypesOf(Object.class);
ArrayList<String> collected = subTypesOf.stream()
.map(Class::getSimpleName)
.collect(Collectors.toCollection(ArrayList::new));
return collected;
}
示例6: buildPackagePredicates
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
private Predicate<String> buildPackagePredicates() {
FilterBuilder filterBuilder = new FilterBuilder();
// Include package names
for (String packageName : options.getModelPackages()) {
filterBuilder.include(FilterBuilder.prefix(packageName));
}
// Exclude class names
for (String excludedClassName : options.getExcludedClasses()) {
filterBuilder.exclude("^" + StringUtils.replace(excludedClassName, ".", "\\.") + "\\.class$");
}
return filterBuilder;
}
示例7: addPackage
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
public void addPackage(String packageName) {
ConfigurationBuilder config = new ConfigurationBuilder();
FilterBuilder fb = new FilterBuilder();
fb.include(FilterBuilder.prefix(packageName));
config.filterInputsBy(fb);
Set<URL> urls = ClasspathHelper.forPackage(packageName);
urls = GoogleReflectionsUtil.fixURLs(urls); //jboss compatibility hack
config.setUrls(urls);
Reflections packageReflections = new Reflections(config);
//packageReflections = new Reflections(packageName);
reflections.merge(packageReflections);
refresh();
}
示例8: scan
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
/**
*
* @param pathsToScan the locations to scan for .class files
* @param packagePrefixes the whitelist of package prefixes to scan
* @param parentResult if there was a prescan, its result
* @return the merged scan
*/
static ScanResult scan(Collection<URL> pathsToScan, Collection<String> packagePrefixes, Collection<String> scannedClasses, Collection<String> scannedAnnotations, ScanResult parentResult) {
Stopwatch watch = Stopwatch.createStarted();
try {
AnnotationScanner annotationScanner = new AnnotationScanner(scannedAnnotations);
SubTypesScanner subTypesScanner = new SubTypesScanner(parentResult.getImplementations());
if (packagePrefixes.size() > 0) {
final FilterBuilder filter = new FilterBuilder();
for (String prefix : packagePrefixes) {
filter.include(FilterBuilder.prefix(prefix));
}
ConfigurationBuilder conf = new ConfigurationBuilder()
.setUrls(pathsToScan)
.setMetadataAdapter(METADATA_ADAPTER) // Scanners depend on this
.filterInputsBy(filter)
.setScanners(annotationScanner, subTypesScanner);
// scans stuff, but don't use the funky storage layer
new Reflections(conf);
}
List<ParentClassDescriptor> implementations = new ArrayList<>();
for (String baseTypeName: scannedClasses) {
implementations.add(
new ParentClassDescriptor(
baseTypeName,
new ArrayList<>(subTypesScanner.getChildrenOf(baseTypeName))));
}
List<AnnotatedClassDescriptor> annotated = annotationScanner.getAnnotatedClasses();
verifyClassUnicity(annotated, pathsToScan);
return new ScanResult(
packagePrefixes,
scannedClasses,
scannedAnnotations,
annotated,
implementations);
} finally {
logger.info(
format("Scanning packages %s in locations %s took %dms",
packagePrefixes, pathsToScan, watch.elapsed(MILLISECONDS)));
}
}
示例9: testFindLogicObjectsWithReflections
import org.reflections.util.FilterBuilder; //導入方法依賴的package包/類
@Test
public void testFindLogicObjectsWithReflections() {
ConfigurationBuilder config = new ConfigurationBuilder();
FilterBuilder fb = new FilterBuilder();
fb.include(FilterBuilder.prefix("org.logicobjects"));
//fb.include(FilterBuilder.prefix("iv4e"));
//fb.include(FilterBuilder.prefix("bin"));
config.filterInputsBy(fb);
//config.addUrls(ClasspathHelper.forClassLoader());
//config.setUrls(ClasspathHelper.forPackage("logicobjects"));
config.setUrls(ClasspathHelper.forPackage("org.logicobjects"));
Reflections system_reflections = new Reflections(config);
//Reflections system_reflections2 = new Reflections("logicobjects");
Set<Class<?>> classes = system_reflections.getTypesAnnotatedWith(LObject.class);
System.out.println("printing logic classes: ");
System.out.println("Number of classes: " + classes.size());
for(Class clazz : classes) {
System.out.println("Logic class: "+clazz.getName());
}
System.out.println("done ...");
}