cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6191] Optionally avoiding depending on Spring in ClassHelper and ClasspathScanner
Date Wed, 14 Jan 2015 17:00:52 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 318501bf3 -> 2d637291f


[CXF-6191] Optionally avoiding depending on Spring in ClassHelper and ClasspathScanner


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

Branch: refs/heads/master
Commit: 2d637291fd751a8d728326fd4ef5abcc133adef8
Parents: 318501b
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jan 14 17:00:25 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jan 14 17:00:25 2015 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/common/util/ClassHelper.java | 24 ++++++++++++++------
 .../cxf/common/util/ClasspathScanner.java       | 24 ++++++++++++++------
 2 files changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/2d637291/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
index 98c249b..db2dbdb 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
@@ -28,19 +28,29 @@ import org.apache.cxf.BusFactory;
 public class ClassHelper {
     static final ClassHelper HELPER;
     static {
-        ClassHelper theHelper = null;
-        try {
-            theHelper = new SpringAopClassHelper();
-        } catch (Throwable ex) {
-            theHelper = new ClassHelper();
-        }
-        HELPER = theHelper;
+        HELPER = getClassHelper();
     }
     
     
     protected ClassHelper() {
     }
     
+    private static ClassHelper getClassHelper() { 
+        boolean useSpring = true;
+        String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.useSpringClassHelpers");
+        if (!StringUtils.isEmpty(s)) {
+            useSpring = "1".equals(s) || Boolean.parseBoolean(s);
+        }
+        if (useSpring) {
+            try {
+                return new SpringAopClassHelper();
+            } catch (Throwable ex) {
+                // ignore
+            }
+        }
+        return new ClassHelper();
+    }
+    
     protected Class<?> getRealClassInternal(Object o) {
         return o.getClass();
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/2d637291/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
index 6507aaa..cc43731 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
@@ -37,13 +37,7 @@ public class ClasspathScanner {
     
     static final ClasspathScanner HELPER;
     static {
-        ClasspathScanner theHelper = null;
-        try {
-            theHelper = new SpringClasspathScanner();
-        } catch (Throwable ex) {
-            theHelper = new ClasspathScanner();
-        }
-        HELPER = theHelper;
+        HELPER = getClasspathScanner();
     }
     
     // Default packages list to ignore during classpath scanning 
@@ -53,6 +47,22 @@ public class ClasspathScanner {
     protected ClasspathScanner() {
     }    
 
+    private static ClasspathScanner getClasspathScanner() { 
+        boolean useSpring = true;
+        String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.useSpringClassHelpers");
+        if (!StringUtils.isEmpty(s)) {
+            useSpring = "1".equals(s) || Boolean.parseBoolean(s);
+        }
+        if (useSpring) {
+            try {
+                return new SpringClasspathScanner();
+            } catch (Throwable ex) {
+                // ignore
+            }
+        }
+        return new ClasspathScanner();
+    }
+    
     /**
      * Scans list of base packages for all classes marked with specific annotations. 
      * @param basePackage base package 


Mime
View raw message