feat(spring): @EnableStormRepositories for switching on repository scanning#229
Merged
Conversation
…anning Registering Storm repositories in plain Spring meant extending RepositoryBeanFactoryPostProcessor and overriding getRepositoryBasePackages(). That works, but it is not how Spring users expect to switch on a data library. - @EnableStormRepositories(basePackages/basePackageClasses, ormTemplateBeanName, repositoryPrefix) in storm-spring, mirroring @EnableJpaRepositories; without packages, the annotated class's package is scanned. The imported registrar binds repositories through the language stack on the classpath: the Kotlin adapter when storm-kotlin-spring is present, the Java adapter otherwise. - In Spring Boot the annotation doubles as the explicit override: the registrar-provided post-processor makes the starter's auto-configured scanning back off. Starter behavior without the annotation is unchanged. - The RepositoryBeanFactoryPostProcessor adapters gain configuring constructors (basePackages, ormTemplateBeanName, repositoryPrefix), so multi-template applications define one bean per repository set instead of one subclass per domain. Fixes #201
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Registering Storm repositories in plain Spring meant extending
RepositoryBeanFactoryPostProcessorand overridinggetRepositoryBasePackages(). That works, but it is not how Spring users expect to switch on a data library.Fixes #201
What's included
@EnableStormRepositories(basePackages/basePackageClasses, ormTemplateBeanName, repositoryPrefix)in storm-spring, mirroring@EnableJpaRepositories. Without explicit packages, the annotated class's package is scanned. One annotation serves both language stacks (storm-kotlin-spring depends on storm-spring, so it is one transitive hop away for Kotlin users): the imported registrar binds repositories through the language stack present on the classpath — the Kotlin adapter when storm-kotlin-spring is available, the Java adapter otherwise.@ConditionalOnMissingBeancondition. Starter behavior without the annotation is unchanged.RepositoryBeanFactoryPostProcessor(basePackages, ormTemplateBeanName, repositoryPrefix)in Java and Kotlin (named/default arguments), so multi-template applications define one bean per repository set instead of one subclass per domain. Subclassing keeps working unchanged.Verification
basePackageClasses, prefix bean naming, and default-package scanning through plainAnnotationConfigApplicationContexts.AutoConfiguredRepositoryBeanFactoryPostProcessorbacks off.Docs: both language tabs of spring-integration.md lead with the annotation, with the constructor-bean form documented for multi-template setups (Multiple Data Sources section updated to match); CHANGELOG entry covers the annotation and the constructors.