Package org.citrusframework.util
Class ClassLoaderHelper
java.lang.Object
org.citrusframework.util.ClassLoaderHelper
Class loader helper class that is aware of dynamically loaded Maven artifacts.
Helper is able to adapt class loaders with the additional dependencies in the form of artifact URLs.
The helper also provides class instantiation utilities that make sure to also honor the additional artifacts in classpath.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSpecial URL class loader allows to add new file URLs. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassLoaderadapt(ClassLoader cl) Adapt given class loader to also use additional artifacts if any.static voidaddArtifact(String gav, URL url) Adds a permanent dynamic class loader entry in the form of a URL.static voidaddArtifact(String gav, URL url, boolean permanent) Adds a dynamic class loader entry in the form of a URL.static voidClear cache for resource path lookup.static ClassLoaderstatic ClassLoadergetClassLoader(Class<?> type) static ClassLoaderstatic <T> TinstantiateType(String type, Class<?> caller, Object... initargs) Instantiate a type by its name.static <T> TinstantiateType(String type, ClassLoader cl, Object... initargs) Instantiate a type by its name.static <T> TinstantiateType(String type, Object... initargs) Instantiate a type by its name.static voidreset()Reset temporary artifacts only.static voidrestore()Clears additional artifacts and restores context class loader to its initial state before adapting.static booleanSet context class loader for current thread with adapted instance.static booleanupdateContextClassloader(boolean clearCache) Set context class loader for current thread with adapted instance.
-
Method Details
-
instantiateType
Instantiate a type by its name. Uses the current thread context class loader to instantiate. -
instantiateType
Instantiate a type by its name. Use the given caller to resolve the class loader. -
instantiateType
Instantiate a type by its name. Uses given class loader to instantiate. -
adapt
Adapt given class loader to also use additional artifacts if any. Wraps given class loader if additional artifacts are present. -
getContextClassLoader
-
getClassLoader
-
getClassLoader
-
addArtifact
Adds a permanent dynamic class loader entry in the form of a URL. When this helper resolves class loaders the dynamic entry will be part of the class loader. -
addArtifact
Adds a dynamic class loader entry in the form of a URL. When this helper resolves class loaders the dynamic entry will be part of the class loader. -
restore
public static void restore()Clears additional artifacts and restores context class loader to its initial state before adapting. -
reset
public static void reset()Reset temporary artifacts only. -
updateContextClassloader
public static boolean updateContextClassloader()Set context class loader for current thread with adapted instance. -
updateContextClassloader
public static boolean updateContextClassloader(boolean clearCache) Set context class loader for current thread with adapted instance. -
clearCache
public static void clearCache()Clear cache for resource path lookup. Required after the classpath has been adapted with additional artifacts.
-