openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1078624 - /openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
Date Sun, 06 Mar 2011 23:10:25 GMT
Author: struberg
Date: Sun Mar  6 23:10:24 2011
New Revision: 1078624

URL: http://svn.apache.org/viewvc?rev=1078624&view=rev
Log:
OWB-540 speed up EE injection with a cache

Modified:
    openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java

Modified: openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java?rev=1078624&r1=1078623&r2=1078624&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
(original)
+++ openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
Sun Mar  6 23:10:24 2011
@@ -26,6 +26,8 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.text.MessageFormat;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.annotation.Resource;
 import javax.enterprise.inject.Produces;
@@ -59,6 +61,11 @@ public class StandaloneResourceInjection
 
     private final WebBeansContext webBeansContext;
 
+    /**
+     * Cache the information if a certain class contains any EE resource at all
+     */
+    private final Map<Class<?>, Boolean> classContainsEEResources = new ConcurrentHashMap<Class<?>,
Boolean>();
+
     public StandaloneResourceInjectionService(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
@@ -104,6 +111,13 @@ public class StandaloneResourceInjection
     public void injectJavaEEResources(Object managedBeanInstance) throws Exception
     {
         Class currentClass = managedBeanInstance.getClass();
+        Boolean containsEeResource = classContainsEEResources.get(currentClass);
+        if (containsEeResource != null && containsEeResource.booleanValue() == false)
+        {
+            // nothing to do it seems.
+            return;
+        }
+
 
         while (currentClass != null && !Object.class.getName().equals(currentClass.getName()))
         {
@@ -126,6 +140,7 @@ public class StandaloneResourceInjection
                                 SecurityUtil.doPrivilegedSetAccessible(field, true);
                                 field.set(managedBeanInstance, getResourceReference(resourceRef));
 
+                                containsEeResource = Boolean.TRUE;
                             }
                             catch(Exception e)
                             {
@@ -144,6 +159,13 @@ public class StandaloneResourceInjection
 
             currentClass = currentClass.getSuperclass();
         }
+
+        if (containsEeResource == null)
+        {
+            containsEeResource = Boolean.FALSE;
+        }
+
+        classContainsEEResources.put(managedBeanInstance.getClass(), containsEeResource);
     }
 
     @Override



Mime
View raw message