-
Notifications
You must be signed in to change notification settings - Fork 0
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
#1023 Updated implementation for ComponentPopulator #1028
Merged
Merged
Conversation
This file contains 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
cf25b0c
to
04de739
Compare
Following up on CVE-2023-6378 in #1029 (0.5.1) and #1030 (0.6.0) |
04de739
to
fd8f10a
Compare
Pending: hooks for processing the value into the injection point |
8231c6d
to
ddae45b
Compare
84c3a93
to
c071a45
Compare
…r, add populator tests
c071a45
to
3ca0deb
Compare
|
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.
Type of Change
Description
The current primary implementation of
ComponentPopulator
, theContextualComponentPopulator
, is a remnant of the old core implementation with all the associated drawbacks. The class is chaotic, has too many responsibilities at once, and is not easily extended.These changes introduce several strategies for a common
StrategyComponentPopulator
. This consists of two primary elements:ComponentPopulationStrategy
ComponentInjectionPointsResolver
Population Strategies
Population strategies allow us to define what information should be injected into given injection points (e.g. fields or method parameters). The
StrategyComponentPopulator
is able to track a collection of strategies, so it remains possible to customize which strategies are applied. As component population is a core component of theComponentFinalizingPostProcessor
, it has been made configurable with appropriate customizers.There are two built-in strategies:
ContextPopulationStrategy
: This strategy is responsible for supporting injection points annotated with@Context
, and resolving the appropriate context on the application context.InjectPopulationStrategy
: This strategy is responsible for supporting injection points annotated with@Inject
, and obtaining the appropriate instance from the application context. The annotation(s) supported by this strategy are configurable, so support for custom injection markers is possible.Both strategies have appropriate customization support, and can be (un)installed from the populator if preferred.
Injection Points Resolvers
To inject content into injection points, you first need to know what the injection points are. Injection points resolvers take care of this step. The default implementation is the
MethodsAndFieldsInjectionPointResolver
, which is also configurable in the configurer forStrategyComponentPopulator
. This resolver respects the existing@Populate
annotation, and will only include injection points compatible with this marker if it is present. If@Populate
is not present, both methods and fields will be included as injection points.Changes to context injection
Context
types used to be injected into injection points decorated with@Context
. This injection strategy has been rewritten to work with the@Inject
annotation. If the target type is a child ofContext
, the strategy will first check if a compatible context is present in the application. If there is a compatible context, it will be used for injection. If no compatible context is present, regular injection will be used for fallback, if possible.Checklist
develop
branchRelated Issue
Closes #1023