cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1421941 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
Date Fri, 14 Dec 2012 15:40:32 GMT
Author: dkulp
Date: Fri Dec 14 15:40:31 2012
New Revision: 1421941

URL: http://svn.apache.org/viewvc?rev=1421941&view=rev
Log:
[CXF-4703] Cache the unfound extensions to boost performance

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java?rev=1421941&r1=1421940&r2=1421941&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java Fri Dec 14 15:40:31
2012
@@ -22,8 +22,10 @@ package org.apache.cxf.bus;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -54,6 +56,7 @@ public class CXFBusImpl extends Abstract
     }
     
     protected final Map<Class<?>, Object> extensions;
+    protected final Set<Class<?>> missingExtensions;
     protected String id;
     private BusState state;      
     private final Collection<Feature> features = new CopyOnWriteArrayList<Feature>();
@@ -70,6 +73,8 @@ public class CXFBusImpl extends Abstract
             extensions = new ConcurrentHashMap<Class<?>, Object>(extensions);
         }
         this.extensions = extensions;
+        this.missingExtensions = new CopyOnWriteArraySet<Class<?>>();
+        
         
         state = BusState.INITIAL;
         
@@ -89,7 +94,7 @@ public class CXFBusImpl extends Abstract
 
     public final <T> T getExtension(Class<T> extensionType) {
         Object obj = extensions.get(extensionType);
-        if (obj == null) {
+        if (obj == null && !missingExtensions.contains(extensionType)) {
             ConfiguredBeanLocator loc = (ConfiguredBeanLocator)extensions.get(ConfiguredBeanLocator.class);
             if (loc == null) {
                 loc = createConfiguredBeanLocator();
@@ -107,6 +112,8 @@ public class CXFBusImpl extends Abstract
         }
         if (null != obj) {
             return extensionType.cast(obj);
+        } else {
+            missingExtensions.add(extensionType);
         }
         return null;
     }
@@ -159,8 +166,9 @@ public class CXFBusImpl extends Abstract
 
     public <T> void setExtension(T extension, Class<T> extensionType) {
         extensions.put(extensionType, extension);
+        missingExtensions.remove(extensionType);
     }
-     
+
     public String getId() {        
         return null == id ? DEFAULT_BUS_ID + Integer.toString(Math.abs(this.hashCode()))
: id;
     }



Mime
View raw message