Package org.eclipse.sisu.space
Class BundleClassSpace
- java.lang.Object
-
- org.eclipse.sisu.space.BundleClassSpace
-
- All Implemented Interfaces:
ClassSpace
public final class BundleClassSpace extends java.lang.Object implements ClassSpace
ClassSpace
backed by a strongly-referencedBundle
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
BundleClassSpace.ChainedEnumeration<T>
Chains a series ofEnumeration
s together to look like a singleEnumeration
.
-
Field Summary
Fields Modifier and Type Field Description private org.osgi.framework.Bundle
bundle
private java.net.URL[]
bundleClassPath
private static java.util.Enumeration<java.net.URL>
NO_ENTRIES
private static java.net.URL[]
NO_URLS
-
Constructor Summary
Constructors Constructor Description BundleClassSpace(org.osgi.framework.Bundle bundle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeferredClass<?>
deferLoadClass(java.lang.String name)
Defers loading of the named class from the surrounding class space.boolean
equals(java.lang.Object rhs)
java.util.Enumeration<java.net.URL>
findEntries(java.lang.String path, java.lang.String glob, boolean recurse)
Queries local class space content for entries matching the given pattern.org.osgi.framework.Bundle
getBundle()
private java.net.URL[]
getBundleClassPath()
Returns the expanded Bundle-ClassPath; we need this to iterate over embedded JARs.java.net.URL
getResource(java.lang.String name)
Queries the surrounding class space for the resource with the given name.java.util.Enumeration<java.net.URL>
getResources(java.lang.String name)
Queries the surrounding class space for all resources with the given name.int
hashCode()
java.lang.Class<?>
loadClass(java.lang.String name)
Loads the named class from the surrounding class space.java.lang.String
toString()
-
-
-
Method Detail
-
loadClass
public java.lang.Class<?> loadClass(java.lang.String name)
Description copied from interface:ClassSpace
Loads the named class from the surrounding class space.- Specified by:
loadClass
in interfaceClassSpace
- Parameters:
name
- The class name- Returns:
- Class instance
- See Also:
ClassLoader.loadClass(String)
-
deferLoadClass
public DeferredClass<?> deferLoadClass(java.lang.String name)
Description copied from interface:ClassSpace
Defers loading of the named class from the surrounding class space.- Specified by:
deferLoadClass
in interfaceClassSpace
- Parameters:
name
- The class name- Returns:
- Deferred class
- See Also:
ClassLoader.loadClass(String)
-
getResource
public java.net.URL getResource(java.lang.String name)
Description copied from interface:ClassSpace
Queries the surrounding class space for the resource with the given name.- Specified by:
getResource
in interfaceClassSpace
- Parameters:
name
- The resource name- Returns:
- URL pointing to the resource;
null
if it wasn't found - See Also:
ClassLoader.getResource(String)
-
getResources
public java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
Description copied from interface:ClassSpace
Queries the surrounding class space for all resources with the given name.- Specified by:
getResources
in interfaceClassSpace
- Parameters:
name
- The resource name- Returns:
- Sequence of URLs, one for each matching resource
- See Also:
ClassLoader.getResources(String)
-
findEntries
public java.util.Enumeration<java.net.URL> findEntries(java.lang.String path, java.lang.String glob, boolean recurse)
Description copied from interface:ClassSpace
Queries local class space content for entries matching the given pattern.- Specified by:
findEntries
in interfaceClassSpace
- Parameters:
path
- The initial search directory; for example"META-INF"
glob
- The filename glob pattern; for example"*.xml"
recurse
- Iftrue
recurse into sub-directories; otherwise only search initial directory- Returns:
- Sequence of URLs, one for each matching entry
- See Also:
Bundle.findEntries(String, String, boolean)
-
getBundle
public org.osgi.framework.Bundle getBundle()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object rhs)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getBundleClassPath
private java.net.URL[] getBundleClassPath()
Returns the expanded Bundle-ClassPath; we need this to iterate over embedded JARs.
-
-