/** * Custom extension of {@link #addIncludeFilter(TypeFilter)} to extend the added {@link TypeFilter}. For the * {@link TypeFilter} handed we'll have two filters registered: one additionally enforcing the * {@link RepositoryDefinition} annotation, the other one forcing the extension of {@link Repository}. * * @see ClassPathScanningCandidateComponentProvider#addIncludeFilter(TypeFilter) */ @Override public void addIncludeFilter(TypeFilter includeFilter) { List<TypeFilter> filterPlusInterface = new ArrayList<>(2); filterPlusInterface.add(includeFilter); filterPlusInterface.add(new InterfaceTypeFilter(Repository.class)); super.addIncludeFilter(new AllTypeFilter(filterPlusInterface)); List<TypeFilter> filterPlusAnnotation = new ArrayList<>(2); filterPlusAnnotation.add(includeFilter); filterPlusAnnotation.add(new AnnotationTypeFilter(RepositoryDefinition.class, true, true)); super.addIncludeFilter(new AllTypeFilter(filterPlusAnnotation)); }
/** * 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)); }
/** * Custom extension of {@link #addIncludeFilter(TypeFilter)} to extend the added {@link TypeFilter}. For the * {@link TypeFilter} handed we'll have two filters registered: one additionally enforcing the * {@link RepositoryDefinition} annotation, the other one forcing the extension of {@link Repository}. * * @see ClassPathScanningCandidateComponentProvider#addIncludeFilter(TypeFilter) */ @Override public void addIncludeFilter(TypeFilter includeFilter) { List<TypeFilter> filterPlusInterface = new ArrayList<TypeFilter>(2); filterPlusInterface.add(includeFilter); filterPlusInterface.add(new InterfaceTypeFilter(Repository.class)); super.addIncludeFilter(new AllTypeFilter(filterPlusInterface)); List<TypeFilter> filterPlusAnnotation = new ArrayList<TypeFilter>(2); filterPlusAnnotation.add(includeFilter); filterPlusAnnotation.add(new AnnotationTypeFilter(RepositoryDefinition.class, true, true)); super.addIncludeFilter(new AllTypeFilter(filterPlusAnnotation)); }