openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1646768 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Date Fri, 19 Dec 2014 15:21:49 GMT
Author: rmannibucau
Date: Fri Dec 19 15:21:49 2014
New Revision: 1646768

URL: http://svn.apache.org/r1646768
Log:
rewriting @AroundConstruct selection to ensure to use a single constructor and avoid to use
an aggregated view - including proxy oriented constructors

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1646768&r1=1646767&r2=1646768&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Fri Dec 19 15:21:49 2014
@@ -269,67 +269,53 @@ public class InterceptorResolutionServic
 
             allUsedCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.POST_CONSTRUCT,
interceptorBindings));
             allUsedCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.PRE_DESTROY,
interceptorBindings));
+        }
 
-            if (!annotatedType.getConstructors().isEmpty())
+        AnnotatedConstructor<?> constructorToUse = null;
+        if (!annotatedType.getConstructors().isEmpty()) // avoid to use class annotations
for not used constructors
+        {
+            for (final AnnotatedConstructor<?> c : annotatedType.getConstructors())
             {
-                for (final AnnotatedConstructor<?> c : annotatedType.getConstructors())
+                if (constructorToUse == null && c.getParameters().isEmpty())
                 {
-                    final Set<Annotation> constructorAnnot = webBeansContext.getAnnotationManager().getInterceptorAnnotations(c.getAnnotations());
-                    if (constructorAnnot.isEmpty())
-                    {
-                        allUsedCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.AROUND_CONSTRUCT,
interceptorBindings));
-                    }
-                    else
-                    {
-                        constructorAnnot.addAll(classInterceptorBindings);
-                        allUsedCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.AROUND_CONSTRUCT,
AnnotationUtil.asArray(constructorAnnot)));
-                    }
+                    constructorToUse = c;
+                }
+                else if (c.getAnnotation(Inject.class) != null)
+                {
+                    constructorToUse = c;
+                    break;
                 }
-            }
-            else
-            {
-                allUsedCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.AROUND_CONSTRUCT,
interceptorBindings));
             }
         }
-
-        if (!annotatedType.getConstructors().isEmpty())
+        if (constructorToUse != null)
         {
-            for (final AnnotatedConstructor<?> c : annotatedType.getConstructors())
+            final Set<Annotation> constructorAnnot = webBeansContext.getAnnotationManager().getInterceptorAnnotations(constructorToUse.getAnnotations());
+            for (final Annotation classA : classInterceptorBindings)
             {
-                final Set<Annotation> constructorAnnot = webBeansContext.getAnnotationManager().getInterceptorAnnotations(c.getAnnotations());
-                if (constructorAnnot.isEmpty())
+                boolean overriden = false;
+                for (final Annotation consA : constructorAnnot)
                 {
-                    if (interceptorBindings != null)
+                    if (classA.annotationType() == consA.annotationType())
                     {
-                        allUsedConstructorCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.AROUND_CONSTRUCT,
interceptorBindings));
+                        overriden = true;
+                        break;
                     }
                 }
-                else
+                if (!overriden)
                 {
-                    for (final Annotation classA : classInterceptorBindings)
-                    {
-                        boolean overriden = false;
-                        for (final Annotation consA : constructorAnnot)
-                        {
-                            if (classA.annotationType() == consA.annotationType())
-                            {
-                                overriden = true;
-                                break;
-                            }
-                        }
-                        if (!overriden)
-                        {
-                            constructorAnnot.add(classA);
-                        }
-                    }
-                    allUsedConstructorCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.AROUND_CONSTRUCT,
AnnotationUtil.asArray(constructorAnnot)));
+                    constructorAnnot.add(classA);
                 }
             }
+            if (!constructorAnnot.isEmpty())
+            {
+                allUsedConstructorCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.AROUND_CONSTRUCT,
AnnotationUtil.asArray(constructorAnnot)));
+            }
         }
         else if (interceptorBindings != null)
         {
             allUsedConstructorCdiInterceptors.addAll(beanManagerImpl.resolveInterceptors(InterceptionType.AROUND_CONSTRUCT,
interceptorBindings));
         }
+        allUsedCdiInterceptors.addAll(allUsedConstructorCdiInterceptors);
     }
 
     /**
@@ -389,7 +375,7 @@ public class InterceptorResolutionServic
         }
     }
 
-    private <T> void collectEjbInterceptors(List<Interceptor<?>> ejbInterceptors,
Annotated annotated, boolean unproxyable, Set<Type> types)
+    private void collectEjbInterceptors(List<Interceptor<?>> ejbInterceptors,
Annotated annotated, boolean unproxyable, Set<Type> types)
     {
         Interceptors interceptorsAnnot = annotated.getAnnotation(Interceptors.class);
         if (interceptorsAnnot != null)



Mime
View raw message