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

possible chicken-egg problem with ProcessBeanAttributes#veto and specialization

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 1.2.Final
    • None
    • None

    Description

      Currently section 12 describes that ProcessBeanAttributes only should get fired for 'enabed beans'.

      12.4.3. Bean discovery

      • if the class is an enabled bean, interceptor or decorator, fire an event of type ProcessBeanAttributes, as defined in ProcessBeanAttributes event,

      But if you have class B extends A and B is @Specializes then you don't know which PBA to fire. Because B could get vetoed in ProcessBeanAttributes. And then while you fire PBA you implicitly change the list of enabled beans. This gets even more complicated by the ability of ProcessBeanAttributes to change the isAlternative bit and even the types of the whole bean.

      I think this might be a left-over of the split between Bean and BeanAttributes. The ProcessBeanAttributes is right in the middle between ProcessAnnotatedType and ProcessBean.

      • ProcessBean die not have a veto(), PAT does have it.
      • PAT gets fired for all discovered classes, ProcessBean only for enabled ones.

      I think the wording 'if the class is an enabled bean' is also misleading. We do not have a bean at this early stage! We only have an AnnotatedType. Maybe it should read ''if the class is a not vetoed AnnotatedType'?

      I'm not sure if there is a way the current wording could get cleanly implemented. I just stumbled across this because we did not fire a PBA for a class because the @Specialized bean got vetoed away.

      The same chicken-egg problem might apply to

      11.5.9. ProcessBeanAttributes event
      The container must fire an event for each bean, interceptor or decorator deployed in a bean
      archive, before registering the Bean object."

      Reads "for every bean". But we don't have any beans yet. We can only make the Bean<T> after the BeanAttributes get returned from PBA. Otherwise changing the bean attributes would have no effect on the Bean, right?

      What could work is roughly:

      • fire PAT for all detected classes
      • remove vetoed ones
      • fire PBA for all AnnotatedTypes
      • remove vetoed one
      • calculate disabled BeanAttributes (@Specializes rule for classes)
      • produce Beans

      Attachments

        Activity

          People

            Unassigned Unassigned
            struberg Mark Struberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: