public final class ContinuationClassLoader extends 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(URL[] urls,
ClassLoader parent) |
ContinuationClassLoader(URL[] urls,
ClassLoader parent,
ResourceTransformer transformer)
Creates a classloader by using the classpath given.
|
Modifier and Type | Method and Description |
---|---|
void |
addLoaderPackageRoot(String packageRoot)
Adds a package root to the list of packages which must be loaded using
this loader.
|
void |
addSystemPackageRoot(String packageRoot)
Adds a package root to the list of packages which must be loaded on the
parent loader.
|
protected Class<?> |
defineClassFromData(byte[] classData,
String classname)
Define a class given its bytes
|
Class<?> |
findClass(String name)
Searches for and load a class on the classpath of this class loader.
|
Class<?> |
forceLoadClass(String classname)
Loads a class through this class loader even if that class is available
on the parent classpath.
|
URL |
getResource(String name)
Finds the resource with the given name.
|
protected Class<?> |
loadClass(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, close, definePackage, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
defineClass, defineClass
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
public ContinuationClassLoader(URL[] urls, 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(URL[] urls, 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(String packageRoot)
packageRoot
- The root of all packages to be included.
Should not be null
.public void addLoaderPackageRoot(String packageRoot)
packageRoot
- The root of all packages to be included.
Should not be null
.public Class<?> forceLoadClass(String classname) throws ClassNotFoundException
classname
- The name of the class to be loaded.
Must not be null
.ClassNotFoundException
- if the requested class does not exist
on this loader's classpath.protected Class<?> loadClass(String classname, boolean resolve) throws ClassNotFoundException
loadClass
in class 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.ClassNotFoundException
- if the requested class does not exist
on the system classpath (when not in isolated mode) or this loader's
classpath.protected Class<?> defineClassFromData(byte[] classData, String classname)
classData
- the bytecode data for the classclassname
- the name of the classpublic Class<?> findClass(String name) throws ClassNotFoundException
findClass
in class URLClassLoader
name
- The name of the class to be loaded. Must not be
null
.ClassNotFoundException
- if the requested class does not exist
on this loader's classpath.public URL getResource(String name)
getResource
in class 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.Copyright © 2004-2012. All Rights Reserved.