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.Thread
affectedThread
private java.lang.String
classPathArgument
private java.lang.ClassLoader
originalClassLoader
-
Constructor Summary
Constructors Constructor Description DefaultHolder(java.lang.Thread affectedThread, java.lang.ClassLoader originalClassLoader, java.lang.String classPathArgument)
Compound constructor creating a default-implementationThreadContextClassLoaderHolder
which wraps references to theThread
affected 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 void
finalize()
java.lang.String
getClassPathAsArgument()
Retrieves the ClassPath held by this ThreadContextClassLoaderHolder as aFile.pathSeparatorChar
-separated string.void
restoreClassLoaderAndReleaseThread()
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-implementationThreadContextClassLoaderHolder
which wraps references to theThread
affected 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:
restoreClassLoaderAndReleaseThread
in 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:
getClassPathAsArgument
in interfaceThreadContextClassLoaderHolder
- Returns:
- the ClassPath as an argument to external processes such as XJC.
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-