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


Java ClassPathScanningCandidateComponentProvider.addIncludeFilter方法代码示例

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


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

示例1: afterPropertiesSet

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {

    // on recherche toutes les classes concrètes du package à la recherche de celles qui sont annotées 'TipiTopProcess'
    final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false) {
        @Override
        protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
            return beanDefinition.getMetadata().isConcrete();
        }
    };
    scanner.addIncludeFilter(new AnnotationTypeFilter(TipiTopProcess.class));

    if (excludeFilters != null) {
        for (TypeFilter filter : excludeFilters) {
            scanner.addExcludeFilter(filter);
        }
    }

    Set<BeanDefinition> beans = scanner.findCandidateComponents(aPackage);
    LOGGER.info("Registering " + beans.size() + " Tipi activities");
    for (BeanDefinition bean : beans) {
        Class<?> clazz = Class.forName(bean.getBeanClassName());
        registerClass(clazz);
    }
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:26,代码来源:AnnotationActivityRegistrar.java

示例2: registerBeanDefinitions

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    Set<String> basePackages = getBasePackages(importingClassMetadata);
    ClassPathScanningCandidateComponentProvider scanner = getScanner();
    scanner.addIncludeFilter(new AnnotationTypeFilter(MuonRepository.class));
    for (String basePackage : basePackages) {
        Set<BeanDefinition> candidateComponents = scanner
                .findCandidateComponents(basePackage);
        for (BeanDefinition candidateComponent : candidateComponents) {
            if (candidateComponent instanceof AnnotatedBeanDefinition) {

                AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();
                Assert.isTrue(annotationMetadata.isInterface(),
                        "@FeignClient can only be specified on an interface");

                BeanDefinitionHolder holder = createBeanDefinition(annotationMetadata);
                BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
            }
        }
    }

}
 
开发者ID:muoncore,项目名称:muon-java,代码行数:24,代码来源:MuonRepositoryRegistrar.java

示例3: getClasses

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
/**
 * Retourne les classes d'une package
 *
 * @param packageName
 * @return
 * @throws Exception
 */
