public class ClassLoaderFromStackOfBrooklynClassLoadingContext
extends java.lang.ClassLoader
ClassLoadingContext
instances can be pushed and popped,
with the most recently pushed one in effect at any given time.
This is useful when traversing a tree some of whose elements may bring custom search paths, and the worker wants to have a simple view of the loader to use at any point in time. For example XStream keeps a class-loader in effect but when deserializing things some of those things may define bundles to use.
Constructor and Description |
---|
ClassLoaderFromStackOfBrooklynClassLoadingContext(java.lang.ClassLoader classLoader) |
Modifier and Type | Method and Description |
---|---|
void |
popClassLoadingContext() |
void |
pushClassLoadingContext(BrooklynClassLoadingContext clcNew)
Must be accompanied by a corresponding
popClassLoadingContext() when finished. |
void |
setManagementContext(ManagementContext mgmt) |
clearAssertionStatus, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
public ClassLoaderFromStackOfBrooklynClassLoadingContext(java.lang.ClassLoader classLoader)
public void setManagementContext(ManagementContext mgmt)
public void pushClassLoadingContext(BrooklynClassLoadingContext clcNew)
popClassLoadingContext()
when finished.
This class enforces a requirement that the pop be done by the same thread that pushed. This is to help ensure a consumer does not accidentally have two threads pushing and popping for different purposes as that would completely break the stack. We were uncertain whether xstream might parallelise things so wanted this to throw if a cross-thread pop happened; there is no deeper reason. If there is a compelling use case for a single logical push-pop chain to be done by different threads we could drop this requirement.
public void popClassLoadingContext()