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

Revisit API for BeanContainer #35744

Closed
manovotn opened this issue Sep 5, 2023 · 0 comments · Fixed by #35776
Closed

Revisit API for BeanContainer #35744

manovotn opened this issue Sep 5, 2023 · 0 comments · Fixed by #35776
Labels
area/arc Issue related to ARC (dependency injection)
Milestone

Comments

@manovotn
Copy link
Contributor

manovotn commented Sep 5, 2023

Currently, the BeanContainer methods for bean resolution are pretty confusing for users.
The way it works is that a bean resolution is attempted and if there is no bean found, a default fallback is executed. However, this fallback is pretty simplistic and tries to instantiate an object via no-arg constructor which may or may not exist.

The current javadoc also seems to be fumbled now that I read it again (which is something I might have butchered back then) - the deprecated version should be the one that doesn't throw ambig. dep. exception which isn't quite clear now.

We could do some (or more) of the following:

  • Deprecate all bean resolving methods in this API and eventually delete them
    • The beanInstance and the beanInstanceFactory methods
  • Introduce a method providing access to Arc container
    • Basically just returning Arc.container(); user can do the rest from there
  • Retain beanInstance but change it's behavior so that it either returns the bean or null leaving user to handle the fallback in whichever way they want to
    • We could still deprecate/drop the beanInstanceFactory method in this case

Personally, I'd deprecate current methods and introduced two new ones:

  • One a convenient access method to ArcContainer
  • The other similar to beanInstance but well defined in that it performs a lookup, resolves ambiguity but in case no bean is found allows user to handle null whichever way they choose to

While at it, we should also look into internal usage of BeanContainerBuildItem - this is still useful to detect a 'container-ready' state in STATIC_INIT but has no real value in RUNTIME_INIT as the container is always active at that point in time.
For instance AmazonLambdaProcessor depends on this item for no real reason.

@manovotn manovotn added the area/arc Issue related to ARC (dependency injection) label Sep 5, 2023
@quarkus-bot quarkus-bot bot added this to the 3.5 - main milestone Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant