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-6131] Minor updates
Date Thu, 04 Dec 2014 11:29:06 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5b4347ecd -> 30853113b


[CXF-6131] Minor updates


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

Branch: refs/heads/master
Commit: 30853113b4c4d47200bcf5305e5e88735f32cc8f
Parents: 5b4347e
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Dec 4 11:28:48 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Dec 4 11:28:48 2014 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/bus/osgi/CXFActivator.java   | 10 --------
 .../cxf/common/util/SpringClasspathScanner.java | 26 ++++++++++----------
 .../apache/cxf/common/util/SpringOsgiUtil.java  | 10 +++-----
 3 files changed, 16 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/30853113/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java b/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
index cb9cce1..030c8a0 100644
--- a/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
+++ b/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
@@ -46,11 +46,6 @@ import org.osgi.util.tracker.ServiceTracker;
  */
 public class CXFActivator implements BundleActivator {
     
-    /*
-     * a flag to tell if run the CXF in OSGi cont
-     */
-    private static boolean inOSGi;
-    
     private List<Extension> extensions;
     private ManagedWorkQueueList workQueues = new ManagedWorkQueueList();
     private ServiceTracker configAdminTracker;
@@ -61,7 +56,6 @@ public class CXFActivator implements BundleActivator {
 
     /** {@inheritDoc}*/
     public void start(BundleContext context) throws Exception {
-        inOSGi = true;
         cxfBundleListener = new CXFExtensionBundleListener(context.getBundle().getBundleId());
         context.addBundleListener(cxfBundleListener);
         cxfBundleListener.registerExistingBundles(context);
@@ -132,9 +126,5 @@ public class CXFActivator implements BundleActivator {
         configAdminTracker.close();
         ExtensionRegistry.removeExtensions(extensions);
     }
-    
-    public static boolean isInOSGi() {
-        return inOSGi;
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/30853113/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
index f36a645..12532b0 100644
--- a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
@@ -28,7 +28,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cxf.bus.osgi.CXFActivator;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@@ -41,22 +40,23 @@ import org.springframework.util.ClassUtils;
 
 class SpringClasspathScanner extends ClasspathScanner {
     
-    static final SpringOsgiUtil SPRING_OSGI_UTIL;
-    
+    private static final Boolean IN_OSGI;
     static {
-        SpringOsgiUtil springOsgiUtil = null;
-        try {
-            springOsgiUtil = new SpringOsgiUtil();
-        } catch (Throwable ex) {
-            springOsgiUtil = null;
-        }
-        SPRING_OSGI_UTIL = springOsgiUtil;
+        IN_OSGI = isSpringInOsgi();
     }
-    
     SpringClasspathScanner() throws Exception {
         Class.forName("org.springframework.core.io.support.PathMatchingResourcePatternResolver");
         Class.forName("org.springframework.core.type.classreading.CachingMetadataReaderFactory");
     }
+    private static boolean isSpringInOsgi() {
+        try {
+            Class.forName("org.springframework.osgi.io.OsgiBundleResourcePatternResolver");
+            Class.forName("org.springframework.osgi.util.BundleDelegatingClassLoader");
+            return true;
+        } catch (Throwable ex) {
+            return false;
+        }    
+    }
     
     protected Map< Class< ? extends Annotation >, Collection< Class< ? >
> > findClassesInternal(
         Collection< String > basePackages, 
@@ -169,8 +169,8 @@ class SpringClasspathScanner extends ClasspathScanner {
     }
     
     private ResourcePatternResolver getResolver(ClassLoader loader) {
-        if (CXFActivator.isInOSGi() && SPRING_OSGI_UTIL != null) {
-            return SPRING_OSGI_UTIL.getResolver(loader);
+        if (IN_OSGI) {
+            return SpringOsgiUtil.getResolver(loader);
         } else {
             return loader != null 
                 ? new PathMatchingResourcePatternResolver(loader) : new PathMatchingResourcePatternResolver();

http://git-wip-us.apache.org/repos/asf/cxf/blob/30853113/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java b/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java
index f7b6381..7312475 100644
--- a/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java
+++ b/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java
@@ -24,16 +24,12 @@ import org.springframework.core.io.support.ResourcePatternResolver;
 import org.springframework.osgi.io.OsgiBundleResourcePatternResolver;
 import org.springframework.osgi.util.BundleDelegatingClassLoader;
 
-public class SpringOsgiUtil {
+final class SpringOsgiUtil {
 
-    SpringOsgiUtil() throws Exception {
-        Class.forName("org.springframework.osgi.io.OsgiBundleResourcePatternResolver");
-        Class.forName("org.springframework.osgi.util.BundleDelegatingClassLoader");
+    private SpringOsgiUtil() {
     }
     
-    public ResourcePatternResolver getResolver(ClassLoader loader) {
-        //in OSGi should use spring-dm OsgiBundleResourcePatternResolver
-        // which can handle bundle url
+    public static ResourcePatternResolver getResolver(ClassLoader loader) {
         Bundle bundle = null;
         if (loader == null) {
             loader = Thread.currentThread().getContextClassLoader();


Mime
View raw message