Package org.eclipse.sisu.space
Class URLClassSpace
java.lang.Object
org.eclipse.sisu.space.URLClassSpace
- All Implemented Interfaces:
ClassSpace
- Direct Known Subclasses:
CloningClassSpace
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate URL[]private static final String[]private final ClassLoaderprivate static final Stringprivate static final Enumeration<URL> private static final URL[]private final Stringprivate static final Stringprivate static final ClassLoader -
Constructor Summary
ConstructorsConstructorDescriptionURLClassSpace(ClassLoader loader) Creates aClassSpacebacked by aClassLoaderand its default class path.URLClassSpace(ClassLoader loader, URL[] path) Creates aClassSpacebacked by aClassLoaderwith a restricted class path. -
Method Summary
Modifier and TypeMethodDescriptionfinal DeferredClass<?> deferLoadClass(String name) Defers loading of the named class from the surrounding class space.final booleanprivate static URL[]expandClassPath(URL[] classPath) Expands the givenURLclass path to include Class-Path entries from local manifests.final Enumeration<URL> findEntries(String path, String glob, boolean recurse) Queries local class space content for entries matching the given pattern.private URL[]Returns the associatedURLclass path; this can either be explicit or implicit.private static String[]getClassPathEntries(URL url) Looks for Class-Path entries in the given jar or directory; returns empty array if none are found.final URLgetResource(String name) Queries the surrounding class space for the resource with the given name.final Enumeration<URL> getResources(String name) Queries the surrounding class space for all resources with the given name.private static URL[]Returns the systemURLclass path.final URL[]getURLs()final inthashCode()final Class<?> Loads the named class from the surrounding class space.private static URLnormalizeEntry(URL url) Normalizes the given class path entry by removing any extraneous "jar:"..."!/" padding.final StringtoString()
-
Field Details
-
MANIFEST_ENTRY
- See Also:
-
NO_URLS
-
NO_ENTRIES
-
EMPTY_CLASSPATH
-
SYSTEM_LOADER
-
SYSTEM_CLASSPATH
-
loader
-
pathDetails
-
classPath
-
-
Constructor Details
-
URLClassSpace
Creates aClassSpacebacked by aClassLoaderand its default class path.For
URLClassLoaders this is their expanded Class-Path; otherwise it is empty.- Parameters:
loader- The class loader to use when getting/finding resources
-
URLClassSpace
Creates aClassSpacebacked by aClassLoaderwith a restricted class path.- Parameters:
loader- The class loader to use when getting resourcespath- The class path to use when finding resources- See Also:
-
-
Method Details
-
loadClass
Description copied from interface:ClassSpaceLoads the named class from the surrounding class space.- Specified by:
loadClassin interfaceClassSpace- Parameters:
name- The class name- Returns:
- Class instance
- See Also:
-
deferLoadClass
Description copied from interface:ClassSpaceDefers loading of the named class from the surrounding class space.- Specified by:
deferLoadClassin interfaceClassSpace- Parameters:
name- The class name- Returns:
- Deferred class
- See Also:
-
getResource
Description copied from interface:ClassSpaceQueries the surrounding class space for the resource with the given name.- Specified by:
getResourcein interfaceClassSpace- Parameters:
name- The resource name- Returns:
- URL pointing to the resource;
nullif it wasn't found - See Also:
-
getResources
Description copied from interface:ClassSpaceQueries the surrounding class space for all resources with the given name.- Specified by:
getResourcesin interfaceClassSpace- Parameters:
name- The resource name- Returns:
- Sequence of URLs, one for each matching resource
- See Also:
-
findEntries
Description copied from interface:ClassSpaceQueries local class space content for entries matching the given pattern.- Specified by:
findEntriesin interfaceClassSpace- Parameters:
path- The initial search directory; for example"META-INF"glob- The filename glob pattern; for example"*.xml"recurse- Iftruerecurse into sub-directories; otherwise only search initial directory- Returns:
- Sequence of URLs, one for each matching entry
- See Also:
-
getURLs
-
hashCode
public final int hashCode() -
equals
-
toString
-
getClassPath
Returns the associatedURLclass path; this can either be explicit or implicit. -
getSystemClassPath
Returns the systemURLclass path. -
expandClassPath
Expands the givenURLclass path to include Class-Path entries from local manifests.- Parameters:
classPath- The URL class path- Returns:
- Expanded URL class path
-
normalizeEntry
Normalizes the given class path entry by removing any extraneous "jar:"..."!/" padding.- Parameters:
path- The URL to normalize- Returns:
- Normalized class path entry
-
getClassPathEntries
Looks for Class-Path entries in the given jar or directory; returns empty array if none are found.- Parameters:
url- The jar or directory to inspect- Returns:
- Array of Class-Path entries
- Throws:
IOException
-