java.lang.Object
jakarta.xml.bind.ContextFinder
This class is package private and therefore is not exposed as part of the
Jakarta XML Binding API.
This code is designed to implement the XML Binding spec pluggability feature
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
When JAXB is in J2SE, rt.jar has to have a JAXB implementation.private static ServiceLoaderUtil.ExceptionHandler
<JAXBException> private static final Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
(package private) static JAXBContext
(package private) static JAXBContext
private static ClassLoader
getClassClassLoader
(Class<?> c) private static ClassLoader
private static ClassLoader
private static String
getSystemProperty
(String property) private static JAXBException
handleClassCastException
(Class<?> originalType, Class<?> targetType) Determine if two types (JAXBContext in this case) will generate a ClassCastException.private static Throwable
If theInvocationTargetException
wraps an exception that shouldn't be wrapped, throw the wrapped exception.private static Object
instantiateProviderIfNecessary
(Class<?> implClass) (package private) static JAXBContext
newInstance
(Class<?>[] classes, Map<String, ?> properties, Class<?> spFactory) private static JAXBContext
newInstance
(Class<?>[] classes, Map<String, ?> properties, String className) Create an instance of a class using the thread context ClassLoaderprivate static JAXBContext
newInstance
(Class<?>[] classes, Map<String, ?> properties, String className, ClassLoader loader) Create an instance of a class using passed in ClassLoader(package private) static JAXBContext
newInstance
(String contextPath, Class<?>[] contextPathClasses, Class<?> spFactory, ClassLoader classLoader, Map<String, ?> properties) (package private) static JAXBContext
newInstance
(String contextPath, Class<?>[] contextPathClasses, String className, ClassLoader classLoader, Map<String, ?> properties) Create an instance of a class using the specified ClassLoader(package private) static URL
Get the URL for the Class from it's ClassLoader.(package private) static URL
which
(Class<?> clazz, ClassLoader loader) Search the given ClassLoader for an instance of the specified class and return a string representation of the URL that points to the resource.
-
Field Details
-
logger
-
DEFAULT_FACTORY_CLASS
When JAXB is in J2SE, rt.jar has to have a JAXB implementation. However, rt.jar cannot have META-INF/services/jakarta.xml.bind.JAXBContext because if it has, it will take precedence over any file that applications have in their jar files.When the user bundles his own Jakarta XML Binding implementation, we'd like to use it, and we want the platform default to be used only when there's no other Jakarta XML Binding provider.
For this reason, we have to hard-code the class name into the API.
- See Also:
-
EXCEPTION_HANDLER
-
-
Constructor Details
-
ContextFinder
ContextFinder()
-
-
Method Details
-
handleInvocationTargetException
private static Throwable handleInvocationTargetException(InvocationTargetException x) throws JAXBException If theInvocationTargetException
wraps an exception that shouldn't be wrapped, throw the wrapped exception. Otherwise, returns exception to be wrapped for further processing.- Throws:
JAXBException
-
handleClassCastException
Determine if two types (JAXBContext in this case) will generate a ClassCastException.For example, (targetType)originalType
- Parameters:
originalType
- The Class object of the type being casttargetType
- The Class object of the type that is being cast to- Returns:
- JAXBException to be thrown.
-
newInstance
static JAXBContext newInstance(String contextPath, Class<?>[] contextPathClasses, String className, ClassLoader classLoader, Map<String, ?> properties) throws JAXBExceptionCreate an instance of a class using the specified ClassLoader- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(String contextPath, Class<?>[] contextPathClasses, Class<?> spFactory, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException- Throws:
JAXBException
-
instantiateProviderIfNecessary
- Throws:
JAXBException
-
newInstance
private static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, String className) throws JAXBExceptionCreate an instance of a class using the thread context ClassLoader- Throws:
JAXBException
-
newInstance
private static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, String className, ClassLoader loader) throws JAXBExceptionCreate an instance of a class using passed in ClassLoader- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, Class<?> spFactory) throws JAXBException- Throws:
JAXBException
-
find
static JAXBContext find(String factoryId, String contextPath, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException- Throws:
JAXBException
-
find
- Throws:
JAXBException
-
classNameFromSystemProperties
- Throws:
JAXBException
-
getSystemProperty
-
which
Search the given ClassLoader for an instance of the specified class and return a string representation of the URL that points to the resource.- Parameters:
clazz
- The class to search forloader
- The ClassLoader to search. If this parameter is null, then the system class loader will be searched- Returns:
- the URL for the class or null if it wasn't found
-
which
Get the URL for the Class from it's ClassLoader.Convenience method for
which(Class, ClassLoader)
.Equivalent to calling: which(clazz, clazz.getClassLoader())
- Parameters:
clazz
- The class to search for- Returns:
- the URL for the class or null if it wasn't found
-
getContextClassLoader
-
getClassClassLoader
-
getSystemClassLoader
-