Return-Path: X-Original-To: apmail-geronimo-xbean-scm-archive@minotaur.apache.org Delivered-To: apmail-geronimo-xbean-scm-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B1F3B826A for ; Tue, 30 Aug 2011 05:54:32 +0000 (UTC) Received: (qmail 9282 invoked by uid 500); 30 Aug 2011 05:54:29 -0000 Delivered-To: apmail-geronimo-xbean-scm-archive@geronimo.apache.org Received: (qmail 9150 invoked by uid 500); 30 Aug 2011 05:54:22 -0000 Mailing-List: contact xbean-scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: xbean-scm@geronimo.apache.org Delivered-To: mailing list xbean-scm@geronimo.apache.org Received: (qmail 9127 invoked by uid 99); 30 Aug 2011 05:54:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2011 05:54:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2011 05:54:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A1E9223889E2; Tue, 30 Aug 2011 05:53:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1163092 - in /geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util: BundleClassLoader.java BundleResourceClassLoader.java equinox/EquinoxBundleClassLoader.java Date: Tue, 30 Aug 2011 05:53:48 -0000 To: xbean-scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110830055348.A1E9223889E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: xuhaihong Date: Tue Aug 30 05:53:48 2011 New Revision: 1163092 URL: http://svn.apache.org/viewvc?rev=1163092&view=rev Log: XBEAN-183 Disable wired bundles search by default Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassLoader.java geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleResourceClassLoader.java geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/equinox/EquinoxBundleClassLoader.java Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassLoader.java URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassLoader.java?rev=1163092&r1=1163091&r2=1163092&view=diff ============================================================================== --- geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassLoader.java (original) +++ geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassLoader.java Tue Aug 30 05:53:48 2011 @@ -27,20 +27,20 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleReference; /** - * ClassLoader for a {@link Bundle}. + * ClassLoader for a {@link Bundle}. *
- * In OSGi, resource lookup on resources in the META-INF directory using {@link Bundle#getResource(String)} or - * {@link Bundle#getResources(String)} does not return the resources found in the wired bundles of the bundle - * (wired via Import-Package or DynamicImport-Package). This class loader implementation provides + * In OSGi, resource lookup on resources in the META-INF directory using {@link Bundle#getResource(String)} or + * {@link Bundle#getResources(String)} does not return the resources found in the wired bundles of the bundle + * (wired via Import-Package or DynamicImport-Package). This class loader implementation provides * {@link #getResource(String) and {@link #getResources(String)} methods that do delegate such resource lookups to - * the wired bundles. + * the wired bundles. *
- * The URLs returned by {@link Bundle#getResource(String)} or {@link Bundle#getResources(String)} methods are + * The URLs returned by {@link Bundle#getResource(String)} or {@link Bundle#getResources(String)} methods are * OSGi framework specific "bundle" URLs. This sometimes can cause problems with 3rd party libraries * which do not understand how to interpret the "bundle" URLs. This ClassLoader implementation, if enabled, * can return jar URLs for resources found in embedded jars in the bundle. If a resource is found within a * directory in the bundle the URL returned for that resource is unconverted. - * + * * @version $Rev$ $Date$ */ public class BundleClassLoader extends ClassLoader implements DelegatingBundleReference { @@ -49,17 +49,17 @@ public class BundleClassLoader extends C protected final BundleResourceHelper resourceHelper; public BundleClassLoader(Bundle bundle) { - this(bundle, - BundleResourceHelper.getSearchWiredBundles(true), + this(bundle, + BundleResourceHelper.getSearchWiredBundles(false), BundleResourceHelper.getConvertResourceUrls(false)); } - + public BundleClassLoader(Bundle bundle, boolean searchWiredBundles) { - this(bundle, - searchWiredBundles, + this(bundle, + searchWiredBundles, BundleResourceHelper.getConvertResourceUrls(false)); } - + public BundleClassLoader(Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls) { this.bundle = bundle; this.resourceHelper = new BundleResourceHelper(bundle, searchWiredBundles, convertResourceUrls); @@ -69,7 +69,7 @@ public class BundleClassLoader extends C public String toString() { return "[BundleClassLoader] " + bundle; } - + @Override protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class clazz = bundle.loadClass(name); @@ -78,48 +78,48 @@ public class BundleClassLoader extends C } return clazz; } - + @Override public URL getResource(String name) { return resourceHelper.getResource(name); } - + @Override public Enumeration getResources(String name) throws IOException { return resourceHelper.getResources(name); } - + @Override public Enumeration findResources (String name) throws IOException { return this.getResources(name); } - + public void setSearchWiredBundles(boolean search) { resourceHelper.setSearchWiredBundles(search); } - + public boolean getSearchWiredBundles() { return resourceHelper.getSearchWiredBundles(); } - + public void setConvertResourceUrls(boolean convert) { resourceHelper.setConvertResourceUrls(convert); } - + public boolean getConvertResourceUrls() { return resourceHelper.getConvertResourceUrls(); } - + /** * Return the bundle associated with this classloader. - * - * In most cases the bundle associated with the classloader is a regular framework bundle. + * + * In most cases the bundle associated with the classloader is a regular framework bundle. * However, in some cases the bundle associated with the classloader is a {@link DelegatingBundle}. * In such cases, the unwrap parameter controls whether this function returns the * {@link DelegatingBundle} instance or the main application bundle backing with the {@link DelegatingBundle}. * - * @param unwrap If true and if the bundle associated with this classloader is a {@link DelegatingBundle}, - * this function will return the main application bundle backing with the {@link DelegatingBundle}. + * @param unwrap If true and if the bundle associated with this classloader is a {@link DelegatingBundle}, + * this function will return the main application bundle backing with the {@link DelegatingBundle}. * Otherwise, the bundle associated with this classloader is returned as is. * @return The bundle associated with this classloader. */ @@ -129,14 +129,14 @@ public class BundleClassLoader extends C } return bundle; } - + /** * Return the bundle associated with this classloader. - * - * This method calls {@link #getBundle(boolean) getBundle(true)} and therefore always returns a regular - * framework bundle. + * + * This method calls {@link #getBundle(boolean) getBundle(true)} and therefore always returns a regular + * framework bundle. *

- * Note: Some libraries use {@link BundleReference#getBundle()} to obtain a bundle for the given + * Note: Some libraries use {@link BundleReference#getBundle()} to obtain a bundle for the given * classloader and expect the returned bundle instance to be work with any OSGi API. Some of these API might * not work if {@link DelegatingBundle} is returned. That is why this function will always return * a regular framework bundle. See {@link #getBundle(boolean)} for more information. Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleResourceClassLoader.java URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleResourceClassLoader.java?rev=1163092&r1=1163091&r2=1163092&view=diff ============================================================================== --- geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleResourceClassLoader.java (original) +++ geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleResourceClassLoader.java Tue Aug 30 05:53:48 2011 @@ -22,18 +22,18 @@ package org.apache.xbean.osgi.bundle.uti import org.osgi.framework.Bundle; /** - * ClassLoader for a {@link Bundle}. + * ClassLoader for a {@link Bundle}. *
* This ClassLoader implementation extends the {@link BundleClassLoader} and returns resources embedded - * in jar files in a bundle with jar URLs. - * + * in jar files in a bundle with jar URLs. + * * @version $Rev$ $Date$ */ public class BundleResourceClassLoader extends BundleClassLoader { public BundleResourceClassLoader(Bundle bundle) { - super(bundle, - BundleResourceHelper.getSearchWiredBundles(true), + super(bundle, + BundleResourceHelper.getSearchWiredBundles(false), BundleResourceHelper.getConvertResourceUrls(true)); } @@ -41,5 +41,5 @@ public class BundleResourceClassLoader e public String toString() { return "[BundleResourceClassLoader] " + bundle; } - + } Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/equinox/EquinoxBundleClassLoader.java URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/equinox/EquinoxBundleClassLoader.java?rev=1163092&r1=1163091&r2=1163092&view=diff ============================================================================== --- geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/equinox/EquinoxBundleClassLoader.java (original) +++ geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/equinox/EquinoxBundleClassLoader.java Tue Aug 30 05:53:48 2011 @@ -31,36 +31,36 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleReference; /** - * ClassLoader for a {@link Bundle}. + * ClassLoader for a {@link Bundle}. *
* This ClassLoader implementation extends the {@link URLClassLoader} and converts resource "bundle" - * URLs (found in directories or embedded jar files) into regular jar URLs. + * URLs (found in directories or embedded jar files) into regular jar URLs. * This ClassLoader implementation will only work on Equinox framework. - * + * * @version $Rev$ $Date$ */ public class EquinoxBundleClassLoader extends URLClassLoader implements DelegatingBundleReference { private final Bundle bundle; private final BundleResourceHelper resourceHelper; - - public EquinoxBundleClassLoader(Bundle bundle) { - this(bundle, - BundleResourceHelper.getSearchWiredBundles(true), + + public EquinoxBundleClassLoader(Bundle bundle) { + this(bundle, + BundleResourceHelper.getSearchWiredBundles(false), BundleResourceHelper.getConvertResourceUrls(true)); } - + public EquinoxBundleClassLoader(Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls) { super(new URL[] {}); this.bundle = bundle; this.resourceHelper = new EquinoxBundleResourceHelper(bundle, searchWiredBundles, convertResourceUrls); } - + @Override public String toString() { return "[EquinoxBundleClassLoader] " + bundle; } - + @Override protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class clazz = bundle.loadClass(name); @@ -69,43 +69,43 @@ public class EquinoxBundleClassLoader ex } return clazz; } - + @Override public URL getResource(String name) { return resourceHelper.getResource(name); } - + @Override public Enumeration findResources(String name) throws IOException { return resourceHelper.getResources(name); } - + public void setSearchWiredBundles(boolean search) { resourceHelper.setSearchWiredBundles(search); } - + public boolean getSearchWiredBundles() { return resourceHelper.getSearchWiredBundles(); } - + public void setConvertResourceUrls(boolean convert) { resourceHelper.setConvertResourceUrls(convert); } - + public boolean getConvertResourceUrls() { return resourceHelper.getConvertResourceUrls(); } - + /** * Return the bundle associated with this classloader. - * - * In most cases the bundle associated with the classloader is a regular framework bundle. + * + * In most cases the bundle associated with the classloader is a regular framework bundle. * However, in some cases the bundle associated with the classloader is a {@link DelegatingBundle}. * In such cases, the unwrap parameter controls whether this function returns the * {@link DelegatingBundle} instance or the main application bundle backing with the {@link DelegatingBundle}. * - * @param unwrap If true and if the bundle associated with this classloader is a {@link DelegatingBundle}, - * this function will return the main application bundle backing with the {@link DelegatingBundle}. + * @param unwrap If true and if the bundle associated with this classloader is a {@link DelegatingBundle}, + * this function will return the main application bundle backing with the {@link DelegatingBundle}. * Otherwise, the bundle associated with this classloader is returned as is. * @return The bundle associated with this classloader. */ @@ -115,14 +115,14 @@ public class EquinoxBundleClassLoader ex } return bundle; } - + /** * Return the bundle associated with this classloader. - * - * This method calls {@link #getBundle(boolean) getBundle(true)} and therefore always returns a regular - * framework bundle. + * + * This method calls {@link #getBundle(boolean) getBundle(true)} and therefore always returns a regular + * framework bundle. *

- * Note: Some libraries use {@link BundleReference#getBundle()} to obtain a bundle for the given + * Note: Some libraries use {@link BundleReference#getBundle()} to obtain a bundle for the given * classloader and expect the returned bundle instance to be work with any OSGi API. Some of these API might * not work if {@link DelegatingBundle} is returned. That is why this function will always return * a regular framework bundle. See {@link #getBundle(boolean)} for more information. @@ -132,7 +132,7 @@ public class EquinoxBundleClassLoader ex public Bundle getBundle() { return getBundle(true); } - + @Override public int hashCode() { return bundle.hashCode(); @@ -149,5 +149,5 @@ public class EquinoxBundleClassLoader ex EquinoxBundleClassLoader otherBundleClassLoader = (EquinoxBundleClassLoader) other; return this.bundle == otherBundleClassLoader.bundle; } - + }