openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1625320 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Date Tue, 16 Sep 2014 14:41:43 GMT
Author: struberg
Date: Tue Sep 16 14:41:43 2014
New Revision: 1625320

URL: http://svn.apache.org/r1625320
Log:
OWB-1007 @Decorated bean checks

txs to Reinhard Sandtner (rsandtner) for the patch

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

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=1625320&r1=1625319&r2=1625320&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
Tue Sep 16 14:41:43 2014
@@ -1629,9 +1629,33 @@ public final class WebBeansUtil
         boolean delegateFound = false;
         for (InjectionPoint injectionPoint : injectionPoints)
         {
-            if (!isDecorator && injectionPoint.getAnnotated().isAnnotationPresent(Decorated.class))
+            if (injectionPoint.getAnnotated().isAnnotationPresent(Decorated.class))
             {
-                throw new DefinitionException(injectionPoint.getBean().getBeanClass() + "
must be a Decorator");
+                if (isDecorator)
+                {
+                        Type[] types = ClassUtil.getActualTypeArguments(injectionPoint.getType());
+                        if (types.length != 1 ||
+                                !((javax.enterprise.inject.spi.Decorator) bean).getDecoratedTypes().contains(types[0]))
+                        {
+                            throw new DefinitionException("ParametrizedType must be a DecoratedType");
+                        }
+                }
+                else
+                {
+                    throw new DefinitionException(injectionPoint.getBean().getBeanClass()
+ " must be a Decorator");
+                }
+            }
+            else
+            {
+                Class<?> rawType = ClassUtil.getRawTypeForInjectionPoint(injectionPoint);
+                if (rawType.equals(javax.enterprise.inject.spi.Decorator.class) || (isDecorator
&& rawType.equals(Bean.class)))
+                {
+                    Type[] types = ClassUtil.getActualTypeArguments(injectionPoint.getType());
+                    if (types.length != 1 || !injectionPoint.getBean().getBeanClass().equals(types[0]))
+                    {
+                        throw new DefinitionException("injected bean parameter must be "
+ rawType);
+                    }
+                }
             }
 
             if (!isInterceptor && injectionPoint.getAnnotated().isAnnotationPresent(Intercepted.class))



Mime
View raw message