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


Java FilterBuilder类代码示例

本文整理汇总了Java中org.reflections.util.FilterBuilder的典型用法代码示例。如果您正苦于以下问题:Java FilterBuilder类的具体用法?Java FilterBuilder怎么用?Java FilterBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FilterBuilder类属于org.reflections.util包,在下文中一共展示了FilterBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: fromConfigWithPackage

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
/**
 * Scans the specified packages for annotated classes, and applies Config values to them.
 * 
 * @param config the Config to derive values from
 * @param packageNamePrefix the prefix to limit scanning to - e.g. "com.github"
 * @return The constructed TypesafeConfigModule.
 */
public static TypesafeConfigModule fromConfigWithPackage(Config config, String packageNamePrefix) {
	 ConfigurationBuilder configBuilder = 
		 new ConfigurationBuilder()
         .filterInputsBy(new FilterBuilder().includePackage(packageNamePrefix))
         .setUrls(ClasspathHelper.forPackage(packageNamePrefix))
         .setScanners(
        	new TypeAnnotationsScanner(), 
        	new MethodParameterScanner(), 
        	new MethodAnnotationsScanner(), 
        	new FieldAnnotationsScanner()
         );
	Reflections reflections = new Reflections(configBuilder);
	
	return new TypesafeConfigModule(config, reflections);
}
 
开发者ID:racc,项目名称:typesafeconfig-guice,代码行数:23,代码来源:TypesafeConfigModule.java

示例3: getCasBannerInstance

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
/**
 * Gets cas banner instance.
 *
 * @return the cas banner instance
 */
public static Banner getCasBannerInstance() {
    final String packageName = CasEmbeddedContainerUtils.class.getPackage().getName();
    final Reflections reflections =
            new Reflections(new ConfigurationBuilder()
                    .filterInputsBy(new FilterBuilder().includePackage(packageName))
                    .setUrls(ClasspathHelper.forPackage(packageName))
                    .setScanners(new SubTypesScanner(true)));

    final Set<Class<? extends AbstractCasBanner>> subTypes = reflections.getSubTypesOf(AbstractCasBanner.class);
    subTypes.remove(DefaultCasBanner.class);
    
    if (subTypes.isEmpty()) {
        return new DefaultCasBanner();
    }
    try {
        final Class<? extends AbstractCasBanner> clz = subTypes.iterator().next();
        LOGGER.debug("Created banner [{}]", clz);
        return clz.newInstance();
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return new DefaultCasBanner();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:29,代码来源:CasEmbeddedContainerUtils.java

示例4: generateReport

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
public void generateReport(String packageName,List<String> flagList) throws IOException
{

    URL testClassesURL = Paths.get("target/test-classes").toUri().toURL();

    URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{testClassesURL},
            ClasspathHelper.staticClassLoader());

    reflections = new Reflections(new ConfigurationBuilder()
            .setUrls(ClasspathHelper.forPackage(packageName,classLoader))
            .addClassLoader(classLoader)
            .filterInputsBy(new FilterBuilder().includePackage(packageName))
            .setScanners(new MethodAnnotationsScanner(), new TypeAnnotationsScanner(), new SubTypesScanner())
    );


    List<Map<String, TestClass>> list = new ArrayList<>();

    for (String flag : flagList)
    {
        list.add(printMethods(flag));
    }

    Gson gson = new Gson();
    String overviewTemplate = IOUtils.toString(getClass().getResourceAsStream("/index.tpl.html"));


    String editedTemplate = overviewTemplate.replace("##TEST_DATA##", gson.toJson(list));

    FileUtils.writeStringToFile(new File("target/test-list-html-report/index.html"), editedTemplate);
    logger.info("report file generated");
}
 
开发者ID:cyildirim,项目名称:Lahiya,代码行数:33,代码来源:LahiyaTestCaseReport.java

示例5: ReflectionsServiceDiscovery

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
public ReflectionsServiceDiscovery(String resourceSearchPackages, JsonServiceLocator locator) {
	this.locator = locator;

	ConfigurationBuilder builder = new ConfigurationBuilder();

	PreconditionUtil.assertNotNull("no resourceSearchPackage configured", resourceSearchPackages);

	FilterBuilder filter = new FilterBuilder();
	for (String resourceSearchPackage : resourceSearchPackages.split(",")) {
		builder = builder.addUrls(ClasspathHelper.forPackage(resourceSearchPackage));
		filter.includePackage(resourceSearchPackage);
	}
	filter.includePackage(Repository.class.getPackage().getName());
	filter.includePackage(ResourceRepository.class.getPackage().getName());
	builder = builder.filterInputsBy(filter);

	builder = builder.addUrls(ClasspathHelper.forClass(Repository.class));
	builder = builder.addUrls(ClasspathHelper.forClass(ResourceRepository.class));
	builder = builder.addUrls(ClasspathHelper.forClass(ResourceRepositoryV2.class));

	builder = builder.setScanners(new SubTypesScanner(false), new TypeAnnotationsScanner());
	reflections = new Reflections(builder);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:24,代码来源:ReflectionsServiceDiscovery.java

示例6: doPackage

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
private void doPackage(FilterBuilder fb, List<RuleFactory> resultL) throws Exception {
    List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
    classLoadersList.add(ClasspathHelper.contextClassLoader());
    classLoadersList.add(ClasspathHelper.staticClassLoader());

    Reflections reflections = new Reflections(new ConfigurationBuilder()
        .setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
        .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
        .filterInputsBy(fb));      
    
    Set<Class<? extends RuleFactory>> subTypes = reflections.getSubTypesOf(RuleFactory.class);        
    for(Class<? extends RuleFactory> clazz : subTypes) {
        RuleFactory factory = clazz.newInstance();
        resultL.add(factory);
    }
}
 
开发者ID:ianrae,项目名称:dnal-lang,代码行数:17,代码来源:RuleFactoryFinder.java

示例7: testReflections

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
@Test
public void testReflections() throws Exception {
    List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
    classLoadersList.add(ClasspathHelper.contextClassLoader());
    classLoadersList.add(ClasspathHelper.staticClassLoader());

    String packageName = "org.dnal.core.world";
    Reflections reflections = new Reflections(new ConfigurationBuilder()
        .setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
        .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
        .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(packageName))));      
    
    Set<String> types = reflections.getAllTypes();
    for(String s : types) {
        System.out.println(s);
    }

    Set<Class<? extends RuleFactory>> subTypes = reflections.getSubTypesOf(RuleFactory.class);        
    for(Class<? extends RuleFactory> clazz : subTypes) {
        System.out.println("sub: " + clazz.getName());
        RuleFactory factory = clazz.newInstance();
        RuleDeclaration decl = factory.getDeclaration();
        System.out.println("d: " + decl.ruleName);
    }
    
}
 
