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

Result of Application methods for CDI beans #1215

Open
jansupol opened this issue Feb 7, 2024 · 1 comment
Open

Result of Application methods for CDI beans #1215

jansupol opened this issue Feb 7, 2024 · 1 comment

Comments

@jansupol
Copy link
Contributor

jansupol commented Feb 7, 2024

Application getClasses() and getSingletons() return the classes and instances used by the application. Should they not be registered, they would not be used by the application.

However, in the CDI, should the providers be CDI beans, no matter whether they are registered or not, they are known to CDI.
Hence, getting all providers from CDI will include them.

The questions:

  1. Should the CDI bean providers be included just when registered in the Application? Or is it ok to have the provider be a bean and it no longer needs to be registered (using the META-INF/services/jakarta.ws.rs.core.Feature for instance)?
  2. If so, does it matter that the behaviour could be potentially different in the CDI-managed environment and non-cdi env using the non-cdi injection?
@jamezp
Copy link
Contributor

jamezp commented Feb 7, 2024

This is a good question and is relevant to both 3.2 and 4.0.

The Application.getSingletons() is deprecated which helps us out a bit. We can't really use CDI for anything returned from this method as it returns already instantiated objects.

For Application.getClasses(), I think those should be usable in that you could use the BeanManager to lookup those types.

With regards to the service loading, that's a great question. Without creating some kind of custom ServiceLoader which returns only class types, there really isn't a good way to make those providers a CDI bean. Therefore, IMO, we should state anything loaded from a service loader will not work with CDI. Not sure on the exact wording we should use though.

That said, from an implementation point of view, I could see creating a service loader which registers those as CDI beans in an CDI extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants