cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/5] git commit: Optimization to only load the first extension found when only one is asked for.
Date Fri, 13 Jun 2014 15:29:35 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 41e11d892 -> ec3deed2b


Optimization to only load the first extension found when only one is asked for.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/22e6b39d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/22e6b39d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/22e6b39d

Branch: refs/heads/2.7.x-fixes
Commit: 22e6b39db88ab99c175ba59bbcf623830614d1d1
Parents: 41e11d8
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu Jun 12 12:37:26 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Jun 13 11:04:20 2014 -0400

----------------------------------------------------------------------
 .../java/org/apache/cxf/bus/CXFBusImpl.java     | 17 +++++++----
 .../cxf/bus/extension/ExtensionManagerImpl.java | 30 +++++++++++++++-----
 2 files changed, 34 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/22e6b39d/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
----------------------------------------------------------------------
diff --git a/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java b/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
index 3f7583c..e578300 100644
--- a/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
+++ b/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
@@ -104,14 +104,19 @@ public class CXFBusImpl extends AbstractBasicInterceptorProvider implements
Bus
                 loc = createConfiguredBeanLocator();
             }
             if (loc != null) {
-                //force loading
-                Collection<?> objs = loc.getBeansOfType(extensionType);
-                if (objs != null) {
-                    for (Object o : objs) {
-                        extensions.put(extensionType, o);
+                obj = loc.getBeanOfType(extensionType.getName(), extensionType);
+                if (obj != null) {
+                    extensions.put(extensionType, obj);
+                } else {
+                    //force loading
+                    Collection<?> objs = loc.getBeansOfType(extensionType);
+                    if (objs != null) {
+                        for (Object o : objs) {
+                            extensions.put(extensionType, o);
+                        }
                     }
+                    obj = extensions.get(extensionType);
                 }
-                obj = extensions.get(extensionType);
             }
         }
         if (null != obj) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/22e6b39d/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
----------------------------------------------------------------------
diff --git a/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
b/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
index 33d8c47..4b014e1 100644
--- a/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
+++ b/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
@@ -188,7 +188,9 @@ public class ExtensionManagerImpl implements ExtensionManager, ConfiguredBeanLoc
                     if (loader != l) {
                         e.classloader = l;
                     }
-                    all.put(e.getName(), e);
+                    if (!all.containsKey(e.getName())) {
+                        all.put(e.getName(), e);
+                    }
                 }
             } finally {
                 try {
@@ -327,17 +329,31 @@ public class ExtensionManagerImpl implements ExtensionManager, ConfiguredBeanLoc
     }
     public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
         List<T> ret = new LinkedList<T>();
-        for (Extension ex : all.values()) {
-            synchronized (ex) {
-                Class<?> cls = ex.getClassObject(loader);
+        Extension ext = all.get(type.getName());
+        if (ext != null) {
+            synchronized (ext) {
+                Class<?> cls = ext.getClassObject(loader);
                 if (cls != null && type.isAssignableFrom(cls)) {
-                    if (ex.getLoadedObject() == null) {
-                        loadAndRegister(ex);
+                    if (ext.getLoadedObject() == null) {
+                        loadAndRegister(ext);
                     }
-                    ret.add(type.cast(ex.getLoadedObject()));
+                    ret.add(type.cast(ext.getLoadedObject()));
                 }                
             }
         }
+        for (Extension ex : all.values()) {
+            if (ex != ext) {
+                synchronized (ex) {
+                    Class<?> cls = ex.getClassObject(loader);
+                    if (cls != null && type.isAssignableFrom(cls)) {
+                        if (ex.getLoadedObject() == null) {
+                            loadAndRegister(ex);
+                        }
+                        ret.add(type.cast(ex.getLoadedObject()));
+                    }                
+                }
+            }
+        }
         return ret;
     }
     public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T>
listener) {


Mime
View raw message