开发者ID:ianrae,项目名称:dnal-lang,代码行数:27,代码来源:ReflectionTests.java

示例8: getResourceDirectoryContent

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
private ArrayList<String> getResourceDirectoryContent(String resourcePattern) {
    ArrayList<String> tempFilesContentList = new ArrayList<>();

    Reflections reflections = new Reflections(new ConfigurationBuilder()
                                                    .setUrls(ClasspathHelper.forPackage("io.logz"))
                                                    .setScanners(new ResourcesScanner())
                                                    .filterInputsBy(new FilterBuilder().include(resourcePattern)));
    Set<String> properties = reflections.getResources(Pattern.compile(".*\\.json"));

    properties.forEach((resourceName) -> {

        URL resourceUrl = Resources.getResource(resourceName);
        try {
            tempFilesContentList.add(Resources.toString(resourceUrl, Charset.forName("utf-8")).replace("\n", ""));

        } catch (IOException e) {
            logger.info("Could not read file {}", resourceUrl.toString());
        }
    });

    if (tempFilesContentList.isEmpty())
        throw new RuntimeException("Did not find any files under "+ resourcePattern +"!");

    return tempFilesContentList;
}
 
开发者ID:logzio,项目名称:elasticsearch-benchmark-tool,代码行数:26,代码来源:ElasticsearchController.java

示例9: BeanScanner

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
public BeanScanner(final BeanManagerImpl beanManager, final ClassLoader classLoader, final String packageToScan)
{
    this.beanManager = beanManager;
    final ConfigurationBuilder config = new ConfigurationBuilder();

    config.setClassLoaders(new ClassLoader[] {classLoader});
    config.setUrls(ClasspathHelper.forPackage(packageToScan, classLoader));
    if (StringUtils.isNotEmpty(packageToScan))
    {
        config.filterInputsBy(new FilterBuilder().includePackage(packageToScan));
    }
    config.useParallelExecutor();
    config.setScanners(new SubTypesScanner(false));

    this.reflections = new Reflections(config);
}
 
开发者ID:Diorite,项目名称:Diorite-old,代码行数:17,代码来源:BeanScanner.java

示例10: findAllPackagesStartingWith

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
/**
 * Finds all package names starting with prefix
 * @param prefix The package in which to start searching
 * @param statik True to statically return components names
 * @return a set of component name
 */
public List<String> findAllPackagesStartingWith(final String prefix, final boolean statik) {
    final List<ClassLoader> classLoadersList = new ArrayList<>();
    classLoadersList.add(ClasspathHelper.contextClassLoader());

    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .setScanners(new SubTypesScanner(false), new ResourcesScanner())
            .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[classLoadersList.size()])))
            .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(prefix))));
    Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);

    final Set<String> packages = new HashSet<>();
    for (final Class classInstance : classes) {
        String packageName = classInstance.getPackage().getName();
        packageName = packageName.split("\\.")[packageName.split("\\.").length-1].toLowerCase();
        packages.add(packageName);
    }
    return new ArrayList<>(packages);
}
 
