/** * Creates a new {@link RepositoryComponentProvider} using the given {@link TypeFilter} to include components to be * picked up. * * @param includeFilters the {@link TypeFilter}s to select repository interfaces to consider, must not be * {@literal null}. */ public RepositoryComponentProvider(Iterable<? extends TypeFilter> includeFilters, BeanDefinitionRegistry registry) { super(false); Assert.notNull(includeFilters, "Include filters must not be null!"); Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); this.registry = registry; if (includeFilters.iterator().hasNext()) { for (TypeFilter filter : includeFilters) { addIncludeFilter(filter); } } else { super.addIncludeFilter(new InterfaceTypeFilter(Repository.class)); super.addIncludeFilter(new AnnotationTypeFilter(RepositoryDefinition.class, true, true)); } addExcludeFilter(new AnnotationTypeFilter(NoRepositoryBean.class)); }
/** * Creates a new {@link RepositoryComponentProvider} using the given {@link TypeFilter} to include components to be * picked up. * * @param includeFilters the {@link TypeFilter}s to select repository interfaces to consider, must not be * {@literal null}. */ public RepositoryComponentProvider(Iterable<? extends TypeFilter> includeFilters) { super(false); Assert.notNull(includeFilters); if (includeFilters.iterator().hasNext()) { for (TypeFilter filter : includeFilters) { addIncludeFilter(filter); } } else { super.addIncludeFilter(new InterfaceTypeFilter(Repository.class)); super.addIncludeFilter(new AnnotationTypeFilter(RepositoryDefinition.class, true, true)); } addExcludeFilter(new AnnotationTypeFilter(NoRepositoryBean.class)); }
@Override public Streamable<BeanDefinition> getCandidates(ResourceLoader loader) { RepositoryComponentProvider scanner = new RepositoryComponentProvider(getIncludeFilters(), registry); scanner.setConsiderNestedRepositoryInterfaces(shouldConsiderNestedRepositories()); scanner.setEnvironment(environment); scanner.setResourceLoader(loader); getExcludeFilters().forEach(it -> scanner.addExcludeFilter(it)); return Streamable.of(() -> getBasePackages().stream()// .flatMap(it -> scanner.findCandidateComponents(it).stream())); }