org.apache.commons.javaflow
public final class ContinuationClassLoader extends java.net.URLClassLoader
URLClassLoader
with bytecode instrumentation for javaflow.
This class loader is useful where the application can set up multiple class loaders (such as in a container environment, ClassWorlds, or Forehead) and when you can isolate the continuation-enabled portion of your application into a separate jar file.
Constructor and Description |
---|
ContinuationClassLoader(java.net.URL[] urls,
java.lang.ClassLoader parent) |
ContinuationClassLoader(java.net.URL[] urls,
java.lang.ClassLoader parent,
ResourceTransformer transformer)
Creates a classloader by using the classpath given.
|
Modifier and Type | Method and Description |
---|---|
void |
addLoaderPackageRoot(java.lang.String packageRoot)
Adds a package root to the list of packages which must be loaded using
this loader.
|
void |
addSystemPackageRoot(java.lang.String packageRoot)
Adds a package root to the list of packages which must be loaded on the
parent loader.
|
protected java.lang.Class |
defineClassFromData(byte[] classData,
java.lang.String classname)
Define a class given its bytes
|
java.lang.Class |
findClass(java.lang.String name)
Searches for and load a class on the classpath of this class loader.
|
java.lang.Class |
forceLoadClass(java.lang.String classname)
Loads a class through this class loader even if that class is available
on the parent classpath.
|
java.net.URL |
getResource(java.lang.String name)
Finds the resource with the given name.
|
protected java.lang.Class |
loadClass(java.lang.String classname,
boolean resolve)
Loads a class with this class loader.
|
void |
setIsolated(boolean isolated)
Sets whether this classloader should run in isolated mode.
|
void |
setParentFirst(boolean parentFirst)
Control whether class lookup is delegated to the parent loader first
or after this loader.
|
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public ContinuationClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent, ResourceTransformer transformer)
urls
- The URLs from which to load classes and resourcesparent
- The parent classloader to which unsatisfied loading
attempts are delegated. May be null
,
in which case the system classloader
is used as the parent.transformer
- This transformer is used to perform the byte-code enhancement.
May not be null.public ContinuationClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent)
public void setParentFirst(boolean parentFirst)
parentFirst
- if true, delegate initial class search to the parent
classloader.public void setIsolated(boolean isolated)
isolated
- Whether or not this classloader should run in
isolated mode.public void addSystemPackageRoot(java.lang.String packageRoot)
packageRoot
- The root of all packages to be included.
Should not be null
.public void addLoaderPackageRoot(java.lang.String packageRoot)
packageRoot
- The root of all packages to be included.
Should not be null
.public java.lang.Class forceLoadClass(java.lang.String classname) throws java.lang.ClassNotFoundException
classname
- The name of the class to be loaded.
Must not be null
.java.lang.ClassNotFoundException
- if the requested class does not exist
on this loader's classpath.protected java.lang.Class loadClass(java.lang.String classname, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
classname
- The name of the class to be loaded.
Must not be null
.resolve
- true
if all classes upon which this class
depends are to be loaded.java.lang.ClassNotFoundException
- if the requested class does not exist
on the system classpath (when not in isolated mode) or this loader's
classpath.protected java.lang.Class defineClassFromData(byte[] classData, java.lang.String classname)
classData
- the bytecode data for the classclassname
- the name of the classpublic java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException
findClass
in class java.net.URLClassLoader
name
- The name of the class to be loaded. Must not be
null
.java.lang.ClassNotFoundException
- if the requested class does not exist
on this loader's classpath.public java.net.URL getResource(java.lang.String name)
getResource
in class java.lang.ClassLoader
name
- The name of the resource for which a stream is required.
Must not be null
.null
if the
resource could not be found or the caller doesn't have
adequate privileges to get the resource.