开发者ID:StephaneMangin,项目名称:Synth,代码行数:25,代码来源:CoreController.java

示例11: getPackageTypes

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
private static Collection<? extends Class<?>> getPackageTypes(String packageToPase, Collection<URL> urls) {
    Set<Class<?>> classes = new HashSet<>();
    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .setScanners(new SubTypesScanner(false /* exclude Object.class */), new ResourcesScanner(), new TypeElementsScanner())
            .setUrls(urls)
            .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(packageToPase)).exclude("java.*")));

    Set<String> types;
    types = reflections.getStore().get("TypeElementsScanner").keySet();
    for (String type: types) {
        Class<?> aClass = TypesHelper.loadClass(type, CLASS_LOADER);
        boolean wantedElement = StringUtils.startsWith(type, packageToPase);
        if (null != aClass && wantedElement) {
            logger.log(Level.INFO, "looking up for type: " + type);
            classes.add(aClass);
        }
    }
    return classes;
}
 
开发者ID:juanmf,项目名称:Java2PlantUML,代码行数:20,代码来源:Parser.java

示例12: scanConceptsWithReflections

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
private void scanConceptsWithReflections() throws ObjectStoreConfigException {
    logger.debug("Search for concepts with reflections");
    Set<URL> classpath = new HashSet<>();
    classpath.addAll(ClasspathHelper.forClassLoader());
    classpath.addAll(ClasspathHelper.forJavaClassPath());
    classpath.addAll(ClasspathHelper.forManifest());
    classpath.addAll(ClasspathHelper.forPackage(""));
    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .setUrls(classpath)
.useParallelExecutor()
.filterInputsBy(FilterBuilder.parsePackages("-java, -javax, -sun, -com.sun"))
            .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()));

    Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(Iri.class, true);
    logger.debug("Search for concepts with reflections resulted in " + annotated.size() + " classes");
    for (Class clazz : annotated) {
        logger.debug("Found concept class: " + clazz.getCanonicalName());
        roleMapper.addConcept(clazz);
    }
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:21,代码来源:RoleClassLoader.java

示例13: registerScriptEngineFactories

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void registerScriptEngineFactories() {
    List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
    classLoadersList.add(ClasspathHelper.contextClassLoader());
    classLoadersList.add(ClasspathHelper.staticClassLoader());
    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner(), new ResourcesScanner())
            .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
            .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.jsen"))));
	
    Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(ScriptEngineFactory.class);
	
	for (Class<?> clazz : annotated) {
		if (AbstractScriptEngineFactory.class.isAssignableFrom(clazz)) {
			registerMimeContentFactory((Class<AbstractScriptEngineFactory>)clazz);	
		}
	}
}
 
开发者ID:jutils,项目名称:jsen-core,代码行数:19,代码来源:ScriptEngineManager.java

示例14: getAllDocStrings0

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
private Map<String, String> getAllDocStrings0(ClassLoader classLoader) {
    final Configuration configuration = new ConfigurationBuilder()
            .filterInputsBy(new FilterBuilder().includePackage(path))
            .setUrls(ClasspathHelper.forPackage(path))
            .addClassLoader(classLoader)
            .setScanners(new ResourcesScanner());
    if (configuration.getUrls() == null || configuration.getUrls().isEmpty()) {
        return Collections.emptyMap();
    }
    Map<String, byte[]> files = new Reflections(configuration)
            .getResources(this::acceptFile).stream()
            .map(f -> {
                try {
                    URL url = classLoader.getResource(f);
                    if (url == null) {
                        throw new IllegalStateException("not found: " + f);
                    }
                    return new SimpleImmutableEntry<>(f, Resources.toByteArray(url));
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            })
            .collect(toImmutableMap(Entry::getKey, Entry::getValue));
    return getDocStringsFromFiles(files);
}
 
开发者ID:line,项目名称:armeria,代码行数:26,代码来源:DocStringExtractor.java

示例15: urls

import org.reflections.util.FilterBuilder; //导入依赖的package包/类
public static List<URL> urls( String atPackage, String ext ) {
    final ExecutorService executorService = Executors.newFixedThreadPool(
        Runtime.getRuntime().availableProcessors(),
        new ThreadFactoryBuilder().setNameFormat( "reflections-%d" ).build()
    );
    try {
        final ConfigurationBuilder configuration = new ConfigurationBuilder()
            .setUrls( ClasspathHelper.forPackage( atPackage ) )
            .setScanners( new ResourcesScanner() )
            .filterInputsBy( new FilterBuilder().includePackage( atPackage ) )
            .setExecutorService( executorService );
        final Reflections reflections = new Reflections( configuration );

        final Set<String> resources = reflections.getResources( in -> in.endsWith( "." + ext ) );
        return new ArrayList<>( Sets.map( resources, r -> Thread.currentThread().getContextClassLoader().getResource( r ) ) );
    } finally {
        executorService.shutdown();
    }
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:20,代码来源:Resources.java


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