当前位置: 首页>>代码示例>>Java>>正文


Java FilterBuilder.include方法代码示例

本文整理汇总了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);
}
 
开发者ID:dehora,项目名称:outland,代码行数:21,代码来源:GuiceApplication.java

示例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);

}
 
开发者ID:robeio,项目名称:robe,代码行数:22,代码来源:GuiceBundle.java

示例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()));
}
 
开发者ID:feroult,项目名称:yawp,代码行数:18,代码来源:ClassloaderScanner.java

示例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;
}
 
开发者ID:ianrae,项目名称:dnal-lang,代码行数:14,代码来源:RuleFactoryFinder.java

示例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;

}
 
开发者ID:virtualdataset,项目名称:metagen-java,代码行数:30,代码来源:FunctionalDataMappingLibrary.java

示例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;
}
 
开发者ID:netceteragroup,项目名称:valdr-bean-validation,代码行数:13,代码来源:ClasspathScanner.java

示例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();
}
 
开发者ID:java-prolog-connectivity,项目名称:logicobjects,代码行数:14,代码来源:ClassPathContext.java

示例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)));
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:48,代码来源:ClassPathScanner.java

示例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 ...");
}
 
开发者ID:java-prolog-connectivity,项目名称:logicobjects,代码行数:33,代码来源:TestReflections.java


注:本文中的org.reflections.util.FilterBuilder.include方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。