Drop the warning about using multipe hints in component definition

Hi everyone,

I recently add the need to use multiple hints for a component definition, however I hesitated to do so because of the warning we currently have in the documentation: https://extensions.xwiki.org/xwiki/bin/view/Extension/Component%20Module#HRegisteringaComponentwithseveralHints

While this feature is still valid in 3.1+, in the future we’ll either drop this feature (since there are workarounds) or we’ll add the ability to specify several @Named annotations. We recommend to not start depending on this feature as much as possible to prevent future incompatibilities.

Now when I asked about it in the chat @tmortagne indicated that:

The thing with @Named is that it’s actually not on our side AFAIR, I think we checked and that it’s simply not defined to allow being used multiple times. That warning was probably a bit premature.

Knowing that it’s a valid usecase to have multiple hints in component (even if not the most common one), and that we do allow that construct for a long time, meaning that we’ll have to preserve the backward compatibility anyway. I propose that we just drop the warning from our documentation.



To give a bit more details: for an annotation to be usable several times at the same location it needs to be annotated with @Repeatable, which is unfortunately not the case of the @Named annotation.

For me, this probably shows that our concept of supporting several hints for the same component with @Named is not the right one (and at least not “standard”). One approach would be to use the @Qualifier annotation for this (note that @Named is actually a qualifier). CDI 3 seems to support repeatable qualifiers: Jakarta Contexts and Dependency Injection

BTW I’ve noticed that CDI (and other frameworks using @Named) support using an @Named annotation without a value (in this case the annotated element name is used as the value, with the first letter lowercased - see Jakarta Contexts and Dependency Injection ).

EDIT: We said that XWiki was supporting Guice (to some extent) and we even have some test to prove this. For this to be more true, we would need to add support for qualifiers.