Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider


    }

    @Override
    @SuppressWarnings("unchecked")
    public void afterPropertiesSet() throws Exception {
        scanner = new ClassPathScanningCandidateComponentProvider(false);
        scanner.addIncludeFilter(new AssignableTypeFilter(Locatable.class));
        Set<BeanDefinition> found = scanner.findCandidateComponents(baseDomainPackage);
        for (BeanDefinition def : found) candidates.add(ClassUtils.forName(def.getBeanClassName()));
    }
View Full Code Here


    // Build pattern to lookup implementation class
    Pattern pattern = Pattern.compile(".*\\." + className);

    // Build classpath scanner and lookup bean definition
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.setEnvironment(environment);
    provider.setResourceLoader(resourceLoader);
    provider.setResourcePattern(String.format(CUSTOM_IMPLEMENTATION_RESOURCE_PATTERN, className));
    provider.setMetadataReaderFactory(metadataReaderFactory);
    provider.addIncludeFilter(new RegexPatternTypeFilter(pattern));

    Set<BeanDefinition> definitions = new HashSet<BeanDefinition>();

    for (String basePackage : basePackages) {
      definitions.addAll(provider.findCandidateComponents(basePackage));
    }

    if (definitions.isEmpty()) {
      return null;
    }
View Full Code Here

    return findTypes(Arrays.asList(basePackages));
  }

  public Set<Class<?>> findTypes(Iterable<String> basePackages) {

    ClassPathScanningCandidateComponentProvider provider = new InterfaceAwareScanner(considerInterfaces);

    for (Class<? extends Annotation> annotationType : annotationTypess) {
      provider.addIncludeFilter(new AnnotationTypeFilter(annotationType, true, considerInterfaces));
    }

    Set<Class<?>> types = new HashSet<Class<?>>();

    for (String basePackage : basePackages) {

      for (BeanDefinition definition : provider.findCandidateComponents(basePackage)) {
        try {
          types.add(ClassUtils.forName(definition.getBeanClassName(), getClass().getClassLoader()));
        } catch (ClassNotFoundException o_O) {
          throw new IllegalStateException(o_O);
        }
View Full Code Here

   *
   * @return
   */
  private boolean multipleStoresDetected() {

    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false,
        environment);
    scanner.addIncludeFilter(new LenientAssignableTypeFilter(RepositoryFactorySupport.class));
    int numberOfModulesFound = scanner.findCandidateComponents(MODULE_DETECTION_PACKAGE).size();

    if (numberOfModulesFound > 1) {
      LOGGER.debug(MULTIPLE_MODULES);
      return true;
    }
View Full Code Here

  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(), AbstractCouchbaseConfiguration.class.getClassLoader()));
      }
    }

    return initialEntitySet;
View Full Code Here

        String[] basePackages = StringUtils.tokenizeToStringArray(this.basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
        for (String basePackage : basePackages) {
            if (this.logger.isInfoEnabled()) {
                this.logger.info("Scanning package [" + basePackage + "]");
            }
            ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
            scanner.addIncludeFilter(new AnnotationTypeFilter(com.googlecode.objectify.annotation.Entity.class));
            scanner.addIncludeFilter(new AnnotationTypeFilter(javax.persistence.Entity.class));
            Set<BeanDefinition> candidates = scanner.findCandidateComponents(basePackage);
            for (BeanDefinition candidate : candidates) {
                Class<?> clazz = ClassUtils.resolveClassName(candidate.getBeanClassName(), ClassUtils.getDefaultClassLoader());
                classes.add(clazz);
            }           
        }
View Full Code Here

          addProposal(complString, string, CompletionProposal.PACKAGE_REF);
        }
      }
    } else if (type == ComponentDeclaration.UIMAFIT_ENGINE) {
      List<String> engines = new ArrayList<String>();
      ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
              true);
      ResourceLoader resourceLoader = new DefaultResourceLoader(classloader);
      provider.setResourceLoader(resourceLoader);
      provider.addIncludeFilter(new AssignableTypeFilter(AnalysisComponent.class));

      String pack = complString.replaceAll("[.]", "/");
      if (pack.endsWith("/")) {
        pack = pack.substring(0, pack.length() - 1);
      }
      Set<BeanDefinition> components = provider.findCandidateComponents(pack);
      for (BeanDefinition component : components) {
        String beanClassName = component.getBeanClassName();
        engines.add(beanClassName);
      }
      for (String string : engines) {
View Full Code Here

*/
public class AnnotationScanner {
  private static Logger logger = LoggerFactory.getLogger(AnnotationScanner.class);

  public Set<Class<?>> scan(String packageRoot, Class<? extends Annotation> anno) {
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);

    AnnotationTypeFilter filter = new AnnotationTypeFilter(anno);
    scanner.addIncludeFilter(filter);
    Set<BeanDefinition> beanSet = scanner.findCandidateComponents(packageRoot);

    Set<Class<?>> classSet = new HashSet<Class<?>>();
    for (BeanDefinition beanDef : beanSet) {
      logger.debug("found candidate bean = " + beanDef.getBeanClassName());

View Full Code Here

        includeClassNamesPattern = Pattern.compile(includeClassNamesWhichMatchRegex);
    }


    private Set<BeanDefinition> getAllBeans() {
        ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
        provider.addIncludeFilter(new AssignableTypeFilter(Object.class));

        Set<BeanDefinition> beans = new HashSet<>();
        for (String packageName : packagesContainingBeans) {
            beans.addAll(provider.findCandidateComponents(packageName));
        }

        return beans;
    }
View Full Code Here

  }

  public AbstractEntityDetector(final TypeFilter filter, final boolean useDefaultFilters) {
    super();
    Assert.notNull(filter, "filter");
    this.provider = new ClassPathScanningCandidateComponentProvider(useDefaultFilters);
    this.provider.addIncludeFilter(filter);
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.