當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。