public static List<Class> getClasses(String packageName) {
    final List<Class> list = new ArrayList<>();

    final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.addIncludeFilter(new AssignableTypeFilter(Object.class));
    final Set<BeanDefinition> bds = scanner.findCandidateComponents(packageName);
    try {
        for (BeanDefinition bd : bds) {
            final Class<?> tc = Class.forName(bd.getBeanClassName());
            if (tc.getAnnotation(Entity.class) != null) {
                list.add(tc);
            }
        }
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
    return list;
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:26,代码来源:HibernateMetaDataHelper.java

示例4: testCompileExtendedServices

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
@Test
public void testCompileExtendedServices() throws Exception
{
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    provider.addIncludeFilter(new AssignableTypeFilter(Extensible.class));

    Set<BeanDefinition> components = provider.findCandidateComponents("org/alfresco/*");
    Set<Class<? extends Extensible>> extensibles = new HashSet<>();
    for (BeanDefinition component : components)
    {
        @SuppressWarnings("unchecked")
        Class<? extends Extensible> extensibleClass = (Class<? extends Extensible>) Class.forName(component
                    .getBeanClassName());
        extensibles.add(extensibleClass);

    }
    compile(extensibles);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:AJExtensionsCompileTest.java

示例5: scanForEntities

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
protected Set<Class<?>> scanForEntities(String basePackage) throws ClassNotFoundException {
    if (!StringUtils.hasText(basePackage)) {
        return Collections.emptySet();
    }

    final Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();

    if (StringUtils.hasText(basePackage)) {
        final ClassPathScanningCandidateComponentProvider componentProvider =
                new ClassPathScanningCandidateComponentProvider(false);
        componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));

        for (final BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {

            initialEntitySet
                    .add(ClassUtils.forName(candidate.getBeanClassName(),
                            DocumentDbConfigurationSupport.class.getClassLoader()));
        }
    }

    return initialEntitySet;
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:23,代码来源:DocumentDbConfigurationSupport.java

示例6: cronyxQuartzConverterPairs

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
public static <T> List<Pair<Class, T>> cronyxQuartzConverterPairs(Class<T> tClass) {

        List<Pair<Class, T>> results = new ArrayList<>();

        ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
        provider.addIncludeFilter(new AssignableTypeFilter(tClass));

        Set<BeanDefinition> components = provider.findCandidateComponents(PACKAGE);
        for (BeanDefinition component : components) {
            try {
                Class cls = Class.forName(component.getBeanClassName());
                Class<?> typeArgument = GenericTypeResolver.resolveTypeArgument(cls, tClass);
                results.add(new ImmutablePair<>(typeArgument, (T) cls.newInstance()));

            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                throw new CronyxException("Could not instantiate cronyxToQuartzConverters", e);
            }
        }
        return results;
    }
 
开发者ID:taboola,项目名称:taboola-cronyx,代码行数:21,代码来源:ConfigUtil.java

示例7: registerBeanDefinitions

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.addIncludeFilter(new AnnotationTypeFilter(Consumer.class));
    provider.addIncludeFilter(new AssignableTypeFilter(IConsumer.class));
    Set<BeanDefinition> beanDefinitionSet = provider.findCandidateComponents("spring.study.componentprovider.bean");

    for(BeanDefinition beanDefinition : beanDefinitionSet) {
        String beanName = beanNameGenerator.generateBeanName(beanDefinition, registry);
        if(!registry.containsBeanDefinition(beanName)) {
            registry.registerBeanDefinition(beanName, beanDefinition);
            registry.registerBeanDefinition("11", beanDefinition);
        }
    }

}
 
开发者ID:fangjian0423,项目名称:springboot-analysis,代码行数:17,代码来源:ConsumerRegistrar.java

示例8: buildCommandHandlersRegistry

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
public static Map<String, CommandHandler> buildCommandHandlersRegistry(final String basePackage,
                                                                       final ApplicationContext context) {

    final Map<String, CommandHandler> registry = new HashMap<>();
    final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
    final AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
    scanner.addIncludeFilter(new AssignableTypeFilter(CommandHandler.class));

    CommandHandler currentHandler = null;

    for (BeanDefinition bean : scanner.findCandidateComponents(basePackage)) {
        currentHandler = (CommandHandler) beanFactory.createBean(ClassUtils.resolveClassName(bean.getBeanClassName(), context.getClassLoader()),
                AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
        registry.put(currentHandler.getInterest(), currentHandler);
    }

    return registry;
}
 
开发者ID:sem2nawara,项目名称:cqrs-es-kafka,代码行数:19,代码来源:CommandHandlerUtils.java

示例9: findClass

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
public List<Class> findClass( Class annotation ) {
	ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
	scanner.addIncludeFilter(new AnnotationTypeFilter(annotation));
	
	List<Class> classList = new ArrayList<Class>();
	
	for (BeanDefinition bd : scanner.findCandidateComponents(BASE_PACKAGE)) {

		try {
			classList.add(Class.forName(bd.getBeanClassName()));
		} catch (ClassNotFoundException e) {

			LOG.error("problème de déploiement du service associé au bean : " + bd.getBeanClassName());
		}
	}
	
	return classList;
}
 
开发者ID:amoldavsky,项目名称:restful-api-cxf-spring-java,代码行数:19,代码来源:ConfigUtils.java

示例10: findSchemaClasses

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
public static Set<Class<?>> findSchemaClasses(final String basePackage) throws ClassNotFoundException {
    
    Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();

    if (StringUtils.hasText(basePackage)) {
        ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
                false);
        componentProvider.addIncludeFilter(new AnnotationTypeFilter(GRAPH_QL_SCHEMA_ANNOTATION));

        for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
            initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
                    GraphQLSchemaDiscoverer.class.getClassLoader()));
        }
    }
    return initialEntitySet;
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:17,代码来源:GraphQLSchemaDiscoverer.java

