openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1623356 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/BeanManagerImpl.java util/WebBeansUtil.java
Date Mon, 08 Sep 2014 10:58:22 GMT
Author: struberg
Date: Mon Sep  8 10:58:21 2014
New Revision: 1623356

URL: http://svn.apache.org/r1623356
Log:
OWB-1002 check @Decorated and @Intercepted conditions

txs to Reinhard Sandtner (rsandtner) for the patch!

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

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1623356&r1=1623355&r2=1623356&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Mon Sep  8 10:58:21 2014
@@ -684,7 +684,7 @@ public class BeansDeployer
                 //Check injection points
                 if(injectionPoints != null)
                 {
-                    webBeansContext.getWebBeansUtil().validate(injectionPoints, bean instanceof
Decorator);
+                    webBeansContext.getWebBeansUtil().validate(injectionPoints, bean);
                 }
             }
             
@@ -705,7 +705,7 @@ public class BeansDeployer
             if (observerMethod instanceof OwbObserverMethod)
             {
                 OwbObserverMethod<?> owbObserverMethod = (OwbObserverMethod<?>)observerMethod;
-                webBeansContext.getWebBeansUtil().validate(owbObserverMethod.getInjectionPoints(),
false);
+                webBeansContext.getWebBeansUtil().validate(owbObserverMethod.getInjectionPoints(),
null);
             }
         }
     }

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=1623356&r1=1623355&r2=1623356&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
Mon Sep  8 10:58:21 2014
@@ -1166,7 +1166,7 @@ public class BeanManagerImpl implements 
                         interceptorUtil.getLifecycleMethods(type, PreDestroy.class));
         try
         {
-            webBeansContext.getWebBeansUtil().validate(injectionTarget.getInjectionPoints(),
false);
+            webBeansContext.getWebBeansUtil().validate(injectionTarget.getInjectionPoints(),
null);
         }
         catch (final InjectionException ie)
         {

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=1623356&r1=1623355&r2=1623356&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
Mon Sep  8 10:58:21 2014
@@ -87,8 +87,10 @@ import javax.enterprise.context.Dependen
 import javax.enterprise.context.NormalScope;
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Decorated;
 import javax.enterprise.inject.IllegalProductException;
 import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.Intercepted;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
@@ -106,6 +108,7 @@ import javax.enterprise.inject.spi.Defin
 import javax.enterprise.inject.spi.DeploymentException;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.PassivationCapable;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
@@ -1610,11 +1613,31 @@ public final class WebBeansUtil
         return builder.toString();
     }
 
-    public void validate(final Set<InjectionPoint> injectionPoints, final boolean isDecorator)
+    public void validate(final Set<InjectionPoint> injectionPoints, Bean<?> bean)
     {
+
+        boolean isDecorator = false;
+        boolean isInterceptor = false;
+
+        if (bean != null)
+        {
+            isInterceptor = bean instanceof Interceptor;
+            isDecorator = !isInterceptor && bean instanceof javax.enterprise.inject.spi.Decorator;
+        }
+
         boolean delegateFound = false;
         for (InjectionPoint injectionPoint : injectionPoints)
         {
+            if (!isDecorator && injectionPoint.getAnnotated().isAnnotationPresent(Decorated.class))
+            {
+                throw new DefinitionException(injectionPoint.getBean().getBeanClass() + "
must be a Decorator");
+            }
+
+            if (!isInterceptor && injectionPoint.getAnnotated().isAnnotationPresent(Intercepted.class))
+            {
+                throw new DefinitionException(injectionPoint.getBean().getBeanClass() + "
must be an Interceptor");
+            }
+
             if (!injectionPoint.isDelegate())
             {
                 webBeansContext.getBeanManagerImpl().validate(injectionPoint);



Mime
View raw message