org.apache.xbean.osgi.bundle.util
Class BundleResourceHelper

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

public class BundleResourceHelper
extends java.lang.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 #getResource(String) and {@link #getResources(String)} methods that do delegate META-INF resource lookups to the wired bundles.
The URLs returned by {@link Bundle#getResource(String)} or {@link Bundle#getResources(String)} methods are OSGi framework specific "bundle" URLs. If enabled, this helper can convert the framework specific URLs into regular jar URLs.

Version:
$Rev: 1165841 $ $Date: 2011-09-06 14:02:40 -0700 (Tue, 06 Sep 2011) $

Field Summary
protected  org.osgi.framework.Bundle bundle
           
static java.lang.String CONVERT_RESOURCE_URLS
           
protected  boolean convertResourceUrls
           
static java.lang.String SEARCH_WIRED_BUNDLES
           
protected  boolean searchWiredBundles
           
 
Constructor Summary
BundleResourceHelper(org.osgi.framework.Bundle bundle)
           
BundleResourceHelper(org.osgi.framework.Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls)
           
 
Method Summary
protected  java.net.URL convert(java.net.URL url)
           
protected  java.net.URL convertedFindResource(java.lang.String name)
          Lookup resource and return converted URL (in a generic way).
protected  java.util.Enumeration<java.net.URL> convertedFindResources(java.lang.String name)
          Lookup resources and return converted URLs (in a generic way).
protected  java.net.URL findResource(java.lang.String name)
           
protected  java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
           
 boolean getConvertResourceUrls()
           
static boolean getConvertResourceUrls(boolean defaultValue)
           
 java.net.URL getResource(java.lang.String name)
           
 java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
           
 boolean getSearchWiredBundles()
           
static boolean getSearchWiredBundles(boolean defaultValue)
           
 void setConvertResourceUrls(boolean convert)
           
 void setSearchWiredBundles(boolean search)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEARCH_WIRED_BUNDLES

public static final java.lang.String SEARCH_WIRED_BUNDLES

CONVERT_RESOURCE_URLS

public static final java.lang.String CONVERT_RESOURCE_URLS

bundle

protected final org.osgi.framework.Bundle bundle

searchWiredBundles

protected boolean searchWiredBundles

convertResourceUrls

protected boolean convertResourceUrls
Constructor Detail

BundleResourceHelper

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

BundleResourceHelper

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

setSearchWiredBundles

public void setSearchWiredBundles(boolean search)

getSearchWiredBundles

public boolean getSearchWiredBundles()

setConvertResourceUrls

public void setConvertResourceUrls(boolean convert)

getConvertResourceUrls

public boolean getConvertResourceUrls()

getResource

public java.net.URL getResource(java.lang.String name)

getResources

public java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
                                                 throws java.io.IOException
Throws:
java.io.IOException

convert

protected java.net.URL convert(java.net.URL url)

findResource

protected java.net.URL findResource(java.lang.String name)

findResources

protected java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
                                                     throws java.io.IOException
Throws:
java.io.IOException

convertedFindResource

protected java.net.URL convertedFindResource(java.lang.String name)
Lookup resource and return converted URL (in a generic way).

Parameters:
name -
Returns:

convertedFindResources

protected java.util.Enumeration<java.net.URL> convertedFindResources(java.lang.String name)
                                                              throws java.io.IOException
Lookup resources and return converted URLs (in a generic way).

Parameters:
name -
Returns:
Throws:
java.io.IOException

getSearchWiredBundles

public static boolean getSearchWiredBundles(boolean defaultValue)

getConvertResourceUrls

public static boolean getConvertResourceUrls(boolean defaultValue)


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.