示例11: CachedSpringClassHierarchySupplier

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
public CachedSpringClassHierarchySupplier(Class<?> baseClass, String basePackage) {
  if (!baseClassSubClassesCache.containsKey(baseClass)) {
    ClassPathScanningCandidateComponentProvider provider =
        new ClassPathScanningCandidateComponentProvider(false);
    provider.addIncludeFilter(new AssignableTypeFilter(baseClass));

    Set<Class<?>> subClasses = new HashSet<>();
    for (BeanDefinition beanDefinition : provider.findCandidateComponents(basePackage)) {
      try {
        subClasses.add(Class.forName(beanDefinition.getBeanClassName()));
      } catch (ClassNotFoundException e) {
        throw new IllegalStateException(
            String.format("Could not load child class '%s'.", beanDefinition.getBeanClassName()),
            e);
      }
    }
    baseClassSubClassesCache.put(baseClass, subClasses);
  }
  subClasses = baseClassSubClassesCache.get(baseClass);
}
 
开发者ID:coveo,项目名称:feign-error-decoder,代码行数:21,代码来源:CachedSpringClassHierarchySupplier.java

示例12: getSubClasses

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
@Override
public Set<Class<?>> getSubClasses(Class<?> clazz, String basePackage) {
  ClassPathScanningCandidateComponentProvider provider =
      new ClassPathScanningCandidateComponentProvider(false);
  provider.addIncludeFilter(new AssignableTypeFilter(clazz));

  Set<BeanDefinition> components = provider.findCandidateComponents(basePackage);

  return components
      .stream()
      .map(
          component -> {
            try {
              return Class.forName(component.getBeanClassName());
            } catch (ClassNotFoundException e) {
              throw new IllegalStateException(
                  String.format("Could not load child class '%s'.", component.getBeanClassName()),
                  e);
            }
          })
      .collect(Collectors.toSet());
}
 
开发者ID:coveo,项目名称:feign-error-decoder,代码行数:23,代码来源:SpringClassHierarchySupplier.java

示例13: getInitialEntitySet

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private Set<Class<?>> getInitialEntitySet(BeanFactory beanFactory)
		throws ClassNotFoundException {
	Set<Class<?>> entitySet = new HashSet<Class<?>>();
	ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
			false);
	scanner.setEnvironment(this.environment);
	scanner.setResourceLoader(this.resourceLoader);
	scanner.addIncludeFilter(new AnnotationTypeFilter(Document.class));
	scanner.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
	for (String basePackage : getMappingBasePackages(beanFactory)) {
		if (StringUtils.hasText(basePackage)) {
			for (BeanDefinition candidate : scanner
					.findCandidateComponents(basePackage)) {
				entitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
						this.classLoader));
			}
		}
	}
	return entitySet;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:21,代码来源:MongoDataAutoConfiguration.java

示例14: getInitialEntitySet

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {

        String basePackage = getMappingBasePackage();
        Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();

        if (StringUtils.hasText(basePackage)) {
            ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
                    false);
            componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
            componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));

            for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
                initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
                        this.getClass().getClassLoader()));
            }
        }

        return initialEntitySet;
    }
 
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:20,代码来源:AbstractRepositoryConfiguration.java

示例15: getAllEventClass

import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private static List<Class<?>> getAllEventClass() {
    ClassPathScanningCandidateComponentProvider scanningProvider =
            new ClassPathScanningCandidateComponentProvider(false);
    scanningProvider
            .addIncludeFilter((metadataReader, metadataReaderFactory) -> true);

    return scanningProvider.findCandidateComponents(Event.class.getPackage().getName())
                           .stream()
                           .map(BeanDefinition::getBeanClassName)
                           .map(className -> {
                               try {
                                   return (Class<?>) Class.forName(className);
                               } catch (ClassNotFoundException e) {
                                   throw new RuntimeException(e);
                               }
                           })
                           .filter(Event.class::isAssignableFrom)
                           .collect(toList());
}
 
开发者ID:line,项目名称:line-bot-sdk-java,代码行数:20,代码来源:ReplyEventTest.java


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