-
Notifications
You must be signed in to change notification settings - Fork 78
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
Feature/replace componentscan #386
Feature/replace componentscan #386
Conversation
✅ Deploy Preview for springwolf-ui canceled.
|
TBD: springboot internal autoconfigurations as well as external springboot 'starter' libs typically define their beans with |
Thank you for this huge improvement @tvahrst and good to see you again. We most likely review the PR this Friday and am already excited to dive more in depth and learn from it! The use of conditionalOnMissingBean sounds good. If it is a larger change, maybe a second PR is good for it (can be on top of this one)? |
well, the PR looks larger than it effectivly is ;-) I basically put all springbeans as @bean Definitions into configuration classes... Extending the bean definitions with @ConditionalOnMissingBean is indeed an optional step, we can add this feature with an additional PR. |
...wolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsService.java
Show resolved
Hide resolved
...mir/springwolf/asyncapi/scanners/channels/annotation/AbstractMethodLevelListenerScanner.java
Outdated
Show resolved
Hide resolved
...amir/springwolf/asyncapi/scanners/channels/annotation/AbstractClassLevelListenerScanner.java
Outdated
Show resolved
Hide resolved
...io/github/stavshamir/springwolf/asyncapi/scanners/classes/AbstractAnnotatedClassScanner.java
Show resolved
Hide resolved
...rc/main/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketService.java
Show resolved
Hide resolved
...ngwolf-core/src/main/java/io/github/stavshamir/springwolf/schemas/DefaultSchemasService.java
Show resolved
Hide resolved
As suggested in the PR Co-authored-by: sam0r040 <[email protected]>
Thank you @tvahrst and @harare for this huge improvement of springwolf and transforming it more into a library! We like the changes very much and indeed, the change looked bigger than it actually is :) We applied your suggestion of cleaning up the We do have one question regarding the Let's put the From our point of view, this is ready to be merged and this can be marked as |
Yes, I think, this is a good idea. If we were using the (old) spring interface Should we move the annotations with this PR or with an seperate one? |
Great, let's move the remaining Ordered annotations to the Configuration classes as well. For me, it is consistent to include it in this PR as well - in essence the existing annotation is refactored/moved. After updating the PR, we can merge it :) |
Ok! I moved the remaining |
The change has been merged and will be part of the next release. If you want to try and verify it in your application, use the current Thank you for the report/contribution! |
This PR resolves #291 . The core module and all plugin modules have their own local, isolated autoconfigurations. The autoconfigurations define the necessary beans explicitly via @bean annotations, component-scan over all spring-wolf modules was removed.
Some implementation details:
I structed the configuration classes: One 'root' autoconfiguration and special configurations (for the scanner/processor beans and for the web-beans) which are imported into the autoconfiguration.
two core classes used @Autowired for dependency injection (
AbstractClassLevelListenerScanner
andAbstractMethodLevelListenerScanner
). I replaced @Autowired with Constructor injection (like all other Springbean classes)ConfigurationProperties Beans do not need to be spring-configurations, so I removed the @configuration annotation from these bean-classes.
@conditional* and @order Annotations had to be moved from springbean classes into the configuration classes, because these annotations must be located where beans are defined.
The @service / @component annotations in the springbean classes aren't necessary anymore, but I leaved them as kind of 'documentation' that these classes are springbean classes.
Some classes used
Optional<>
for dependencies, i.e.Optional<Environment>
,Optional<SpringwolfConfigProperties>
,Optional<List<...>>
. I removed these Optionals:**
Optional<Environment>
is not necessary, because the Environment is always present**
Optional<SpringwolfConfigProperties>
is now explicitly defined the spring configuration and not optional anymore**
Optional<List<...>>
is not necessary, because spring injects always a non-null CollectionOne test (
DefaultAsyncApiDocketServiceTest#testNoConfigurationShouldThrowException
) became obsolet because SpringwolfConfigProperties aren't optional anymore.Some tests had to be modified due to the change from component-scanning to explicit bean configuration
currently the packages in the plugin modules share the same namespace, there are no plugin specific packages to differentiate for example kafka and amqp scanners. For now, I put the spring configurations in all plugin modules into the package 'io.github.stavshamir.springwolf.asyncapi.{pluginname}'