-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-3926: BeanNameGenerator for @MessagingGateway #3927
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
Conversation
src/reference/asciidoc/gateway.adoc
Outdated
The `@MessagingGateway.name()` attribute specifies a name for the target bean registered. | ||
If it is not provided, the `@IntegrationComponentScan.nameGenerator()` (since version `6.0`) is consulted. | ||
And if that is not provided as well, an `AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR` bean, provided for the application context, is used. | ||
Otherwise, the bean name generation falls back to the `AnnotationBeanNameGenerator` which results with an uncapitalized simple class name. | ||
In other words, the current naming strategy for gateway proxy beans is aligned with standard Spring Framework `@ComponentScan` approach. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `@MessagingGateway.name()` attribute specifies a name for the target bean registered. | |
If it is not provided, the `@IntegrationComponentScan.nameGenerator()` (since version `6.0`) is consulted. | |
And if that is not provided as well, an `AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR` bean, provided for the application context, is used. | |
Otherwise, the bean name generation falls back to the `AnnotationBeanNameGenerator` which results with an uncapitalized simple class name. | |
In other words, the current naming strategy for gateway proxy beans is aligned with standard Spring Framework `@ComponentScan` approach. | |
The `@MessagingGateway.name()` attribute specifies a name for the target bean that will be registered. | |
If it is not provided, the `@IntegrationComponentScan.nameGenerator()` (since version `6.0`) is consulted. | |
And, if that is not provided, an `AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR` bean, if present in the application context, is used. | |
Otherwise, the bean name generation falls back to the `AnnotationBeanNameGenerator` which results with an uncapitalized simple class name. | |
In other words, the current naming strategy for gateway proxy beans is aligned with standard Spring Framework `@ComponentScan` approach. | |
This probably can be revised when #3929 is merged, since it looks like we would need from now on only a |
Fixes spring-projects#3926 Current approach for generated bean name in the `MessagingGatewayRegistrar` is to decapitalize simple class name, which is similar to standard `AnnotationBeanNameGenerator` * Make logic in the `MessagingGatewayRegistrar` based on the provided `BeanNameGenerator` * Expose an `@IntegrationComponentScan.nameGenerator()` attribute to allow to customize default bean name generation strategy * Introduce `IntegrationConfigUtils.annotationBeanNameGenerator()` to take a provided `AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR` singleton or fallback to the `AnnotationBeanNameGenerator.INSTANCE` * Use this utility in the `IntegrationComponentScanRegistrar` if no custom strategy is provided in the `@IntegrationComponentScan` * Use same util from the `GatewayParser` since there is no custom naming strategy configuration * Some other current Java level refactoring in the `IntegrationComponentScanRegistrar` and `MessagingGatewayRegistrar`
* Alias `@MessageEndpoint.value()` with a `@Component.value()` * Alias `@MessagingGateway.name()` with a `@MessageEndpoint.value()`
…nfiguration directly by the `GatewayProxyInstantiationPostProcessor` and `AnnotationGatewayProxyFactoryBean`. * The `MessagingGatewayRegistrar` logic has been migrated back to the `GatewayParser`, but only with an XML-relevant parts * Change the logic of the `IntegrationComponentScanRegistrar` to rely on a `ClassPathBeanDefinitionScanner` and its `scan()` functionality since this is all what we need to trigger a `GatewayProxyInstantiationPostProcessor` for scanned components * Fix `GatewayProxyInstantiationPostProcessor` to call an `afterPropertiesSet()` as well * Add a `value()` alias attribute for the `@MessagingGateway` to satisfy a name resolution from a `@Component` * Replace annotation chain resolution logic by new `MessagingAnnotationUtils.resolveMergedAttribute()` API * Use `MergedAnnotations` API in the `AnnotationGatewayProxyFactoryBean` to preserve a logic for attribute resolution from the annotation hierarchy * Add expression resolution for attribute values in the `AnnotationGatewayProxyFactoryBean` * Make a `GatewayInterfaceTests.CustomBeanNameGenerator` as an `AnnotationBeanNameGenerator` extension to satisfy the test logic expectations: no custom name if explicit is present * Clean up some doc typos after merge conflict The fix in this commit essentially resolves some old JIRA ticket: https://jira.spring.io/browse/INT-4558
Sorry, it took a bit more time than I expected: the annotation stuff has eaten my brain... |
* Optimize the logic in the `AnnotationGatewayProxyFactoryBean` around annotation attributes to plain annotation - no adaptation to maps
Fixes #3926
Current approach for generated bean name in the
MessagingGatewayRegistrar
is to decapitalize simple class name, which is similar to standardAnnotationBeanNameGenerator
MessagingGatewayRegistrar
based on the providedBeanNameGenerator
@IntegrationComponentScan.nameGenerator()
attribute to allow to customize default bean name generation strategyIntegrationConfigUtils.annotationBeanNameGenerator()
to take a providedAnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR
singleton or fallback to theAnnotationBeanNameGenerator.INSTANCE
IntegrationComponentScanRegistrar
if no custom strategy is provided in the@IntegrationComponentScan
GatewayParser
since there is no custom naming strategy configurationIntegrationComponentScanRegistrar
andMessagingGatewayRegistrar