Skip to content
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

Improve ability to introspect bean context prior to start #10805

Merged
merged 4 commits into from May 15, 2024

Conversation

graemerocher
Copy link
Contributor

@graemerocher graemerocher commented May 7, 2024

The existing InitializableBeanContext is problematic because it still creates context scoped beans and runs event listeners. We need a way to configure the context and allow it to be introspected prior to start so this deprecates InitializableBeanContext and replaces it with ConfigurableBeanContext and ConfigurableApplicationContext interfaces.

These feature a configure() method that loads the bean definitions and state needed to start the context but doesn't actually start it.

The PR also adds logic to assert the context is running when resolving beans which was missing before and could lead to odd behaviour.

@graemerocher graemerocher added the type: improvement A minor improvement to an existing feature label May 7, 2024
@graemerocher graemerocher added this to the 4.5.0 milestone May 7, 2024
@graemerocher graemerocher force-pushed the configurable-application-context branch from b4b7572 to ca09c33 Compare May 15, 2024 10:52
Copy link

sonarcloud bot commented May 15, 2024

Copy link
Contributor

@melix melix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked that these changes to not break AOT (without changing the code) and also after changing it to call the new configure() method.

Both work correctly 👍

Note that we were already using reflection to configure the context, so I could probably do something similar to support it right now (and probably remove the code for older Micronaut releases).

@graemerocher graemerocher merged commit 1a8fc61 into 4.5.x May 15, 2024
17 checks passed
@graemerocher graemerocher deleted the configurable-application-context branch May 15, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants