Class ThreadContextClassLoaderTaskExecutor


  • @ProviderType
    public final class ThreadContextClassLoaderTaskExecutor
    extends Object
    Utility class for executing a particular task with a set Thread Context Class Loader.
    • Method Detail

      • doWithTccl

        public static <V> V doWithTccl​(ClassLoader classLoader,
                                       Callable<V> task)
                                throws Exception
        Execute the task while the Thread Context Class Loader is set to the provided Class Loader.
        Type Parameters:
        V - the return type of the task
        Parameters:
        classLoader - the requested class loader
        task - the task
        Returns:
        the return value
        Throws:
        Exception - the exception throw, if any, by the task