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 java.lang.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 Summary
Fields Modifier and Type Field Description private java.lang.ThreadaffectedThreadprivate java.lang.StringclassPathArgumentprivate java.lang.ClassLoaderoriginalClassLoader
-
Constructor Summary
Constructors Constructor Description DefaultHolder(java.lang.Thread affectedThread, java.lang.ClassLoader originalClassLoader, java.lang.String classPathArgument)Compound constructor creating a default-implementationThreadContextClassLoaderHolderwhich wraps references to theThreadaffected as well as the original ClassLoader to restore during the call torestoreClassLoaderAndReleaseThread()method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfinalize()java.lang.StringgetClassPathAsArgument()Retrieves the ClassPath held by this ThreadContextClassLoaderHolder as aFile.pathSeparatorChar-separated string.voidrestoreClassLoaderAndReleaseThread()Restores the original ThreadContext ClassLoader, and nullifies any references to the Thread which had its ThreadContext ClassLoader altered.
-
-
-
Constructor Detail
-
DefaultHolder
public DefaultHolder(java.lang.Thread affectedThread, java.lang.ClassLoader originalClassLoader, java.lang.String classPathArgument)Compound constructor creating a default-implementationThreadContextClassLoaderHolderwhich wraps references to theThreadaffected as well as the original ClassLoader to restore during the call torestoreClassLoaderAndReleaseThread()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 togetClassPathAsArgument().
-
-
Method Detail
-
restoreClassLoaderAndReleaseThread
public void restoreClassLoaderAndReleaseThread()
Restores the original ThreadContext ClassLoader, and nullifies any references to the Thread which had its ThreadContext ClassLoader altered.- Specified by:
restoreClassLoaderAndReleaseThreadin interfaceThreadContextClassLoaderHolder
-
getClassPathAsArgument
public java.lang.String getClassPathAsArgument()
Retrieves the ClassPath held by this ThreadContextClassLoaderHolder as aFile.pathSeparatorChar-separated string. This is directly usable as a String argument by any external process.- Specified by:
getClassPathAsArgumentin interfaceThreadContextClassLoaderHolder- Returns:
- the ClassPath as an argument to external processes such as XJC.
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-