Class BundleResourceHelper

java.lang.Object
org.apache.xbean.osgi.bundle.util.BundleResourceHelper
Direct Known Subclasses:
EquinoxBundleResourceHelper

public class BundleResourceHelper extends Object
Helper for finding resources in a Bundle.
In OSGi, resource lookup on resources in the META-INF directory using Bundle.getResource(String) or 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 invalid input: 'and {@link #getResources(String)} methods that do delegate <i>META-INF</i> resource lookups to the wired bundles. <br/> The URLs returned by {@link Bundle#getResource(String)} or {@link Bundle#getResources(String)} methods are OSGi framework specific &quot;bundle&quot; URLs. If enabled, this helper can convert the framework specific URLs into regular <tt>jar</tt> URLs. @version $Rev: 1331428 $ $Date: 2012-04-27 15:39:19 +0200 (Fri, 27 Apr 2012) $'
  • Field Details

    • SEARCH_WIRED_BUNDLES

      public static final String SEARCH_WIRED_BUNDLES
    • CONVERT_RESOURCE_URLS

      public static final String CONVERT_RESOURCE_URLS
    • bundle

      protected final org.osgi.framework.Bundle bundle
    • searchWiredBundles

      protected boolean searchWiredBundles
    • convertResourceUrls

      protected boolean convertResourceUrls
  • Constructor Details

    • BundleResourceHelper

      public BundleResourceHelper(org.osgi.framework.Bundle bundle)
    • BundleResourceHelper

      public BundleResourceHelper(org.osgi.framework.Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls)
  • Method Details

    • setSearchWiredBundles

      public void setSearchWiredBundles(boolean search)
    • getSearchWiredBundles

      public boolean getSearchWiredBundles()
    • setConvertResourceUrls

      public void setConvertResourceUrls(boolean convert)
    • getConvertResourceUrls

      public boolean getConvertResourceUrls()
    • getResource

      public URL getResource(String name)
    • getResources

      public Enumeration<URL> getResources(String name) throws IOException
      Throws:
      IOException
    • convert

      protected URL convert(URL url)
    • findResource

      protected URL findResource(String name)
    • findResources

      protected Enumeration<URL> findResources(String name) throws IOException
      Throws:
      IOException
    • convertedFindResource

      protected URL convertedFindResource(String name)
      Lookup resource and return converted URL (in a generic way).
      Parameters:
      name -
      Returns:
    • convertedFindResources

      protected Enumeration<URL> convertedFindResources(String name) throws IOException
      Lookup resources and return converted URLs (in a generic way).
      Parameters:
      name -
      Returns:
      Throws:
      IOException
    • getSearchWiredBundles

      public static boolean getSearchWiredBundles(boolean defaultValue)
    • getConvertResourceUrls

      public static boolean getConvertResourceUrls(boolean defaultValue)