public class UberJarRealmClassLoader
extends java.net.URLClassLoader
ClassRealm
s.
Loads classes from an "uberjar".Modifier and Type | Field and Description |
---|---|
protected DefaultClassRealm |
realm
The realm.
|
Constructor and Description |
---|
UberJarRealmClassLoader(DefaultClassRealm realm) |
Modifier and Type | Method and Description |
---|---|
void |
addConstituent(java.net.URL constituent)
Add a constituent to this realm for locating classes.
|
protected byte[] |
findClassInDirectoryUrl(java.net.URL url,
java.lang.String path) |
protected byte[] |
findClassInJarStream(java.net.URL inUrl,
java.lang.String path) |
java.net.URL |
findResource(java.lang.String name)
Find a resource within this ClassLoader only (don't delegate to the parent).
|
protected java.net.URL |
findResourceInDirectoryUrl(java.net.URL inUrl,
java.lang.String path) |
protected java.net.URL |
findResourceInJarStream(java.net.URL inUrl,
java.lang.String path) |
java.util.Enumeration |
findResources(java.lang.String name) |
java.util.Enumeration |
findResourcesDirect(java.lang.String name)
Find resources from this ClassLoader, and don't search the realm.
|
byte[] |
getBytesToEndOfStream(java.io.DataInputStream in)
Helper method for addConstituent that reads in a DataInputStream and returns it as a byte[]
It attempts to use in.available - the size of the file - else defaults to 2048
|
java.net.URL |
getResource(java.lang.String name) |
java.net.URL |
getResourceDirect(java.lang.String name)
Get a resource from this ClassLoader, and don't search the realm.
|
java.net.URL[] |
getURLs()
Retrieve the
URL s used by this ClassLoader . |
protected java.lang.Class |
loadClass(java.lang.String name,
boolean resolve)
Load a class.
|
java.lang.Class |
loadClassDirect(java.lang.String className)
Load a class directly from this classloader without
defering through any other
ClassRealm . |
addURL, close, definePackage, findClass, getPermissions, getResourceAsStream, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
protected DefaultClassRealm realm
public UberJarRealmClassLoader(DefaultClassRealm realm)
public void addConstituent(java.net.URL constituent)
constituent
- URL to contituent jar or directory.public java.lang.Class loadClassDirect(java.lang.String className) throws java.lang.ClassNotFoundException
ClassRealm
.className
- The name of the class to load.java.lang.ClassNotFoundException
- If the class could not be found.public java.net.URL findResource(java.lang.String name)
public java.util.Enumeration findResourcesDirect(java.lang.String name)
protected java.net.URL findResourceInJarStream(java.net.URL inUrl, java.lang.String path)
protected java.net.URL findResourceInDirectoryUrl(java.net.URL inUrl, java.lang.String path)
protected byte[] findClassInJarStream(java.net.URL inUrl, java.lang.String path)
protected byte[] findClassInDirectoryUrl(java.net.URL url, java.lang.String path)
public byte[] getBytesToEndOfStream(java.io.DataInputStream in) throws java.io.IOException
java.io.IOException
protected java.lang.Class loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
name
- The name of the class to load.resolve
- If true
then resolve the class.java.lang.ClassNotFoundException
- If the class cannot be found.public java.net.URL[] getURLs()
URL
s used by this ClassLoader
.getURLs
in class java.net.URLClassLoader
public java.net.URL getResource(java.lang.String name)
getResource
in class java.lang.ClassLoader
public java.net.URL getResourceDirect(java.lang.String name)
public java.util.Enumeration findResources(java.lang.String name) throws java.io.IOException
findResources
in class java.net.URLClassLoader
java.io.IOException