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


Java ConfigurationBuilder.filterInputsBy方法代码示例

本文整理汇总了Java中org.reflections.util.ConfigurationBuilder.filterInputsBy方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationBuilder.filterInputsBy方法的具体用法?Java ConfigurationBuilder.filterInputsBy怎么用?Java ConfigurationBuilder.filterInputsBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.reflections.util.ConfigurationBuilder的用法示例。


在下文中一共展示了ConfigurationBuilder.filterInputsBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ReflectionsServiceDiscovery

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的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

示例2: BeanScanner

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的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

示例3: getDataMapperNames

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的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

示例4: getConfigurationBuilder

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
private ConfigurationBuilder getConfigurationBuilder() {
	ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
	for (String excludedPackage : excludedPackages) {
		configurationBuilder.filterInputsBy(new FilterBuilder().excludePackage(excludedPackage));
	}
	for (String excludedPattern : excludedPatterns) {
		configurationBuilder.filterInputsBy(new FilterBuilder().exclude(excludedPattern));
	}
	return configurationBuilder;
}
 
开发者ID:stephenwilliams,项目名称:Auto-Spark,代码行数:11,代码来源:AutoSpark.java

示例5: addPackage

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的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

示例6: EntityScanner

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
/**
 * Creates an EntityScanner using the given Morphia instance with the given predicate.
 *
 * @param m         the Morphia instance
 * @param predicate the Predicate to use when determining which classes to map.
 */
public EntityScanner(final Morphia m, final Predicate<String> predicate) {
    Predicate<String> localPredicate = predicate;
    if (localPredicate == null) {
        localPredicate = Predicates.alwaysTrue();
    }
    Assert.parametersNotNull("m, predicate", m, localPredicate);
    final ConfigurationBuilder conf = new ConfigurationBuilder();
    conf.setScanners(new TypeElementsScanner(), new TypeAnnotationsScanner());

    final Set<URL> s = new HashSet<URL>();
    s.addAll(ClasspathHelper.forClassLoader());
    s.addAll(ClasspathHelper.forJavaClassPath());
    final Iterator<URL> iterator = s.iterator();
    while (iterator.hasNext()) {
        final URL url = iterator.next();
        if (url.getPath().endsWith("jnilib")) {
            iterator.remove();
        }
    }
    conf.setUrls(new ArrayList<URL>(s));

    conf.filterInputsBy(localPredicate);
    conf.addScanners(new SubTypesScanner());

    final Reflections r = new Reflections(conf);

    final Set<Class<?>> entities = r.getTypesAnnotatedWith(Entity.class);
    for (final Class<?> c : entities) {
        m.map(c);
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:38,代码来源:EntityScanner.java

示例7: execute

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的package包/类
public void execute() throws MojoExecutionException, MojoFailureException {
    //
    if (StringUtils.isEmpty(destinations)) {
        destinations = resolveOutputDirectory() + "/META-INF/reflections/" + getProject().getArtifactId() + "-reflections.xml";
    }

    String outputDirectory = resolveOutputDirectory();
    if (!new File(outputDirectory).exists()) {
        getLog().warn(String.format("Reflections plugin is skipping because %s was not found", outputDirectory));
        return;
    }

    //
    ConfigurationBuilder config = new ConfigurationBuilder();

    config.setUrls(parseUrls());

    if (!isEmpty(includeExclude)) {
        config.filterInputsBy(FilterBuilder.parse(includeExclude));
    }

    config.setScanners(!isEmpty(scanners) ? parseScanners() : new Scanner[]{new SubTypesScanner(), new TypeAnnotationsScanner()});

    if (!isEmpty(serializer)) {
        try {
            Serializer serializerInstance = (Serializer) forName(serializer, "org.reflections.serializers").newInstance();
            config.setSerializer(serializerInstance);

            if (serializerInstance instanceof JavaCodeSerializer) {
                int size = config.getScanners().size();
                config.addScanners(new TypeElementsScanner());
                if (size != config.getScanners().size()) {
                    getLog().info("added type scanners for JavaCodeSerializer");
                }
            }
        } catch (Exception ex) {
            throw new ReflectionsException("could not create serializer instance", ex);
        }
    }

    if (parallel != null && parallel.equals(Boolean.TRUE)) {
        config.useParallelExecutor();
    }

    //
    if (Reflections.log == null) {
        try {
            Reflections.log = new MavenLogAdapter(getLog());
        } catch (Error e) {
            //ignore
        }
    }
    Reflections reflections = new Reflections(config);

    reflections.save(destinations.trim());
}
 
开发者ID:ronmamo,项目名称:reflections-maven,代码行数:57,代码来源:ReflectionsMojo.java

示例8: testFindLogicObjectsWithReflections

import org.reflections.util.ConfigurationBuilder; //导入方法依赖的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.ConfigurationBuilder.filterInputsBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。