-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Introduce a mechanism for abstract types at component scanning [SPR-11663] #16286
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
Comments
cemo koc commented Any chance for this issue? I believe that It will help a lot other frameworks based on Spring as well. For example currently I am trying to implement a library based on only Spring JDBC. I need to create some proxy instances as a result of component scan but strict nature of component scan is blocking. I am ready for any kind of help. |
Juergen Hoeller commented Alright, as per your comment on #15547, I'll consider this one for 4.2 as well. No promises yet, just moving it to a concrete timeframe for consideration :-) Juergen |
Juergen Hoeller commented I'm afraid this might not make it into 4.2 RC1... too much on the plate still, and a rather hard deadline towards the end of May. Juergen |
Juergen Hoeller commented Oliver Drotbohm, any current take from your side on what would make sense for Spring Data here? I'm happy to consider this for 5.0 still but I'd like to understand our use cases better. From my perspective, we could let our component scanner register abstract classes as abstract bean definitions which will get ignored by the container by default. A regular |
Juergen Hoeller commented After discussions with the Spring Data team, we are not going to generally allow component scanning to pick up abstract types, and we won't provide an SPI at the scanner level either. Instead, in particular with 5.0's indexing mechanism, we actually recommend a separate scan attempt for specific interfaces, ideally combined with a post-processor that knows how to turn those interfaces into concrete components. If you'd like to have a nicer way to customize the scanner, we're definitely open to that. What does your current code look like there? |
cemo koc opened SPR-11663 and commented
I would like to create some proxy beans based on interfaces. I will provide some basic examples to make clear.
Use case 1: Creating a proxy restful client based on interface
Use case 2: Creating a proxy repository instance based on interfaces
In order to provide this functionality I had to dig many codes from Spring Data project and became little frustrated with result. I had to create 6-7 class and most of them are duplicated. As a result of my implementation basically I had to create a custom InstantiationAwareBeanPostProcessorAdapter to create beans with custom logic after registering them.
I would like to see a configuration mechanism for registering beans for abstract types dynamically. I was considering an API for component scanning such as ComponentScanProcessor. Each registered ComponentScanProcessor can decide about candidates.
This will help to reduce a fair amount codes in many projects even Spring Data which is creating repository beans from Interfaces.
Affects: 4.0.3
Issue Links:
@Configuration
interface with Java 8 default methods (as a standalone artifact)@Lookup
methods not registered in case of classpath scanning3 votes, 6 watchers
The text was updated successfully, but these errors were encountered: