openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1739140 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/BeanManagerImpl.java container/InjectableBeanManager.java container/InjectionResolver.java
Date Thu, 14 Apr 2016 16:55:07 GMT
Author: rmannibucau
Date: Thu Apr 14 16:55:07 2016
New Revision: 1739140

URL: http://svn.apache.org/viewvc?rev=1739140&view=rev
Log:
OWB-1129 AfterBeanDiscovery flag needs to handle 3 states

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/InjectableBeanManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.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=1739140&r1=1739139&r2=1739140&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
Thu Apr 14 16:55:07 2016
@@ -670,13 +670,15 @@ public class BeansDeployer
     private void fireAfterBeanDiscoveryEvent()
     {
         BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
-        manager.setAfterBeanDiscoveryFired(true);
+        manager.setAfterBeanDiscoveryStart();
         final AfterBeanDiscoveryImpl event = new AfterBeanDiscoveryImpl(webBeansContext);
         manager.fireLifecycleEvent(event);
 
+
         webBeansContext.getWebBeansUtil().inspectDefinitionErrorStack(
                 "There are errors that are added by AfterBeanDiscovery event observers. Look
at logs for further details");
 
+        manager.setAfterBeanDiscoveryDone();
         event.setStarted();
     }
     

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=1739140&r1=1739139&r2=1739140&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
Thu Apr 14 16:55:07 2016
@@ -194,10 +194,10 @@ public class BeanManagerImpl implements
     private boolean inUse = false;
 
     /**
-     * This flag will get set to {@code true} after the
-     * {@link javax.enterprise.inject.spi.AfterBeanDiscovery} gets fired
+     * This flag will get set to handle lifecyle around
+     * {@link javax.enterprise.inject.spi.AfterBeanDiscovery}
      */
-    private boolean afterBeanDiscoveryFired = false;
+    private LifecycleState beanDiscoveryState = LifecycleState.BEFORE_DISCOVERY;
 
     /**
      * This flag will get set to {@code true} after the
@@ -1214,7 +1214,7 @@ public class BeanManagerImpl implements
                         webBeansContext,
                         interceptorUtil.getLifecycleMethods(type, PostConstruct.class),
                         interceptorUtil.getLifecycleMethods(type, PreDestroy.class));
-        if (afterBeanDiscoveryFired)
+        if (isAfterBeanDiscoveryDone())
         {
             try
             {
@@ -1435,23 +1435,38 @@ public class BeanManagerImpl implements
         return inUse;
     }
 
-    public boolean isAfterBeanDiscoveryFired()
+    public boolean isAfterDeploymentValidationFired()
     {
-        return afterBeanDiscoveryFired;
+        return afterDeploymentValidationFired;
     }
 
-    public void setAfterBeanDiscoveryFired(boolean afterBeanDiscoveryFired)
+    public void setAfterDeploymentValidationFired(boolean afterDeploymentValidationFired)
     {
-        this.afterBeanDiscoveryFired = afterBeanDiscoveryFired;
+        this.afterDeploymentValidationFired = afterDeploymentValidationFired;
     }
 
-    public boolean isAfterDeploymentValidationFired()
+    public void setAfterBeanDiscoveryStart()
     {
-        return afterDeploymentValidationFired;
+        this.beanDiscoveryState = LifecycleState.DISCOVERY;
     }
 
-    public void setAfterDeploymentValidationFired(boolean afterDeploymentValidationFired)
+    public void setAfterBeanDiscoveryDone()
     {
-        this.afterDeploymentValidationFired = afterDeploymentValidationFired;
+        this.beanDiscoveryState = LifecycleState.AFTER_DISCOVERY;
+    }
+
+    public boolean isAfterBeanDiscoveryDone()
+    {
+        return beanDiscoveryState == LifecycleState.AFTER_DISCOVERY;
+    }
+
+    public boolean isAfterBeanDiscovery()
+    {
+        return beanDiscoveryState == LifecycleState.DISCOVERY;
+    }
+
+    private enum LifecycleState
+    {
+        BEFORE_DISCOVERY, DISCOVERY, AFTER_DISCOVERY
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java?rev=1739140&r1=1739139&r2=1739140&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
Thu Apr 14 16:55:07 2016
@@ -397,7 +397,7 @@ public class InjectableBeanManager imple
      */
     private void checkAfterBeanDiscoveryProcessed(String message)
     {
-        if (!bm.isAfterBeanDiscoveryFired())
+        if (!bm.isAfterBeanDiscoveryDone() && !bm.isAfterBeanDiscovery())
         {
             throw new IllegalStateException(message);
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1739140&r1=1739139&r2=1739140&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Thu Apr 14 16:55:07 2016
@@ -189,7 +189,7 @@ public class InjectionResolver
             throw new WebBeansConfigurationException("Injection point type : " + injectionPoint
+ " type can not be defined as Typevariable or Wildcard type!");
         }
 
-        if (webBeansContext.getBeanManagerImpl().isAfterBeanDiscoveryFired())
+        if (webBeansContext.getBeanManagerImpl().isAfterBeanDiscoveryDone())
         {
             Annotation[] qualifiers = new Annotation[injectionPoint.getQualifiers().size()];
             qualifiers = injectionPoint.getQualifiers().toArray(qualifiers);



Mime
View raw message