openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1623110 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/PassivationBeanWrapper.java component/creation/ManagedBeanBuilder.java util/WebBeansUtil.java
Date Sun, 07 Sep 2014 19:17:34 GMT
Author: rmannibucau
Date: Sun Sep  7 19:17:34 2014
New Revision: 1623110

URL: http://svn.apache.org/r1623110
Log:
ensure @Inject Bean<X> are done in X

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/PassivationBeanWrapper.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.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/component/PassivationBeanWrapper.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/PassivationBeanWrapper.java?rev=1623110&r1=1623109&r2=1623110&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/PassivationBeanWrapper.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/PassivationBeanWrapper.java
Sun Sep  7 19:17:34 2014
@@ -22,7 +22,8 @@ import org.apache.webbeans.config.WebBea
 
 import java.io.ObjectStreamException;
 
-public class PassivationBeanWrapper {
+public class PassivationBeanWrapper
+{
     private static final long serialVersionUID = 1L;
 
     private final String passivationId;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java?rev=1623110&r1=1623109&r2=1623110&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
Sun Sep  7 19:17:34 2014
@@ -63,6 +63,7 @@ public class ManagedBeanBuilder<T, M ext
         bean.setEnabled(webBeansContext.getWebBeansUtil().isBeanEnabled(annotatedType, bean.getStereotypes()));
         webBeansContext.getWebBeansUtil().checkManagedBeanCondition(annotatedType);
         WebBeansUtil.checkGenericType(annotatedType.getJavaClass(), beanAttributes.getScope());
+        webBeansContext.getWebBeansUtil().validateBeanInjection(bean);
         webBeansContext.getDeploymentValidationService().validateProxyable(bean);
         return bean;
     }

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=1623110&r1=1623109&r2=1623110&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 Sep  7 19:17:34 2014
@@ -1766,6 +1766,30 @@ public final class WebBeansUtil
         return beanAttributes;
     }
 
+    public void validateBeanInjection(final Bean<?> bean)
+    {
+        for (final InjectionPoint injectionPoint : bean.getInjectionPoints())
+        {
+            final Type type = injectionPoint.getType();
+            if (type instanceof ParameterizedType)
+            {
+                final Bean injectionPointBean = injectionPoint.getBean();
+                ParameterizedType pt = (ParameterizedType) type;
+
+                if (pt.getRawType() == Bean.class)
+                {
+                    final Class<?> beanClass = AbstractOwbBean.class.isInstance(injectionPointBean)
?
+                            AbstractOwbBean.class.cast(injectionPointBean).getReturnType()
: injectionPointBean.getBeanClass();
+                    final Type beanType = pt.getActualTypeArguments()[0];
+                    if (!GenericsUtil.isAssignableFrom(false, beanClass, beanType))
+                    {
+                        throw new DefinitionException("@Inject Bean<X> can only be
done in X, found " + beanType + " and " + beanClass);
+                    }
+                }
+            }
+        }
+    }
+
     private static final class EventCacheKey
     {
         private final Type event;



Mime
View raw message