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

Clarify how default bean EL name and @Named qualifier with no value at injection point are related

    Details

    • Type: Clarification
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1.PRD
    • Component/s: None
    • Labels:
      None

      Description

      Related CDI 1.0 spec chapters:
      2.5.2 Default bean EL names
      3.11 The qualifier @Named at injection points

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            mkouba Martin Kouba added a comment -

            To sum it up:

            1. A bean may have an EL name (2.5. Bean EL names)
            2. EL name is declared with the @Named qualifier (2.5. Bean EL names)
            3. If the @Named annotation does not specify the value member, the EL name is defaulted (2.5. Bean EL names)
            4. The defaulted name is used in typesafe resolution: "If an injected field declares a @Named annotation that does not specify the value member, the name of the field is assumed." and the qualifier is changed to @Named(DEFAULT_NAME)(3.13. The qualifier @Named at injection points)
            5. However in case of @Named is used on stereotype only EL name is defaulted

            So if I understand it correctly the only clarification required for "2.5. Bean EL names" is: "If a bean declares @Named qualifier and no EL name is explicitly specified, the default EL name is assigned, and the qualifier is @Named(value=DEFAULT_NAME).".

            Otherwise a bean with the @Named annotation that does not specify the value member could not be resolved - see example below.

            @Named
            public class Ant {}
             
            public class AntHill {
              @Inject
              @Named // -> @Named("ant") --> UnsatisfiedResolutionException
              private Ant ant;
            }
            

            Show
            mkouba Martin Kouba added a comment - To sum it up: A bean may have an EL name (2.5. Bean EL names) EL name is declared with the @Named qualifier (2.5. Bean EL names) If the @Named annotation does not specify the value member, the EL name is defaulted (2.5. Bean EL names) The defaulted name is used in typesafe resolution: "If an injected field declares a @Named annotation that does not specify the value member, the name of the field is assumed." and the qualifier is changed to @Named(DEFAULT_NAME)(3.13. The qualifier @Named at injection points) However in case of @Named is used on stereotype only EL name is defaulted So if I understand it correctly the only clarification required for "2.5. Bean EL names" is: "If a bean declares @Named qualifier and no EL name is explicitly specified, the default EL name is assigned, and the qualifier is @Named(value=DEFAULT_NAME).". Otherwise a bean with the @Named annotation that does not specify the value member could not be resolved - see example below. @Named public class Ant {}   public class AntHill { @Inject @Named // -> @Named("ant") --> UnsatisfiedResolutionException private Ant ant; }
            Hide
            pmuir Pete Muir added a comment -

            A quick note on Martin's analysis:

            4. The default name is not used in all typesafe resolution, but just field injection.

            Show
            pmuir Pete Muir added a comment - A quick note on Martin's analysis: 4. The default name is not used in all typesafe resolution, but just field injection.
            Hide
            pmuir Pete Muir added a comment -

            Would it not be cleaner to generally discuss how @Named qualifiers are defaulted, and then make the EL Name use that?

            Show
            pmuir Pete Muir added a comment - Would it not be cleaner to generally discuss how @Named qualifiers are defaulted, and then make the EL Name use that?
            Hide
            mkouba Martin Kouba added a comment -

            Agreed. I think the way @Named qualifier is defaulted on field injection point is reasonable and could be also used for bean definitions...

            Show
            mkouba Martin Kouba added a comment - Agreed. I think the way @Named qualifier is defaulted on field injection point is reasonable and could be also used for bean definitions...
            Hide
            pmuir Pete Muir added a comment - - edited

            Please review https://github.com/jboss/cdi/pull/77

            This one should be reviewed at the CDI EG meeting.

            Show
            pmuir Pete Muir added a comment - - edited Please review https://github.com/jboss/cdi/pull/77 This one should be reviewed at the CDI EG meeting.
            Hide
            pmuir Pete Muir added a comment -

            The pull is updated with a much simpler approach, please review.

            Show
            pmuir Pete Muir added a comment - The pull is updated with a much simpler approach, please review.
            Hide
            mkouba Martin Kouba added a comment -

            Yes, much simpler and still working.

            Show
            mkouba Martin Kouba added a comment - Yes, much simpler and still working.

              People

              • Assignee:
                pmuir Pete Muir
                Reporter:
                mkouba Martin Kouba
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Development