cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/4] git commit: Optimization to only load the first extension found when only one is asked for.
Date Thu, 12 Jun 2014 17:18:36 GMT
Repository: cxf
Updated Branches:
  refs/heads/master bbee298c2 -> f912f16cf


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/63e985d0
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/63e985d0
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/63e985d0

Branch: refs/heads/master
Commit: 63e985d05127a64dbfa6acfbb5c0f3ffb916fad5
Parents: bbee298
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu Jun 12 12:37:26 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Jun 12 13:17:17 2014 -0400

----------------------------------------------------------------------
 .../cxf/bus/extension/ExtensionManagerBus.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/63e985d0/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
index 9e2f7ad..bb5f1b9 100644
--- a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
+++ b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
@@ -202,14 +202,19 @@ public class ExtensionManagerBus extends AbstractBasicInterceptorProvider
implem
                 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/63e985d0/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
index 53d0622..71ae65d 100644
--- a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
+++ b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
@@ -176,7 +176,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 {
@@ -315,17 +317,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