Examples of AssignableTypeFilter


Examples of org.springframework.core.type.filter.AssignableTypeFilter

    }

    @SuppressWarnings("unchecked")
    private <T> void collect(Set<Class<T>>candidates, Class<?> clazz, String pkg) throws ClassNotFoundException {
      scanner.resetFilters(false);
        scanner.addIncludeFilter(clazz.isAnnotation() new AnnotationTypeFilter((Class<? extends Annotation>) clazz) : new AssignableTypeFilter(clazz));
        if (logger.isInfoEnabled()) logger.info("Scanning classpath [" + pkg + "] looking for " + (clazz.isAnnotation() ? "@" + clazz.getSimpleName() + " annotated" : clazz.getSimpleName()) + " domain entities");
        Set<BeanDefinition> definitions = scanner.findCandidateComponents(pkg);
        for (BeanDefinition def : definitions) {
          if (logger.isDebugEnabled()) logger.debug("Found matching class [" + def.getBeanClassName() + "]");
            candidates.add(ClassUtils.forName(def.getBeanClassName()));
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

    @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

Examples of org.springframework.core.type.filter.AssignableTypeFilter

          @SuppressWarnings("unchecked")
          Class<Annotation> annoClass = (Class<Annotation>) filterClass;
          typeFilters.add(new AnnotationTypeFilter(annoClass));
          break;
        case ASSIGNABLE_TYPE:
          typeFilters.add(new AssignableTypeFilter(filterClass));
          break;
        case CUSTOM:
          Assert.isAssignable(TypeFilter.class, filterClass, "An error occured when processing a @ComponentScan "
              + "CUSTOM type filter: ");
          typeFilters.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class));
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

  }

  @Test
  public void limitsFoundRepositoriesToIncludeFiltersOnly() {

    List<? extends TypeFilter> filters = Arrays.asList(new AssignableTypeFilter(MyOtherRepository.class));

    RepositoryComponentProvider provider = new RepositoryComponentProvider(filters);
    Set<BeanDefinition> components = provider.findCandidateComponents("org.springframework.data.repository");

    assertThat(components.size(), is(1));
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

                acceptAllInterfaces = false;
            }

            // override AssignableTypeFilter to ignore matches on the actual marker interface
            if (MapperScannerConfigurer.this.markerInterface != null) {
                addIncludeFilter(new AssignableTypeFilter(MapperScannerConfigurer.this.markerInterface) {
                    @Override
                    protected boolean matchClassName(String className) {
                        return false;
                    }
                });
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

  static class GenericEntityDaoComponentProvider extends
    ClassPathScanningCandidateComponentProvider {

    public GenericEntityDaoComponentProvider() {
      super(false);
      addIncludeFilter(new AssignableTypeFilter(GenericEntityDao.class));
    }
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

      acceptAllInterfaces = false;
    }

    // override AssignableTypeFilter to ignore matches on the actual marker interface
    if (this.markerInterface != null) {
      addIncludeFilter(new AssignableTypeFilter(this.markerInterface) {
        @Override
        protected boolean matchClassName(String className) {
          return false;
        }
      });
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

      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);
      }
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

          @SuppressWarnings("unchecked")
          Class<Annotation> annoClass = (Class<Annotation>)filterClass;
          typeFilters.add(new AnnotationTypeFilter(annoClass));
          break;
        case ASSIGNABLE_TYPE:
          typeFilters.add(new AssignableTypeFilter(filterClass));
          break;
        case CUSTOM:
          Assert.isAssignable(TypeFilter.class, filterClass,
              "An error occured when processing a @ComponentScan " +
              "CUSTOM type filter: ");
View Full Code Here

Examples of org.springframework.core.type.filter.AssignableTypeFilter

    else {
      this.importStack.push(configClass);
      AnnotationMetadata importingClassMetadata = configClass.getMetadata();
      for (String candidate : classesToImport) {
        MetadataReader reader = this.metadataReaderFactory.getMetadataReader(candidate);
        if (new AssignableTypeFilter(ImportSelector.class).match(reader, metadataReaderFactory)) {
          // the candidate class is an ImportSelector -> delegate to it to determine imports
          try {
            ImportSelector selector = BeanUtils.instantiateClass(Class.forName(candidate), ImportSelector.class);
            processImport(configClass, selector.selectImports(importingClassMetadata), false);
          } catch (ClassNotFoundException ex) {
            throw new IllegalStateException(ex);
          }
        }
        else if (new AssignableTypeFilter(ImportBeanDefinitionRegistrar.class).match(reader, metadataReaderFactory)) {
          // the candidate class is an ImportBeanDefinitionRegistrar -> delegate to it to register additional bean definitions
          try {
            ImportBeanDefinitionRegistrar registrar = BeanUtils.instantiateClass(Class.forName(candidate), ImportBeanDefinitionRegistrar.class);
            registrar.registerBeanDefinitions(importingClassMetadata, registry);
          } catch (ClassNotFoundException ex) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.