Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9453610EE9 for ; Thu, 4 Dec 2014 11:29:07 +0000 (UTC) Received: (qmail 8079 invoked by uid 500); 4 Dec 2014 11:29:07 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 8017 invoked by uid 500); 4 Dec 2014 11:29:07 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 8002 invoked by uid 99); 4 Dec 2014 11:29:07 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Dec 2014 11:29:07 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 170EDA1B6CC; Thu, 4 Dec 2014 11:29:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: [CXF-6131] Minor updates Date: Thu, 4 Dec 2014 11:29:06 +0000 (UTC) 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 Authored: Thu Dec 4 11:28:48 2014 +0000 Committer: Sergey Beryozkin 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 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();