geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1163514 - in /geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util: BundleClassLoader.java BundleResourceClassLoader.java equinox/EquinoxBundleClassLoader.java
Date Wed, 31 Aug 2011 07:37:38 GMT
Author: xuhaihong
Date: Wed Aug 31 07:37:38 2011
New Revision: 1163514

URL: http://svn.apache.org/viewvc?rev=1163514&view=rev
Log:
Revert 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=1163514&r1=1163513&r2=1163514&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
Wed Aug 31 07:37:38 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}. 
  * <br/>
- * In OSGi, resource lookup on resources in the <i>META-INF</i> 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 <i>Import-Package</i> or <i>DynamicImport-Package</i>).
This class loader implementation provides
+ * In OSGi, resource lookup on resources in the <i>META-INF</i> 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 <i>Import-Package</i> or <i>DynamicImport-Package</i>).
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. 
  * <br/>
- * 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 &quot;bundle&quot; URLs. This sometimes can cause problems
with 3rd party libraries
  * which do not understand how to interpret the &quot;bundle&quot; URLs. This ClassLoader
implementation, if enabled,
  * can return <tt>jar</tt> 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(false),
+        this(bundle, 
+             BundleResourceHelper.getSearchWiredBundles(true), 
              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<URL> getResources(String name) throws IOException {
         return resourceHelper.getResources(name);
     }
-
+    
     @Override
     public Enumeration<URL> 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 <tt>unwrap</tt> 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.  
      * <br><br>
-     * 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=1163514&r1=1163513&r2=1163514&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
Wed Aug 31 07:37:38 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}. 
  * <br/>
  * This ClassLoader implementation extends the {@link BundleClassLoader} and returns resources
embedded
- * in jar files in a bundle with <tt>jar</tt> URLs.
- *
+ * in jar files in a bundle with <tt>jar</tt> URLs. 
+ * 
  * @version $Rev$ $Date$
  */
 public class BundleResourceClassLoader extends BundleClassLoader {
 
     public BundleResourceClassLoader(Bundle bundle) {
-        super(bundle,
-              BundleResourceHelper.getSearchWiredBundles(false),
+        super(bundle, 
+              BundleResourceHelper.getSearchWiredBundles(true), 
               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=1163514&r1=1163513&r2=1163514&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
Wed Aug 31 07:37:38 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}. 
  * <br/>
  * This ClassLoader implementation extends the {@link URLClassLoader} and converts resource
&quot;bundle&quot;
- * URLs (found in directories or embedded jar files) into regular <tt>jar</tt>
URLs.
+ * URLs (found in directories or embedded jar files) into regular <tt>jar</tt>
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(false),
+    
+    public EquinoxBundleClassLoader(Bundle bundle) {      
+        this(bundle, 
+             BundleResourceHelper.getSearchWiredBundles(true), 
              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<URL> 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 <tt>unwrap</tt> 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.  
      * <br><br>
-     * 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;
     }
-
+    
 }



Mime
View raw message