public final class ExchangeClassLoader extends Object implements AutoCloseable
try (ExchangeClassLoader exchange = ExchangeClassLoader.forTinyPlugz()) {
// perform scoped actions here
}
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static ExchangeClassLoader |
forTinyPlugz()
If
TinyPlugz is deployed, the context ClassLoader is exchanged
for TinyPlugz's Classloader. |
void |
setFailOnChange(boolean failOnChange)
Sets whether
close() throws an exception if it detects that the
context Classloader has been exchanged by a 3rd party. |
static ExchangeClassLoader |
with(@NonNull ClassLoader classLoader)
Exchanges the context ClassLoader with the given one until
close() is called. |
public static ExchangeClassLoader with(@NonNull ClassLoader classLoader)
close() is called.classLoader - The Classloader to employ.ExchangeClassLoader object to use in a try-resources
block.public static ExchangeClassLoader forTinyPlugz()
TinyPlugz is deployed, the context ClassLoader is exchanged
for TinyPlugz's Classloader. Otherwise, it will not be changed.ExchangeClassLoader object to use in a try-resources
block.public void setFailOnChange(boolean failOnChange)
close() throws an exception if it detects that the
context Classloader has been exchanged by a 3rd party.failOnChange - Whether to fail on unexpected Classloader exchange.public final void close()
close in interface AutoCloseableCopyright © 2014–2015. All rights reserved.