openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1429565 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/annotation/ main/java/org/apache/webbeans/component/creation/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/decorator/ main/java/org...
Date Sun, 06 Jan 2013 18:35:35 GMT
Author: struberg
Date: Sun Jan  6 18:35:35 2013
New Revision: 1429565

URL: http://svn.apache.org/viewvc?rev=1429565&view=rev
Log:
OWB-344 add Decorator method resolution

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/DecoratedClass.java
      - copied, changed from r1429558, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassAndMethodInterceptedClass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/NonInterceptedClass.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassMultiInterceptedClass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.xml

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=1429565&r1=1429564&r2=1429565&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
Sun Jan  6 18:35:35 2013
@@ -168,7 +168,7 @@ public final class AnnotationManager
      */
     public Annotation[] getInterceptorBindingMetaAnnotations(Set<Annotation> anns)
     {
-        return getInterceptorBindingMetaAnnotations(AnnotationUtil.asSet(anns));
+        return getInterceptorBindingMetaAnnotations(AnnotationUtil.asArray(anns));
     }
 
     /**
@@ -241,7 +241,7 @@ public final class AnnotationManager
         {
             if(parameter.isAnnotationPresent(clazz))
             {
-                Annotation[] anns = AnnotationUtil.asSet(parameter.getAnnotations());
+                Annotation[] anns = AnnotationUtil.asArray(parameter.getAnnotations());
                 for(Annotation ann : anns)
                 {
                     if(isQualifierAnnotation(ann.annotationType()))

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
Sun Jan  6 18:35:35 2013
@@ -122,7 +122,7 @@ public class AbstractBeanCreator<T>
 
     public void defineName(String name)
     {
-        Annotation[] anns = AnnotationUtil.asSet(getAnnotated().getAnnotations());
+        Annotation[] anns = AnnotationUtil.asArray(getAnnotated().getAnnotations());
         Named nameAnnot = null;
         boolean isDefault = false;
         for (Annotation ann : anns)
@@ -168,7 +168,7 @@ public class AbstractBeanCreator<T>
      */
     public void defineQualifiers()
     {
-        Annotation[] annotations = AnnotationUtil.asSet(annotated.getAnnotations());
+        Annotation[] annotations = AnnotationUtil.asArray(annotated.getAnnotations());
         final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
 
         for (Annotation annotation : annotations)
@@ -249,7 +249,7 @@ public class AbstractBeanCreator<T>
      */
     public void defineScopeType(String errorMessage, boolean allowLazyInit)
     {
-        Annotation[] annotations = AnnotationUtil.asSet(annotated.getAnnotations());
+        Annotation[] annotations = AnnotationUtil.asArray(annotated.getAnnotations());
         boolean found = false;
 
         List<ExternalScope> additionalScopes = webBeansContext.getBeanManagerImpl().getAdditionalScopes();
@@ -461,7 +461,7 @@ public class AbstractBeanCreator<T>
      */
     public void defineStereoTypes()
     {
-        Annotation[] anns = AnnotationUtil.asSet(annotated.getAnnotations());
+        Annotation[] anns = AnnotationUtil.asArray(annotated.getAnnotations());
         final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
         if (annotationManager.hasStereoTypeMetaAnnotation(anns))
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
Sun Jan  6 18:35:35 2013
@@ -231,7 +231,7 @@ public abstract class AbstractInjecionTa
             }
             
             Field field = annotatedField.getJavaMember();
-            Annotation[] anns = AnnotationUtil.asSet(annotatedField.getAnnotations());
+            Annotation[] anns = AnnotationUtil.asArray(annotatedField.getAnnotations());
             if(Modifier.isPublic(field.getModifiers()))
             {
                 if(!getBean().getScope().equals(Dependent.class))
@@ -324,7 +324,7 @@ public abstract class AbstractInjecionTa
         for (AnnotatedParameter<T> annotatedParameter : annotatedParameters)
         {
             annotationManager.checkForNewQualifierForDeployment(annotatedParameter.getBaseType(),
annotatedMethod.getDeclaringType().getJavaClass(),
-                    method.getName(), AnnotationUtil.asSet(annotatedParameter.getAnnotations()));
+                    method.getName(), AnnotationUtil.asArray(annotatedParameter.getAnnotations()));
 
             if(annotatedParameter.isAnnotationPresent(Disposes.class) ||
                     annotatedParameter.isAnnotationPresent(Observes.class))
@@ -444,7 +444,7 @@ public abstract class AbstractInjecionTa
                     }
                 }
                 
-                Annotation[] anns = AnnotationUtil.asSet(annotatedField.getAnnotations());
+                Annotation[] anns = AnnotationUtil.asArray(annotatedField.getAnnotations());
                 Field field = annotatedField.getJavaMember();
                 
                 //Producer field for resource
@@ -558,7 +558,7 @@ public abstract class AbstractInjecionTa
                 producerMethodBeanCreator.defineStereoTypes();
                 webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(getBean(),
                                                                                    producerMethodBean,
-                                                                                   AnnotationUtil.asSet(annotatedMethod.getAnnotations()));
+                                                                                   AnnotationUtil.asArray(annotatedMethod.getAnnotations()));
 
                 if (producerMethodBean.getReturnType().isArray())
                 {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Sun Jan  6 18:35:35 2013
@@ -927,7 +927,7 @@ public class BeanManagerImpl implements 
         // check for InjectionPoint injection
         if (rawType.equals(InjectionPoint.class))
         {
-            if (AnnotationUtil.hasAnnotation(AnnotationUtil.asSet(injectionPoint.getQualifiers()),
Default.class))
+            if (AnnotationUtil.hasAnnotation(AnnotationUtil.asArray(injectionPoint.getQualifiers()),
Default.class))
             {
                 if (!bean.getScope().equals(Dependent.class))
                 {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
Sun Jan  6 18:35:35 2013
@@ -175,7 +175,7 @@ public final class WebBeansDecoratorConf
         }
     }
 
-    public static Set<Decorator<?>> findDeployedWebBeansDecorator(BeanManagerImpl
beanManagerImpl, Set<Type> apiType, Annotation... anns)
+    public static Set<Decorator<?>> findDeployedWebBeansDecorator(BeanManagerImpl
beanManagerImpl, Set<Type> apiTypes, Annotation... anns)
     {
         Set<Decorator<?>> set = new HashSet<Decorator<?>>();
 
@@ -199,7 +199,7 @@ public final class WebBeansDecoratorConf
         {
             decorator = (WebBeansDecorator<?>) it.next();
 
-            if (decorator.isDecoratorMatch(apiType, listAnnot))
+            if (decorator.isDecoratorMatch(apiTypes, listAnnot))
             {
                 set.add(decorator);
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
Sun Jan  6 18:35:35 2013
@@ -455,7 +455,7 @@ public class ObserverMethodImpl<T> imple
                 //Get parameter annotations
                 Annotation[] bindingTypes =
                     annotationManager.getQualifierAnnotations(AnnotationUtil.
-                            asSet(parameter.getAnnotations()));
+                            asArray(parameter.getAnnotations()));
 
                 InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean,
parameter.getBaseType(),
                         parameter.getDeclaringCallable().getJavaMember(), parameter, bindingTypes);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
Sun Jan  6 18:35:35 2013
@@ -74,7 +74,7 @@ public class InjectionPointFactory
         Asserts.assertNotNull(annotField, "annotField parameter can not be null");
         Field member = annotField.getJavaMember();
 
-        Annotation[] annots = AnnotationUtil.asSet(annotField.getAnnotations());
+        Annotation[] annots = AnnotationUtil.asArray(annotField.getAnnotations());
 
         return getGenericInjectionPoint(owner, annots, annotField.getBaseType(), member,
annotField);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
Sun Jan  6 18:35:35 2013
@@ -44,6 +44,7 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
 import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 
 /**
@@ -83,6 +84,9 @@ public class InterceptorResolution
 
     public <T> BeanInterceptorInfo  calculateInterceptorInfo(Bean<T> bean, AnnotatedType<T>
annotatedType)
     {
+        Asserts.assertNotNull(bean, "Bean must not be null!");
+        Asserts.assertNotNull(annotatedType, "AnnotatedType must not be null!");
+
         List<AnnotatedMethod> interceptableAnnotatedMethods = getInterceptableBusinessMethods(annotatedType);
 
         AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
@@ -95,8 +99,12 @@ public class InterceptorResolution
 
         //X TODO pick up EJB-style interceptors from a class level
 
-        //X TODO pick up the decorators
-        List<Decorator<?>> decorators = beanManager.resolveDecorators(bean.getTypes(),
AnnotationUtil.asSet(bean.getQualifiers()));
+        // pick up the decorators
+        List<Decorator<?>> decorators = beanManager.resolveDecorators(bean.getTypes(),
AnnotationUtil.asArray(bean.getQualifiers()));
+        if (decorators.size() == 0)
+        {
+            decorators = null; // less to store
+        }
 
         Set<Interceptor<?>> allUsedCdiInterceptors = new HashSet<Interceptor<?>>();
         Map<Method, MethodInterceptorInfo> businessMethodInterceptorInfos = new HashMap<Method,
MethodInterceptorInfo>();
@@ -123,7 +131,7 @@ public class InterceptorResolution
             }
         }
 
-        return new BeanInterceptorInfo(null, allUsedCdiInterceptors, businessMethodInterceptorInfos);
+        return new BeanInterceptorInfo(decorators, allUsedCdiInterceptors, businessMethodInterceptorInfos);
     }
 
 
@@ -134,11 +142,14 @@ public class InterceptorResolution
             return;
         }
 
-        Set<Decorator<?>> appliedDecorators = new HashSet<Decorator<?>>();
+        List<Decorator<?>> appliedDecorators = new ArrayList<Decorator<?>>();
 
         for (Decorator decorator : decorators)
         {
-            isDecoratorInterceptsMethod(decorator, annotatedMethod, appliedDecorators);
+            if (isDecoratorInterceptsMethod(decorator, annotatedMethod))
+            {
+                appliedDecorators.add(decorator);
+            }
         }
 
         if (appliedDecorators.size() > 0)
@@ -147,7 +158,7 @@ public class InterceptorResolution
         }
     }
 
-    private boolean isDecoratorInterceptsMethod(Decorator decorator, AnnotatedMethod annotatedMethod,
Set<Decorator<?>> appliedDecorators)
+    private boolean isDecoratorInterceptsMethod(Decorator decorator, AnnotatedMethod annotatedMethod)
     {
         String annotatedMethodName = annotatedMethod.getJavaMember().getName();
 
@@ -162,8 +173,8 @@ public class InterceptorResolution
                 {
                     int modifiers = decoratorMethod.getModifiers();
                     if (Modifier.isFinal(modifiers) ||
-                            Modifier.isPrivate(modifiers) ||
-                            Modifier.isStatic(modifiers))
+                        Modifier.isPrivate(modifiers) ||
+                        Modifier.isStatic(modifiers))
                     {
                         continue;
                     }
@@ -187,7 +198,6 @@ public class InterceptorResolution
                             if (paramsMatch)
                             {
                                 // yikes our method is decorated by this very decorator type.
-                                appliedDecorators.add(decorator);
                                 return true;
                             }
                         }
@@ -220,7 +230,7 @@ public class InterceptorResolution
 
         List<Interceptor<?>> methodInterceptors
                 = webBeansContext.getBeanManagerImpl().resolveInterceptors(methodInterceptorInfo.getInterceptionType(),
-                                                                           AnnotationUtil.asSet(cummulatedInterceptorBindings));
+                                                                           AnnotationUtil.asArray(cummulatedInterceptorBindings));
 
         methodInterceptorInfo.setCdiInterceptors(methodInterceptors);
 
@@ -298,7 +308,7 @@ public class InterceptorResolution
      */
     public static class BeanInterceptorInfo
     {
-        public BeanInterceptorInfo(Set<Decorator<?>> decorators, Set<Interceptor<?>>
interceptors,
+        public BeanInterceptorInfo(List<Decorator<?>> decorators, Set<Interceptor<?>>
interceptors,
                                    Map<Method, MethodInterceptorInfo> businessMethodsInfo)
         {
             this.decorators = decorators;
@@ -315,7 +325,7 @@ public class InterceptorResolution
         /**
          * All the Decorator Beans active on this class.
          */
-        private Set<Decorator<?>> decorators = null;
+        private List<Decorator<?>> decorators = null;
 
         /**
          * For each business method which is either decorated or intercepted we keep an entry.
@@ -324,7 +334,7 @@ public class InterceptorResolution
         private Map<Method, MethodInterceptorInfo> businessMethodsInfo = new HashMap<Method,
MethodInterceptorInfo>();
 
 
-        public Set<Decorator<?>> getDecorators()
+        public List<Decorator<?>> getDecorators()
         {
             return decorators;
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
Sun Jan  6 18:35:35 2013
@@ -305,7 +305,7 @@ public final class WebBeansInterceptorCo
             Method method = methodB.getJavaMember();
             Set<Annotation> interceptorAnns = new HashSet<Annotation>();
 
-            Annotation[] methodAnns = AnnotationUtil.asSet(methodB.getAnnotations());
+            Annotation[] methodAnns = AnnotationUtil.asArray(methodB.getAnnotations());
             if (annotationManager.hasInterceptorBindingMetaAnnotation(methodAnns))
             {
                 Annotation[] anns =
@@ -313,7 +313,7 @@ public final class WebBeansInterceptorCo
                         methodAnns);
                 Annotation[] annsClazz =
                     annotationManager.getInterceptorBindingMetaAnnotations(
-                        AnnotationUtil.asSet(annotatedType.getAnnotations()));
+                        AnnotationUtil.asArray(annotatedType.getAnnotations()));
 
                 for (Annotation ann : anns)
                 {
@@ -328,7 +328,7 @@ public final class WebBeansInterceptorCo
 
             Annotation[] stereoTypes =
                 annotationManager.getStereotypeMetaAnnotations(
-                    AnnotationUtil.asSet(annotatedType.getAnnotations()));
+                    AnnotationUtil.asArray(annotatedType.getAnnotations()));
             for (Annotation stero : stereoTypes)
             {
                 if (annotationManager.hasInterceptorBindingMetaAnnotation(

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
Sun Jan  6 18:35:35 2013
@@ -638,7 +638,7 @@ public final class AnnotationUtil
         return null;        
     }
 
-    public static Annotation[] asSet(Set<Annotation> set)
+    public static Annotation[] asArray(Set<Annotation> set)
     {
         if(set != null)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sun Jan  6 18:35:35 2013
@@ -1943,7 +1943,7 @@ public final class WebBeansUtil
          if (component instanceof EnterpriseBeanMarker)
          {
              beans = new HashSet<Bean<?>>();
-             Set<Bean<?>> allBeans = ((BeanManagerImpl)(manager)).getBeans(Object.class,
AnnotationUtil.asSet(component.getQualifiers()));
+             Set<Bean<?>> allBeans = ((BeanManagerImpl)(manager)).getBeans(Object.class,
AnnotationUtil.asArray(component.getQualifiers()));
 
              for(Bean<?> candidateBean : allBeans)
              {
@@ -1964,7 +1964,7 @@ public final class WebBeansUtil
          else
          {
              beans = manager.getBeans(component.getBeanClass(),
-                     AnnotationUtil.asSet(component.getQualifiers()));
+                     AnnotationUtil.asArray(component.getQualifiers()));
          }
 
         for(Bean<?> bean : beans)
@@ -2080,7 +2080,7 @@ public final class WebBeansUtil
         {
             ProducerMethodBean<?> bean = beanEntry.getKey();
             AnnotatedMethod<?> annotatedMethod = beanEntry.getValue();
-            Annotation[] annotationsFromSet = AnnotationUtil.asSet(bean.getQualifiers());
+            Annotation[] annotationsFromSet = AnnotationUtil.asArray(bean.getQualifiers());
             Method disposal = annotationManager.getDisposalWithGivenAnnotatedMethod(annotatedType,
bean.getReturnType(), annotationsFromSet);
 
             AnnotatedMethod<?> disposalAnnotated = null;
@@ -2705,7 +2705,7 @@ public final class WebBeansUtil
 
     private <X> void checkManagedWebBeansInterceptorConditions(AnnotatedType<X>
type)
     {
-        Annotation[] anns = AnnotationUtil.asSet(type.getAnnotations());
+        Annotation[] anns = AnnotationUtil.asArray(type.getAnnotations());
 
         Class<?> clazz = type.getJavaClass();
         boolean hasClassInterceptors = false;
@@ -2746,7 +2746,7 @@ public final class WebBeansUtil
                 }
 
                 if (annotationManager.hasInterceptorBindingMetaAnnotation(
-                    AnnotationUtil.asSet(methodA.getAnnotations())))
+                    AnnotationUtil.asArray(methodA.getAnnotations())))
                 {
                     throw new WebBeansConfigurationException("Method : " + method.getName()
+ "in managed bean class : " + clazz.getName()
                                                     + " can not be defined as non-static,
non-private and final . Because it is annotated with at least one @InterceptorBinding");

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
Sun Jan  6 18:35:35 2013
@@ -24,7 +24,7 @@ import javax.annotation.PreDestroy;
 import org.apache.webbeans.test.component.intercept.webbeans.bindings.Transactional;
 
 /**
- * A simple class which is not intercepted
+ * A simple class which is class-level intercepted
  */
 @Transactional
 public class ClassInterceptedClass

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassMultiInterceptedClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassMultiInterceptedClass.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassMultiInterceptedClass.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassMultiInterceptedClass.java
Sun Jan  6 18:35:35 2013
@@ -26,7 +26,7 @@ import org.apache.webbeans.test.componen
 import org.apache.webbeans.test.component.intercept.webbeans.bindings.Transactional;
 
 /**
- * A simple class which is not intercepted
+ * A simple class which has multiple interceptors
  */
 @Transactional
 @Action

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/DecoratedClass.java
(from r1429558, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/DecoratedClass.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/DecoratedClass.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java&r1=1429558&r2=1429565&rev=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/DecoratedClass.java
Sun Jan  6 18:35:35 2013
@@ -18,77 +18,28 @@
  */
 package org.apache.webbeans.newtests.interceptors.factory.beans;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
 
-import org.apache.webbeans.test.component.intercept.webbeans.bindings.Transactional;
+import javax.enterprise.context.RequestScoped;
+import org.apache.webbeans.test.annotation.binding.Binding1;
+import org.apache.webbeans.test.component.service.IService;
 
 /**
- * A simple class which is not intercepted
+ * A simple class which has a Decorator of type
+ * {@link org.apache.webbeans.test.component.decorator.clean.ServiceDecorator}
  */
-@Transactional
-public class ClassInterceptedClass
+@RequestScoped
+@Binding1
+public class DecoratedClass implements IService
 {
-    private boolean defaultCtInvoked = false;
 
-    private int meaningOfLife;
-    private float f;
-    private char c;
-
-    public ClassInterceptedClass()
-    {
-        defaultCtInvoked = true;
-    }
-
-    @PostConstruct
-    public void postConstruct()
-    {
-        System.out.println("postConstruct invoked");
-    }
-
-    @PreDestroy
-    private void preDestroy()
-    {
-        System.out.println("preDestroy invoked");
-    }
-
-    public void init()
-    {
-        f = 2.4f;
-        c = 'c';
-        meaningOfLife = 42;
-    }
-
-    public int getMeaningOfLife() throws NumberFormatException
+    @Override
+    public String service()
     {
-        System.out.println("answering the question about life, the universe and everything!");
-        System.out.println("and being in " + this.getClass());
-        return meaningOfLife;
+        return "theOriginalValue";
     }
 
-    public void setMeaningOfLife(int meaningOfLife)
+    public int nonDecoratedMethod()
     {
-        this.meaningOfLife = meaningOfLife;
+        return 42;
     }
-
-    public float getFloat()
-    {
-        return f;
-    }
-
-    public ClassInterceptedClass getSelf()
-    {
-        return this;
-    }
-
-    public char getChar()
-    {
-        return c;
-    }
-
-    public String doThaBlowup() throws NumberFormatException
-    {
-        throw new NumberFormatException("should fit");
-    }
-
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
Sun Jan  6 18:35:35 2013
@@ -20,6 +20,7 @@ package org.apache.webbeans.newtests.int
 
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -28,9 +29,11 @@ import java.util.Map;
 import org.apache.webbeans.intercept.InterceptorResolution;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.interceptors.factory.beans.ClassInterceptedClass;
-
 import org.apache.webbeans.newtests.interceptors.factory.beans.ClassMultiInterceptedClass;
+import org.apache.webbeans.newtests.interceptors.factory.beans.DecoratedClass;
 import org.apache.webbeans.newtests.interceptors.factory.beans.MethodInterceptedClass;
+import org.apache.webbeans.test.annotation.binding.Binding1;
+import org.apache.webbeans.test.component.decorator.clean.ServiceDecorator;
 import org.apache.webbeans.test.component.intercept.webbeans.ActionInterceptor;
 import org.apache.webbeans.test.component.intercept.webbeans.SecureInterceptor;
 import org.apache.webbeans.test.component.intercept.webbeans.TransactionalInterceptor;
@@ -174,4 +177,33 @@ public class InterceptorResolutionTest  
     }
 
 
+    @Test
+    public void testDecoratorResolution() throws Exception
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(this.getClass().getPackage().getName(), this.getClass().getSimpleName()));
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(DecoratedClass.class);
+        beanClasses.add(ServiceDecorator.class);
+
+        startContainer(beanClasses, beanXmls);
+
+        InterceptorResolution ir = new InterceptorResolution(getWebBeansContext());
+        AnnotatedType<DecoratedClass> annotatedType = getBeanManager().createAnnotatedType(DecoratedClass.class);
+        Bean<DecoratedClass> bean = (Bean<DecoratedClass>) getBeanManager().resolve(
+                getBeanManager().getBeans(DecoratedClass.class, new AnnotationLiteral<Binding1>()
{}));
+
+        InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean,
annotatedType);
+        Assert.assertNotNull(interceptorInfo);
+
+        Assert.assertNotNull(interceptorInfo.getBusinessMethodsInfo());
+        Assert.assertEquals(1, interceptorInfo.getBusinessMethodsInfo().size());
+
+        Assert.assertNotNull(interceptorInfo.getDecorators());
+        Assert.assertEquals(1, interceptorInfo.getDecorators().size());
+
+        shutDownContainer();
+    }
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.xml?rev=1429565&r1=1429564&r2=1429565&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.xml
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.xml
Sun Jan  6 18:35:35 2013
@@ -18,9 +18,12 @@ specific language governing permissions 
 under the License.
 -->
 <beans>
-   <interceptors>
-      <class>org.apache.webbeans.test.component.intercept.webbeans.TransactionalInterceptor</class>
-      <class>org.apache.webbeans.test.component.intercept.webbeans.ActionInterceptor</class>
-      <class>org.apache.webbeans.test.component.intercept.webbeans.SecureInterceptor</class>
-   </interceptors>
+    <interceptors>
+        <class>org.apache.webbeans.test.component.intercept.webbeans.TransactionalInterceptor</class>
+        <class>org.apache.webbeans.test.component.intercept.webbeans.ActionInterceptor</class>
+        <class>org.apache.webbeans.test.component.intercept.webbeans.SecureInterceptor</class>
+    </interceptors>
+    <decorators>
+        <class>org.apache.webbeans.test.component.decorator.clean.ServiceDecorator</class>
+    </decorators>
 </beans>



Mime
View raw message