Class BundleResourceHelper
- java.lang.Object
-
- org.apache.xbean.osgi.bundle.util.BundleResourceHelper
-
- Direct Known Subclasses:
EquinoxBundleResourceHelper
public class BundleResourceHelper extends java.lang.Object
Helper for finding resources in aBundle
.
In OSGi, resource lookup on resources in the META-INF directory usingBundle.getResource(String)
orBundle.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 providesand {@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: 1331428 $ $Date: 2012-04-27 15:39:19 +0200 (Fri, 27 Apr 2012) $
-
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description BundleResourceHelper(org.osgi.framework.Bundle bundle)
BundleResourceHelper(org.osgi.framework.Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)
-
-
-
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
-
-
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)
-
-