DelegatingBundleReference
, org.osgi.framework.BundleReference
BundleResourceClassLoader
public class BundleClassLoader extends java.lang.ClassLoader implements DelegatingBundleReference
Bundle
.
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
and {@link #getResources(String)} methods that do delegate such 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. 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.
Modifier and Type | Field | Description |
---|---|---|
protected org.osgi.framework.Bundle |
bundle |
|
protected BundleResourceHelper |
resourceHelper |
Constructor | Description |
---|---|
BundleClassLoader(org.osgi.framework.Bundle bundle) |
|
BundleClassLoader(org.osgi.framework.Bundle bundle,
boolean searchWiredBundles) |
|
BundleClassLoader(org.osgi.framework.Bundle bundle,
boolean searchWiredBundles,
boolean convertResourceUrls) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(java.lang.Object other) |
|
java.util.Enumeration<java.net.URL> |
findResources(java.lang.String name) |
|
org.osgi.framework.Bundle |
getBundle() |
Return the bundle associated with this classloader.
|
org.osgi.framework.Bundle |
getBundle(boolean unwrap) |
Return the bundle associated with this classloader.
|
boolean |
getConvertResourceUrls() |
|
java.net.URL |
getResource(java.lang.String name) |
|
java.util.Enumeration<java.net.URL> |
getResources(java.lang.String name) |
|
boolean |
getSearchWiredBundles() |
|
int |
hashCode() |
|
protected java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve) |
|
void |
setConvertResourceUrls(boolean convert) |
|
void |
setSearchWiredBundles(boolean search) |
|
java.lang.String |
toString() |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findClass, findLibrary, findLoadedClass, findResource, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResourceAsStream, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
protected final org.osgi.framework.Bundle bundle
protected final BundleResourceHelper resourceHelper
public BundleClassLoader(org.osgi.framework.Bundle bundle)
public BundleClassLoader(org.osgi.framework.Bundle bundle, boolean searchWiredBundles)
public BundleClassLoader(org.osgi.framework.Bundle bundle, boolean searchWiredBundles, boolean convertResourceUrls)
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.Class<?> loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
public java.net.URL getResource(java.lang.String name)
getResource
in class java.lang.ClassLoader
public java.util.Enumeration<java.net.URL> getResources(java.lang.String name) throws java.io.IOException
getResources
in class java.lang.ClassLoader
java.io.IOException
public java.util.Enumeration<java.net.URL> findResources(java.lang.String name) throws java.io.IOException
findResources
in class java.lang.ClassLoader
java.io.IOException
public void setSearchWiredBundles(boolean search)
public boolean getSearchWiredBundles()
public void setConvertResourceUrls(boolean convert)
public boolean getConvertResourceUrls()
public org.osgi.framework.Bundle getBundle(boolean unwrap)
DelegatingBundle
.
In such cases, the unwrap parameter controls whether this function returns the
DelegatingBundle
instance or the main application bundle backing with the DelegatingBundle
.getBundle
in interface DelegatingBundleReference
unwrap
- If true and if the bundle associated with this classloader is a DelegatingBundle
,
this function will return the main application bundle backing with the DelegatingBundle
.
Otherwise, the bundle associated with this classloader is returned as is.public org.osgi.framework.Bundle getBundle()
getBundle(true)
and therefore always returns a regular
framework bundle.
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 DelegatingBundle
is returned. That is why this function will always return
a regular framework bundle. See getBundle(boolean)
for more information.getBundle
in interface org.osgi.framework.BundleReference
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
Copyright © 2005–2018. All rights reserved.