Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-11410 Camunda Engine Quarkus Extension
  3. CAM-13747

CDI: Investigate behavior of @Alternative annotation in conjunction with @Priority(1)

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.16.0, 7.16.0-alpha4
    • None
    • quarkus
    • None

      Problem

      • In the engine-cdi test suite, with ProgrammaticBeanLookupTest a test exists that tests if an alternative bean can be selected using the @Alternative annotation.
      • The only way to select an alternative bean implementation in CDI 1.0 is to declare the bean via the META-INF/beans.xml file [1].
      • In Quarkus, the content of the META-INF/beans.xml file is ignored, which means that it is not possible to select an alternative bean implementation via this file.

      Solution

      What Quarkus supports to specify an alternative bean implementation:

      • From CDI 1.1 onwards, it is possible to define an alternative implementation programmatically via @Priority(int) annotation [3].
      • Since @Priority cannot be used for producer methods, Quarkus offers the custom annotation io.quarkus.arc.AlternativePriority.
      • It is possible to select an alternative bean implementation via Quarkus application.properties file and the property quarkus.arc.selected-alternatives.

      You can read more about it in the official Quarkus documentation [4].

      Decision

      • Since our engine-cdi module doesn't make use of the @Alternative annotation, we don't need to document the alternative solutions.
      • We exclude the failing ProgrammaticBeanLookupTest in the Quarkus test suite and introduce a dedicated test [5] that ensures the behavior expected in Quarkus.

      [1] https://docs.jboss.org/weld/reference/1.0.0/en-US/html_single/#alternatives
      [2] https://quarkus.io/guides/cdi-reference#declaring-selected-alternatives
      [3] https://docs.jboss.org/weld/reference/2.2.0.Final/en-US/html_single/#alternatives
      [4] https://quarkus.io/guides/cdi-reference#declaring-selected-alternatives
      [5] https://github.com/camunda/camunda-bpm-platform/blob/master/quarkus-extension/engine/deployment/src/test/java/org/camunda/bpm/quarkus/engine/test/lookup/ProgrammaticBeanLookupTest.java

        This is the controller panel for Smart Panels app

              tassilo.weidner Tassilo Weidner
              tassilo.weidner Tassilo Weidner
              Tassilo Weidner Tassilo Weidner
              Nikola Koevski Nikola Koevski
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: