java.lang.Object
javax.xml.bind.ContextFinder
This class is package private and therefore is not exposed as part of the
JAXB API.
This code is designed to implement the JAXB 1.0 spec pluggability feature
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ServiceLoaderUtil.ExceptionHandler<JAXBException>
private static final String
private static final Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
classNameFromPackageProperties
(URL packagePropertiesUrl, String... factoryIds) first factoryId should be the preferred one, more of those can be provided to support backwards compatibilityprivate static String
(package private) static JAXBContext
(package private) static JAXBContext
find
(String factoryId, String contextPath, ClassLoader classLoader, Map properties) (package private) static String
firstByServiceLoaderDeprecated
(Class spiClass, ClassLoader classLoader) Deprecated.private static ClassLoader
private static ClassLoader
private static String
getDeprecatedSystemProperty
(String property) private static URL
getResourceUrl
(Class<?> clazz, String resourceName) private static URL
getResourceUrl
(ClassLoader classLoader, String resourceName) If run on JPMS package containing resource must be open unconditionally.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) private static String
jaxbProperties
(Class[] classesFromContextPath, String factoryId) private static String
jaxbProperties
(String contextPath, ClassLoader classLoader, String factoryId) private static Properties
loadJAXBProperties
(URL url) (package private) static JAXBContext
newInstance
(Class[] classes, Map properties, Class spFactory) (package private) static JAXBContext
newInstance
(Class[] classes, Map properties, String className) Create an instance of a class using the thread context ClassLoader(package private) static JAXBContext
newInstance
(String contextPath, Class[] contextPathClasses, Class spFactory, ClassLoader classLoader, Map properties) (package private) static JAXBContext
newInstance
(String contextPath, Class[] contextPathClasses, String className, ClassLoader classLoader, Map 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
-
JAXB_CONTEXT_FACTORY_DEPRECATED
- See Also:
-
logger
-
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 properties) throws JAXBException Create an instance of a class using the specified ClassLoader- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(String contextPath, Class[] contextPathClasses, Class spFactory, ClassLoader classLoader, Map properties) throws JAXBException - Throws:
JAXBException
-
instantiateProviderIfNecessary
- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(Class[] classes, Map properties, String className) throws JAXBException Create an instance of a class using the thread context ClassLoader- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(Class[] classes, Map properties, Class spFactory) throws JAXBException - Throws:
JAXBException
-
find
static JAXBContext find(String factoryId, String contextPath, ClassLoader classLoader, Map properties) throws JAXBException - Throws:
JAXBException
-
find
- Throws:
JAXBException
-
classNameFromPackageProperties
private static String classNameFromPackageProperties(URL packagePropertiesUrl, String... factoryIds) throws JAXBException first factoryId should be the preferred one, more of those can be provided to support backwards compatibility- Throws:
JAXBException
-
classNameFromSystemProperties
- Throws:
JAXBException
-
getDeprecatedSystemProperty
-
getSystemProperty
-
loadJAXBProperties
- Throws:
JAXBException
-
getResourceUrl
If run on JPMS package containing resource must be open unconditionally.- Parameters:
classLoader
- classloader to load resource withresourceName
- qualified name of the resource- Returns:
- resource url if found
-
getResourceUrl
-
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 forwhich(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
-
firstByServiceLoaderDeprecated
@Deprecated static String firstByServiceLoaderDeprecated(Class spiClass, ClassLoader classLoader) throws JAXBException Deprecated.- Throws:
JAXBException
-
jaxbProperties
private static String jaxbProperties(String contextPath, ClassLoader classLoader, String factoryId) throws JAXBException - Throws:
JAXBException
-
jaxbProperties
private static String jaxbProperties(Class[] classesFromContextPath, String factoryId) throws JAXBException - Throws:
JAXBException
-