Class ThreadContextClassLoaderBuilder.DefaultHolder

java.lang.Object
org.codehaus.mojo.jaxb2.shared.environment.classloading.ThreadContextClassLoaderBuilder.DefaultHolder
All Implemented Interfaces:
ThreadContextClassLoaderHolder
Enclosing class:
ThreadContextClassLoaderBuilder

class ThreadContextClassLoaderBuilder.DefaultHolder extends Object implements ThreadContextClassLoaderHolder
Default implementation of the ThreadContextClassLoaderCleaner specification, with added finalizer to ensure we release the Thread reference no matter what happens with any DefaultCleaner objects.
  • Field Details

    • affectedThread

      private Thread affectedThread
    • originalClassLoader

      private ClassLoader originalClassLoader
    • classPathArgument

      private String classPathArgument
  • Constructor Details

    • DefaultHolder

      public DefaultHolder(Thread affectedThread, ClassLoader originalClassLoader, String classPathArgument)
      Compound constructor creating a default-implementation ThreadContextClassLoaderHolder which wraps references to the Thread affected as well as the original ClassLoader to restore during the call to restoreClassLoaderAndReleaseThread() method.
      Parameters:
      affectedThread - The non-null Thread for which a new ClassLoader should be constructed.
      originalClassLoader - The non-null original ClassLoader.
      classPathArgument - The non-null classpath argument, to be returned from the method call to getClassPathAsArgument().
  • Method Details

    • restoreClassLoaderAndReleaseThread

      public void restoreClassLoaderAndReleaseThread()
      Restores the original ThreadContext ClassLoader, and nullifies any references to the Thread which had its ThreadContext ClassLoader altered.
      Specified by:
      restoreClassLoaderAndReleaseThread in interface ThreadContextClassLoaderHolder
    • getClassPathAsArgument

      public String getClassPathAsArgument()
      Retrieves the ClassPath held by this ThreadContextClassLoaderHolder as a File.pathSeparatorChar-separated string. This is directly usable as a String argument by any external process.
      Specified by:
      getClassPathAsArgument in interface ThreadContextClassLoaderHolder
      Returns:
      the ClassPath as an argument to external processes such as XJC.
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable