openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1606690 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/apache/webbeans/util/ webbeans-tck/
Date Mon, 30 Jun 2014 11:29:33 GMT
Author: rmannibucau
Date: Mon Jun 30 11:29:33 2014
New Revision: 1606690

URL: http://svn.apache.org/r1606690
Log:
createInjectionTarget should validate the created InjectionTarget

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/container/InjectionTargetFactoryImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-tck/testng-dev.xml

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=1606690&r1=1606689&r2=1606690&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 Jun 30 11:29:33 2014
@@ -614,7 +614,7 @@ public class BeansDeployer
                 //Check injection points
                 if(injectionPoints != null)
                 {
-                    validate(injectionPoints, bean instanceof Decorator);               
    
+                    webBeansContext.getWebBeansUtil().validate(injectionPoints, bean instanceof
Decorator);
                 }
             }
             
@@ -635,38 +635,7 @@ public class BeansDeployer
             if (observerMethod instanceof OwbObserverMethod)
             {
                 OwbObserverMethod<?> owbObserverMethod = (OwbObserverMethod<?>)observerMethod;
-                validate(owbObserverMethod.getInjectionPoints(), false);
-            }
-        }
-    }
-
-    private void validate(Set<InjectionPoint> injectionPoints, boolean isDecorator)
-    {
-        boolean delegateFound = false;
-        for (InjectionPoint injectionPoint : injectionPoints)
-        {
-            if (!injectionPoint.isDelegate())
-            {
-                webBeansContext.getBeanManagerImpl().validate(injectionPoint);   
-            }
-            else
-            {
-                if (!isDecorator)
-                {
-                    throw new WebBeansConfigurationException(
-                            "Delegate injection points can not defined by beans that are
not decorator. Injection point : "
-                            + injectionPoint);
-                }
-                else if (delegateFound)
-                {
-                    throw new WebBeansConfigurationException(
-                            "Only one Delegate injection point can be defined by decorator.
Decorator : "
-                            + injectionPoint.getBean());
-                }
-                else
-                {
-                    delegateFound = true;
-                }
+                webBeansContext.getWebBeansUtil().validate(owbObserverMethod.getInjectionPoints(),
false);
             }
         }
     }

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=1606690&r1=1606689&r2=1606690&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 Jun 30 11:29:33 2014
@@ -32,6 +32,8 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.el.ELResolver;
 import javax.el.ExpressionFactory;
 import javax.enterprise.context.ContextNotActiveException;
@@ -41,6 +43,7 @@ import javax.enterprise.context.spi.Cont
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.Default;
+import javax.enterprise.inject.InjectionException;
 import javax.enterprise.inject.Stereotype;
 import javax.enterprise.inject.Vetoed;
 import javax.enterprise.inject.spi.*;
@@ -71,8 +74,10 @@ import org.apache.webbeans.event.Notific
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.definition.DuplicateDefinitionException;
 
+import org.apache.webbeans.intercept.InterceptorUtil;
 import org.apache.webbeans.plugins.OpenWebBeansJmsPlugin;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
+import org.apache.webbeans.portable.InjectionTargetImpl;
 import org.apache.webbeans.portable.events.discovery.ErrorStack;
 import org.apache.webbeans.spi.adaptor.ELAdaptor;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
@@ -1007,7 +1012,12 @@ public class BeanManagerImpl implements 
 
     public <T extends Extension> T getExtension(Class<T> type)
     {
-        return webBeansContext.getExtensionLoader().getExtension(type);
+        final T extension = webBeansContext.getExtensionLoader().getExtension(type);
+        if (extension == null)
+        {
+            throw new IllegalArgumentException("extension " + type + " not registered");
+        }
+        return extension;
     }
 
     @Override
@@ -1052,8 +1062,31 @@ public class BeanManagerImpl implements 
     @Override
     public <T> InjectionTarget<T> createInjectionTarget(AnnotatedType<T>
type)
     {
-        InjectionTargetFactoryImpl<T> factory = new InjectionTargetFactoryImpl<T>(type,
webBeansContext);
-        return factory.createInjectionTarget();
+        final InjectionTargetFactoryImpl<T> factory = new InjectionTargetFactoryImpl<T>(type,
webBeansContext);
+        final InterceptorUtil interceptorUtil = webBeansContext.getInterceptorUtil();
+        final InjectionTargetImpl<T> injectionTarget = new InjectionTargetImpl<T>(
+                        type,
+                        factory.createInjectionPoints(null),
+                        webBeansContext,
+                        interceptorUtil.getLifecycleMethods(type, PostConstruct.class, true),
+                        interceptorUtil.getLifecycleMethods(type, PreDestroy.class, true));
+        try
+        {
+            webBeansContext.getWebBeansUtil().validate(injectionTarget.getInjectionPoints(),
false);
+        }
+        catch (final InjectionException ie)
+        {
+            throw new IllegalArgumentException(ie);
+        }
+        catch (final WebBeansConfigurationException ie)
+        {
+            throw new IllegalArgumentException(ie);
+        }
+        catch (final DeploymentException ie)
+        {
+            throw new IllegalArgumentException(ie);
+        }
+        return webBeansContext.getWebBeansUtil().fireProcessInjectionTargetEvent(injectionTarget,
type).getInjectionTarget();
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionTargetFactoryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionTargetFactoryImpl.java?rev=1606690&r1=1606689&r2=1606690&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionTargetFactoryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionTargetFactoryImpl.java
Mon Jun 30 11:29:33 2014
@@ -61,7 +61,7 @@ public class InjectionTargetFactoryImpl<
         return webBeansContext.getWebBeansUtil().fireProcessInjectionTargetEvent(injectionTarget,
annotatedType).getInjectionTarget();
     }
 
-    protected Set<InjectionPoint> createInjectionPoints(Bean<T> bean)
+    public Set<InjectionPoint> createInjectionPoints(Bean<T> bean)
     {
         Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
         for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
annotatedType))

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=1606690&r1=1606689&r2=1606690&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 Jun 30 11:29:33 2014
@@ -1546,4 +1546,35 @@ public final class WebBeansUtil
 
         return builder.toString();
     }
+
+    public void validate(final Set<InjectionPoint> injectionPoints, final boolean isDecorator)
+    {
+        boolean delegateFound = false;
+        for (InjectionPoint injectionPoint : injectionPoints)
+        {
+            if (!injectionPoint.isDelegate())
+            {
+                webBeansContext.getBeanManagerImpl().validate(injectionPoint);
+            }
+            else
+            {
+                if (!isDecorator)
+                {
+                    throw new WebBeansConfigurationException(
+                            "Delegate injection points can not defined by beans that are
not decorator. Injection point : "
+                                    + injectionPoint);
+                }
+                else if (delegateFound)
+                {
+                    throw new WebBeansConfigurationException(
+                            "Only one Delegate injection point can be defined by decorator.
Decorator : "
+                                    + injectionPoint.getBean());
+                }
+                else
+                {
+                    delegateFound = true;
+                }
+            }
+        }
+    }
 }

Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1606690&r1=1606689&r2=1606690&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Mon Jun 30 11:29:33 2014
@@ -19,7 +19,7 @@
   <test name="JSR-346 TCK">
     <classes>
       <class
-          name="org.jboss.cdi.tck.tests.extensions.annotated.synthetic.ProcessSyntheticAnnotatedTypeTest"
/>
+          name="org.jboss.cdi.tck.tests.extensions.beanManager.BeanManagerTest" />
     </classes>
     <groups>
       <run>



Mime
View raw message