Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify *Aware interfaces using custom type filters through Enable…Repositories#includeFilters #2481

Closed
f-cramer opened this issue Oct 12, 2021 · 4 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@f-cramer
Copy link

The javadoc for ComponentScan.Filter#classes specifies that custom instances of TypeFilter can implement any of 4 *Aware interfaces, whose methods should be called before matching.
When specifying a filter in EnableJpaRepositories#includeFilters, the methods of those interfaces are not called. Construtor autowiring cannot be used either, because filter instances are created using BeanUtils#instantiateClass(Class<?>).

@mp911de
Copy link
Member

mp911de commented Oct 13, 2021

Thanks for bringing this up. Spring Data reuses ComponentScan filters but handles the parsing on its own. Spring Framework's ComponentScanAnnotationParser is not accessible and AnnotationRepositoryConfigurationSource.typeFiltersFor(…) follows a different implementation.

Support for *Aware callbacks was introduced at a later stage in Spring Framework and Spring Data never revised its filter handling.

Aligning with Spring Framework would help with consistency here.

@mp911de mp911de transferred this issue from spring-projects/spring-data-jpa Oct 13, 2021
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 13, 2021
@mp911de
Copy link
Member

mp911de commented Oct 13, 2021

I moved this ticket into Spring Data Commons as the repository discovery is part of our common infrastructure.

@mp911de
Copy link
Member

mp911de commented Oct 13, 2021

I filed spring-projects/spring-framework#27553 asking for reuse of Framework components for filter annotation parsing.

@mp911de
Copy link
Member

mp911de commented Oct 21, 2021

Spring Framework provides now TypeFilterUtils that handle the creation of TypeFilter including *Aware callbacks.

@mp911de mp911de self-assigned this Jun 23, 2022
@mp911de mp911de changed the title EnableJpaRepositories#includeFilters does not enable *Aware interfaces for custom type filters Enable…Repositories#includeFilters does not enable *Aware interfaces for custom type filters Jun 23, 2022
@mp911de mp911de changed the title Enable…Repositories#includeFilters does not enable *Aware interfaces for custom type filters Notify *Aware interfaces using custom type filters through Enable…Repositories#includeFilters Jun 23, 2022
@mp911de mp911de added this to the 2.6.6 (2021.1.6) milestone Jun 23, 2022
mp911de pushed a commit that referenced this issue Jun 23, 2022
mp911de pushed a commit that referenced this issue Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants