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 2014/09/19 11:37:26 UTC
svn commit: r1626160 -
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
Author: struberg
Date: Fri Sep 19 09:37:26 2014
New Revision: 1626160
URL: http://svn.apache.org/r1626160
Log:
OWB-1010 fix Stereotype annotation override rules
txs to Reinhard Sandnter(rsandtner) for the patch!
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=1626160&r1=1626159&r2=1626160&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 Fri Sep 19 09:37:26 2014
@@ -142,6 +142,7 @@ public final class AnnotationManager
// check for stereotypes _explicitly_ declared on the bean class (not inherited)
Annotation[] stereoTypes = getStereotypeMetaAnnotations(typeAnns.toArray(new Annotation[typeAnns.size()]));
+ Map<Class<? extends Annotation>, Annotation> annotationsFromSteretypes = new HashMap<Class<? extends Annotation>, Annotation>();
for (Annotation stereoType : stereoTypes)
{
if (hasInterceptorBindingMetaAnnotation(stereoType.annotationType().getDeclaredAnnotations()))
@@ -151,14 +152,25 @@ public final class AnnotationManager
for (Annotation ann : steroInterceptorBindings)
{
Annotation oldBinding = bindings.get(ann.annotationType());
- if (oldBinding != null && !AnnotationUtil.isCdiAnnotationEqual(oldBinding, ann))
+
+ // annotations which are declared on bean class overrides the one
+ // declared in stereotypes
+ if (oldBinding == null)
+ {
+ bindings.put(ann.annotationType(), ann);
+ }
+ else
{
- throw new WebBeansConfigurationException("Illegal interceptor binding: annotation of type "
- + ann.annotationType().getName()
- + " is present twice with diffenent values: "
- + oldBinding.toString() + " and " + ann.toString());
+ if (annotationsFromSteretypes.containsKey(ann.annotationType()) && !AnnotationUtil.isCdiAnnotationEqual(oldBinding, ann))
+ {
+ throw new WebBeansConfigurationException("Illegal interceptor binding: annotation of type "
+ + ann.annotationType().getName()
+ + " is present twice with diffenent values: "
+ + oldBinding.toString() + " and " + ann.toString());
+ }
}
- bindings.put(ann.annotationType(), ann);
+
+ annotationsFromSteretypes.put(ann.annotationType(), ann);
}
}
}