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 2015/05/25 21:29:38 UTC

svn commit: r1681638 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java

Author: struberg
Date: Mon May 25 19:29:38 2015
New Revision: 1681638

URL: http://svn.apache.org/r1681638
Log:
OWB-1075 improve annotation check performance

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java?rev=1681638&r1=1681637&r2=1681638&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java Mon May 25 19:29:38 2015
@@ -30,6 +30,7 @@ import org.apache.webbeans.util.ArrayUti
 import org.apache.webbeans.util.Asserts;
 
 import javax.enterprise.context.NormalScope;
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Default;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.New;
@@ -398,6 +399,17 @@ public final class AnnotationManager
 
     public void checkQualifierConditions(Annotation... qualifierAnnots)
     {
+        if (qualifierAnnots == null || qualifierAnnots.length == 0)
+        {
+            return;
+        }
+
+        if (qualifierAnnots.length == 1)
+        {
+            // performance hack to avoid Set creation
+            checkQualifierConditions(qualifierAnnots[0]);
+        }
+
         Set<Annotation> annSet = ArrayUtil.asSet(qualifierAnnots);
 
         //check for duplicate annotations
@@ -425,6 +437,14 @@ public final class AnnotationManager
 
     private void checkQualifierConditions(Annotation ann)
     {
+        if (ann == DefaultLiteral.INSTANCE || ann == AnyLiteral.INSTANCE ||
+            ann.annotationType().equals(Default.class) || ann.annotationType().equals(Any.class) ||
+            ann.annotationType().equals(Named.class))
+        {
+            // special performance boost for some known Qualifiers
+            return;
+        }
+
         Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(ann.annotationType());
 
         for (Method method : methods)