-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Allow usage of BeanNameGenerator in ImportBeanDefinitionRegistrars #22591
Comments
…eanNameGenerator. We now implement the newly introduced ImportBeanDefinitionRegistrar overload additional provided with a BeanNameGenerator configured for the import scanning. We forward this into our bean name generation infrastructure as fallback. Related tickets: spring-projects/spring-framework#22591
…eanNameGenerator. We now implement the newly introduced ImportBeanDefinitionRegistrar overload additional provided with a BeanNameGenerator configured for the import scanning. We forward this into our bean name generation infrastructure as fallback. Related tickets: spring-projects/spring-framework#22591
It looks like we're getting the generator that's used for the configuration class scanning, not the one used to name scanned components. I've put in check for the enclosing class of the provided instance to only opt in using it if it's not |
Reopening to consider comments from @odrotbohm. |
@odrotbohm So you'd simply like to be able to ignore the default import bean name generator more easily, e.g. by comparing it to a constant on |
Yes. Fundamentally, we're scanning for components ourselves. I.e. for us, the bean name generator used to name scanned components would be the more appropriate one. It looks like the user override is trumping both default variants Spring Framework uses internally. If that stays the same, I'm fine with just using the one handed down, if it's not the default one. To detect that, something to easily compare the handed down instance to would allow us to remove the rather brittle check of inspecting the surrounding class. |
Alright, I've added an |
…eanNameGenerator. We now implement the newly introduced ImportBeanDefinitionRegistrar overload additional provided with a BeanNameGenerator configured for the import scanning. We forward this into our bean name generation infrastructure as fallback. Related tickets: spring-projects/spring-framework#22591
I hate to bring this up again but we face the same issue with the XML flavor as the However, ultimately we're facing the same slightly brittle situation of detecting the default. |
RepositoryBeanDefinitionRegistrarSupport now also overrides registerBeanDefinitions(AnnotationMetadata, BeanDefinitionRegistry) so that unit test in downstream modules still work. Added defaulting of BeanNameGenerator in XmlRepositoryConfigurationSource so that we use an AnnotationBeanNameGenerator if a DefaultBeanNameGenerator is handed in. Related tickets: spring-projects/spring-framework#22591
Hmm, in line with the common instance constants, |
Yes, I think so. |
A
BeanNameGenerator
can be configured for usage in component scanning configuration classes. That support allows custom annotation based activation of functionality via annotations importing anImportBeanDefinitionRegistrar
. Its primary callback method unfortunately currently doesn't provide access to theBeanNameGenerator
potentially provided so that a customization of that generator cannot be considered for components registered via the registrar.It would be nice, if there was a way to consume the
BeanNameGenerator
to allow components being registered to follow the configured naming strategy.The text was updated successfully, but these errors were encountered: