You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2023/01/25 19:37:41 UTC

[openwebbeans] branch main updated: OWB-1418 refine Priority on nested Stereotypes

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git


The following commit(s) were added to refs/heads/main by this push:
     new 53d3837cb OWB-1418 refine Priority on nested Stereotypes
53d3837cb is described below

commit 53d3837cb07f9d4fec5e41696882e2e5fd5561e2
Author: Mark Struberg <st...@apache.org>
AuthorDate: Wed Jan 25 20:37:04 2023 +0100

    OWB-1418 refine Priority on nested Stereotypes
---
 .../java/org/apache/webbeans/util/WebBeansUtil.java    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java b/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
index 3e279805d..a855a4521 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
@@ -905,7 +905,7 @@ public final class WebBeansUtil
             for (Class<? extends Annotation> stereotype : stereotypes)
             {
                 if (alternativesManager.isAlternativeStereotype(stereotype) &&
-                    (at.getAnnotation(Priority.class) != null || stereotype.getAnnotation(Priority.class) != null))
+                    (at.getAnnotation(Priority.class) != null || isStereotypeWithPriority(stereotype, stereotypes)))
                 {
                     return true;
                 }
@@ -916,6 +916,22 @@ public final class WebBeansUtil
 
     }
 
+    private boolean isStereotypeWithPriority(Class<? extends Annotation> stereotype, Set<Class<? extends Annotation>> stereotypes)
+    {
+        if (stereotype.getAnnotation(Priority.class) != null)
+        {
+            return true;
+        }
+        for (Annotation annotation : stereotype.getAnnotations())
+        {
+            if (stereotypes.contains(annotation.annotationType()) && annotation.annotationType().getAnnotation(Priority.class) != null)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public static boolean isAlternative(Annotated annotated, Set<Class<? extends Annotation>> stereotypes)
     {
         Asserts.assertNotNull(annotated, "annotated");