Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-712

Clarify whether is should be possible to "override" built-in Instance/Provider

    Details

    • Type: Clarification
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 2.1 (Discussion)
    • Component/s: None
    • Labels:
      None

      Description

      In theory, an extension could register an alternative custom bean to override the built-in Instance/Provider bean for injection points such as @Inject Provider<String>.

      It is not forbidden at the moment. The spec only states that there must be a built-in bean eligible for any injection point with Instance/Provider required type and any qualifier. See also https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#builtin_instance.

      It seems to be a powerful feature. On the other hand, it might be a source of confusion. Take for example this injection point:

      @Inject
      @MyQualifier
      Instance<String> instance;
      

      The qualifier is now considered when calling instance.get() and NOT when resolving the injection point.

      Note that the spec already allows to decorate built-in beans.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                mkouba Martin Kouba
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: