public class EnvironmentClassLoader extends DynamicClassLoader
DynamicClassLoaders can be chained creating one virtual class loader. From the perspective of the JDK, it's all one classloader. Internally, the class loader chain searches like a classpath.
Modifier | Constructor and Description |
---|---|
protected |
EnvironmentClassLoader(java.lang.ClassLoader parent,
java.lang.String id)
Creates a new environment class loader.
|
protected |
EnvironmentClassLoader(java.lang.ClassLoader parent,
java.lang.String id,
boolean isRoot)
Creates a new environment class loader.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(EnvironmentListener listener)
Adds a listener to detect environment lifecycle changes.
|
void |
addLoaderListener(AddLoaderListener listener)
Adds a child listener.
|
void |
addScanListener(ScanListener listener)
Adds a scan listener.
|
void |
addScanPackage(java.net.URL url,
java.lang.String rootPackage)
Adds a virtual module root for scanning.
|
void |
addScanRoot()
Tells the classloader to scan the root classpath.
|
void |
addURL(java.net.URL url)
Adds the URL to the URLClassLoader.
|
void |
applyVisibleModules(EnvironmentApply apply)
Applies the action to all visible environment modules.
|
protected void |
buildImportClassPath(java.util.ArrayList<java.lang.String> cp) |
protected void |
configureEnhancerEvent()
Adds a listener to detect class loader changes.
|
protected void |
configurePostEnhancerEvent()
Adds a listener to detect class loader changes.
|
static EnvironmentClassLoader |
create()
Creates a new environment class loader.
|
static EnvironmentClassLoader |
create(java.lang.ClassLoader parent)
Creates a new environment class loader.
|
static EnvironmentClassLoader |
create(java.lang.ClassLoader parent,
java.lang.String id)
Creates a new environment class loader.
|
static EnvironmentClassLoader |
create(java.lang.String id)
Creates a new environment class loader.
|
ArtifactManager |
createArtifactManager()
Returns the artifact manager
|
void |
destroy()
Destroys the class loader.
|
protected java.lang.Class<?> |
findImportClass(java.lang.String name)
Returns any import class, e.g.
|
EnvironmentMXBean |
getAdmin()
Returns the admin
|
ArtifactManager |
getArtifactManager()
Returns the artifact manager
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the named attributes
|
java.lang.Throwable |
getConfigException()
Gets the config exception.
|
protected java.util.ArrayList<EnvironmentListener> |
getEnvironmentListeners()
Returns the listeners.
|
java.lang.String |
getHash()
Add the custom packages to the classloader hash.
|
protected java.net.URL |
getImportResource(java.lang.String name)
Get resource from an artifact
|
protected java.util.ArrayList<AddLoaderListener> |
getLoaderListeners()
Returns the listeners.
|
EnvironmentBean |
getOwner()
Returns the environment's owner.
|
java.net.URL |
getResource(java.lang.String name)
Overrides getResource to implement caching.
|
java.lang.String |
getResourceAlias(java.lang.String name) |
java.io.InputStream |
getResourceAsStream(java.lang.String name)
Overrides getResource to implement caching.
|
void |
init()
Initialize the environment.
|
protected void |
initEnvironment() |
boolean |
isActive()
Returns true if the environment is active
|
java.lang.Object |
putIfAbsent(java.lang.String name,
java.lang.Object obj)
Sets the named attributes
|
void |
putResourceAlias(java.lang.String name,
java.lang.String actualName) |
java.lang.Object |
removeAttribute(java.lang.String name)
Removes the named attributes
|
void |
removeListener(EnvironmentListener listener)
Adds a listener to detect environment lifecycle changes.
|
void |
scan() |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object obj)
Sets the named attributes
|
void |
setConfigException(java.lang.Throwable e)
Sets the config exception.
|
void |
setOwner(EnvironmentBean owner)
Sets the environment's owner.
|
void |
start()
Marks the environment of the class loader as started.
|
void |
stop()
Stops the environment, closing down any resources.
|
java.lang.String |
toString() |
void |
validate()
Called when the
|
addCodeBasePath, addDependency, addJar, addJarManifestClassPath, addListener, addLoader, addLoader, addManifestClassPath, addNative, addParentPriorityPackage, addParentPriorityPackages, addPathClass, addPermission, addPermission, addPermissions, addPriorityPackage, addRoot, addTransformer, addURL, addURL, appendToClassPathForInstrumentation, buildClassPath, buildResourcePathSpecificFirst, buildSourcePath, clearModified, containsURL, containsURL, definePackage, findClass, findClassImpl, findLibrary, findPath, findResources, getClassEntry, getClassPath, getDependencyCheckInterval, getGlobalDependencyCheckInterval, getHash, getHashCrc, getId, getInstrumentableClassLoader, getListeners, getLoaders, getLocalClassPath, getNewTempClassLoader, getPermissions, getPermissions, getResourcePathSpecificFirst, getResources, getSourcePath, getThrowawayClassLoader, getTransformerList, getURLs, isDestroyed, isDirectoryLoader, isDisableURLs, isJarCacheEnabled, isJarCacheEnabledDefault, isModified, isModified, isModified, isModifiedNow, isRoot, loadClass, loadClass, loadClass, loadClassEntry, loadClassImpl, logModified, make, removeListener, removeLoader, replace, resetDependencyCheckInterval, sendAddLoaderEvent, setDependencyCheckInterval, setDisableURLs, setEnableDependencyCheck, setGlobalDependencyCheckInterval, setId, setJarCacheEnabled, setOldLoader, setServletHack, toClassPath, updateScan
close, definePackage, findResource, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
protected EnvironmentClassLoader(java.lang.ClassLoader parent, java.lang.String id)
protected EnvironmentClassLoader(java.lang.ClassLoader parent, java.lang.String id, boolean isRoot)
public static EnvironmentClassLoader create()
public static EnvironmentClassLoader create(java.lang.String id)
public static EnvironmentClassLoader create(java.lang.ClassLoader parent)
public static EnvironmentClassLoader create(java.lang.ClassLoader parent, java.lang.String id)
public EnvironmentBean getOwner()
public void setOwner(EnvironmentBean owner)
public void setConfigException(java.lang.Throwable e)
public java.lang.Throwable getConfigException()
public boolean isActive()
public EnvironmentMXBean getAdmin()
public void init()
init
in class DynamicClassLoader
protected void initEnvironment()
public java.lang.Object getAttribute(java.lang.String name)
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object obj)
public java.lang.Object putIfAbsent(java.lang.String name, java.lang.Object obj)
public java.lang.Object removeAttribute(java.lang.String name)
public java.net.URL getResource(java.lang.String name)
getResource
in class DynamicClassLoader
name
- name of the resourcepublic java.io.InputStream getResourceAsStream(java.lang.String name)
getResourceAsStream
in class DynamicClassLoader
name
- the path to the resourcepublic void putResourceAlias(java.lang.String name, java.lang.String actualName)
public java.lang.String getResourceAlias(java.lang.String name)
getResourceAlias
in class DynamicClassLoader
public void addListener(EnvironmentListener listener)
public void removeListener(EnvironmentListener listener)
protected java.util.ArrayList<EnvironmentListener> getEnvironmentListeners()
public void addLoaderListener(AddLoaderListener listener)
protected java.util.ArrayList<AddLoaderListener> getLoaderListeners()
protected void configureEnhancerEvent()
configureEnhancerEvent
in class DynamicClassLoader
protected void configurePostEnhancerEvent()
configurePostEnhancerEvent
in class DynamicClassLoader
public void addURL(java.net.URL url)
addURL
in class DynamicClassLoader
public void addScanPackage(java.net.URL url, java.lang.String rootPackage)
rootPackage
- public java.lang.String getHash()
getHash
in class DynamicClassLoader
public void addScanRoot()
addScanRoot
in class DynamicClassLoader
public void addScanListener(ScanListener listener)
public ArtifactManager createArtifactManager()
public ArtifactManager getArtifactManager()
protected java.lang.Class<?> findImportClass(java.lang.String name)
findImportClass
in class DynamicClassLoader
protected java.net.URL getImportResource(java.lang.String name)
getImportResource
in class DynamicClassLoader
protected void buildImportClassPath(java.util.ArrayList<java.lang.String> cp)
buildImportClassPath
in class DynamicClassLoader
public void applyVisibleModules(EnvironmentApply apply)
public void validate()
validate
in class DynamicClassLoader
public void scan()
scan
in class DynamicClassLoader
public void start()
public void stop()
stop
in class DynamicClassLoader
public void destroy()
destroy
in class DynamicClassLoader
public java.lang.String toString()
toString
in class DynamicClassLoader