openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject svn commit: r1710767 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/InjectionResolver.java
Date Tue, 27 Oct 2015 10:49:43 GMT
Author: tandraschko
Date: Tue Oct 27 10:49:42 2015
New Revision: 1710767

URL: http://svn.apache.org/viewvc?rev=1710767&view=rev
Log:
OWB-1095 fixed InjectionResolver cache handling on startup

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/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=1710767&r1=1710766&r2=1710767&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
Tue Oct 27 10:49:42 2015
@@ -216,6 +216,8 @@ public class BeansDeployer
                 // Register Manager built-in component
                 webBeansContext.getBeanManagerImpl().addInternalBean(webBeansContext.getWebBeansUtil().getManagerBean());
 
+                webBeansContext.getBeanManagerImpl().getInjectionResolver().setStartup(true);
+                
                 //Fire Event
                 fireBeforeBeanDiscoveryEvent();
                 
@@ -286,6 +288,7 @@ public class BeansDeployer
                 // do some cleanup after the deployment
                 scanner.release();
                 webBeansContext.getAnnotatedElementFactory().clear();
+                webBeansContext.getBeanManagerImpl().getInjectionResolver().setStartup(false);
             }
         }
         catch (UnsatisfiedResolutionException e)

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=1710767&r1=1710766&r2=1710767&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
Tue Oct 27 10:49:42 2015
@@ -99,6 +99,8 @@ public class InjectionResolver
      */
     private Map<String, Set<Bean<?>>> resolvedBeansByName = new ConcurrentHashMap<String,
Set<Bean<?>>>();
 
+    private boolean startup;
+    
     /**
      * Creates a new injection resolve for given bean manager.
      *
@@ -108,8 +110,14 @@ public class InjectionResolver
     {
         this.webBeansContext = webBeansContext;
         this.alternativesManager = webBeansContext.getAlternativesManager();
+        this.startup = false;
     }
 
+    public void setStartup(boolean startup)
+    {
+        this.startup = startup;
+    }
+    
     /**
      * Clear caches.
      */
@@ -499,7 +507,17 @@ public class InjectionResolver
                 resolvedComponents = byParameterizedType;
             }
         }
-        resolvedBeansByType.put(cacheKey, resolvedComponents);
+
+        if (startup && (resolvedComponents == null || resolvedComponents.isEmpty()))
+        {
+            // skip cache on startup when resolvedComponents are null or empty
+            // see https://issues.apache.org/jira/browse/OWB-1095
+        }
+        else
+        {
+            resolvedBeansByType.put(cacheKey, resolvedComponents);
+        }
+
         if (logger.isLoggable(Level.FINE))
         {
             logger.log(Level.FINE, "DEBUG_ADD_BYTYPE_CACHE_BEANS", cacheKey);



Mime
View raw message