- java.lang.Object
-
- javax.xml.bind.ContextFinder
-
class ContextFinder extends java.lang.Object
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:
JAXBContext
-
-
Field Summary
Fields Modifier and Type Field Description private static ServiceLoaderUtil.ExceptionHandler<JAXBException>
EXCEPTION_HANDLER
private static java.lang.String
JAXB_CONTEXT_FACTORY_DEPRECATED
private static java.util.logging.Logger
logger
-
Constructor Summary
Constructors Constructor Description ContextFinder()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static java.lang.String
classNameFromPackageProperties(java.net.URL packagePropertiesUrl, java.lang.String... factoryIds)
first factoryId should be the preferred one, more of those can be provided to support backwards compatibilityprivate static java.lang.String
classNameFromSystemProperties()
(package private) static JAXBContext
find(java.lang.Class<?>[] classes, java.util.Map<java.lang.String,?> properties)
(package private) static JAXBContext
find(java.lang.String factoryId, java.lang.String contextPath, java.lang.ClassLoader classLoader, java.util.Map properties)
(package private) static java.lang.String
firstByServiceLoaderDeprecated(java.lang.Class spiClass, java.lang.ClassLoader classLoader)
Deprecated.private static java.lang.ClassLoader
getClassClassLoader(java.lang.Class c)
private static java.lang.ClassLoader
getContextClassLoader()
private static java.lang.String
getDeprecatedSystemProperty(java.lang.String property)
private static java.net.URL
getResourceUrl(java.lang.Class<?> clazz, java.lang.String resourceName)
private static java.net.URL
getResourceUrl(java.lang.ClassLoader classLoader, java.lang.String resourceName)
If run on JPMS package containing resource must be open unconditionally.private static java.lang.ClassLoader
getSystemClassLoader()
private static java.lang.String
getSystemProperty(java.lang.String property)
private static JAXBException
handleClassCastException(java.lang.Class originalType, java.lang.Class targetType)
Determine if two types (JAXBContext in this case) will generate a ClassCastException.private static java.lang.Throwable
handleInvocationTargetException(java.lang.reflect.InvocationTargetException x)
If theInvocationTargetException
wraps an exception that shouldn't be wrapped, throw the wrapped exception.private static java.lang.Object
instantiateProviderIfNecessary(java.lang.Class<?> implClass)
private static java.lang.String
jaxbProperties(java.lang.Class[] classesFromContextPath, java.lang.String factoryId)
private static java.lang.String
jaxbProperties(java.lang.String contextPath, java.lang.ClassLoader classLoader, java.lang.String factoryId)
private static java.util.Properties
loadJAXBProperties(java.net.URL url)
(package private) static JAXBContext
newInstance(java.lang.Class[] classes, java.util.Map properties, java.lang.Class spFactory)
(package private) static JAXBContext
newInstance(java.lang.Class[] classes, java.util.Map properties, java.lang.String className)
Create an instance of a class using the thread context ClassLoader(package private) static JAXBContext
newInstance(java.lang.String contextPath, java.lang.Class[] contextPathClasses, java.lang.Class spFactory, java.lang.ClassLoader classLoader, java.util.Map properties)
(package private) static JAXBContext
newInstance(java.lang.String contextPath, java.lang.Class[] contextPathClasses, java.lang.String className, java.lang.ClassLoader classLoader, java.util.Map properties)
Create an instance of a class using the specified ClassLoader(package private) static java.net.URL
which(java.lang.Class clazz)
Get the URL for the Class from it's ClassLoader.(package private) static java.net.URL
which(java.lang.Class clazz, java.lang.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 Detail
-
JAXB_CONTEXT_FACTORY_DEPRECATED
private static final java.lang.String JAXB_CONTEXT_FACTORY_DEPRECATED
- See Also:
- Constant Field Values
-
logger
private static final java.util.logging.Logger logger
-
EXCEPTION_HANDLER
private static ServiceLoaderUtil.ExceptionHandler<JAXBException> EXCEPTION_HANDLER
-
-
Method Detail
-
handleInvocationTargetException
private static java.lang.Throwable handleInvocationTargetException(java.lang.reflect.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
private static JAXBException handleClassCastException(java.lang.Class originalType, java.lang.Class targetType)
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(java.lang.String contextPath, java.lang.Class[] contextPathClasses, java.lang.String className, java.lang.ClassLoader classLoader, java.util.Map properties) throws JAXBException
Create an instance of a class using the specified ClassLoader- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(java.lang.String contextPath, java.lang.Class[] contextPathClasses, java.lang.Class spFactory, java.lang.ClassLoader classLoader, java.util.Map properties) throws JAXBException
- Throws:
JAXBException
-
instantiateProviderIfNecessary
private static java.lang.Object instantiateProviderIfNecessary(java.lang.Class<?> implClass) throws JAXBException
- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(java.lang.Class[] classes, java.util.Map properties, java.lang.String className) throws JAXBException
Create an instance of a class using the thread context ClassLoader- Throws:
JAXBException
-
newInstance
static JAXBContext newInstance(java.lang.Class[] classes, java.util.Map properties, java.lang.Class spFactory) throws JAXBException
- Throws:
JAXBException
-
find
static JAXBContext find(java.lang.String factoryId, java.lang.String contextPath, java.lang.ClassLoader classLoader, java.util.Map properties) throws JAXBException
- Throws:
JAXBException
-
find
static JAXBContext find(java.lang.Class<?>[] classes, java.util.Map<java.lang.String,?> properties) throws JAXBException
- Throws:
JAXBException
-
classNameFromPackageProperties
private static java.lang.String classNameFromPackageProperties(java.net.URL packagePropertiesUrl, java.lang.String... factoryIds) throws JAXBException
first factoryId should be the preferred one, more of those can be provided to support backwards compatibility- Throws:
JAXBException
-
classNameFromSystemProperties
private static java.lang.String classNameFromSystemProperties() throws JAXBException
- Throws:
JAXBException
-
getDeprecatedSystemProperty
private static java.lang.String getDeprecatedSystemProperty(java.lang.String property)
-
getSystemProperty
private static java.lang.String getSystemProperty(java.lang.String property)
-
loadJAXBProperties
private static java.util.Properties loadJAXBProperties(java.net.URL url) throws JAXBException
- Throws:
JAXBException
-
getResourceUrl
private static java.net.URL getResourceUrl(java.lang.ClassLoader classLoader, java.lang.String resourceName)
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
private static java.net.URL getResourceUrl(java.lang.Class<?> clazz, java.lang.String resourceName)
-
which
static java.net.URL which(java.lang.Class clazz, java.lang.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.- 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
static java.net.URL which(java.lang.Class clazz)
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
private static java.lang.ClassLoader getContextClassLoader()
-
getClassClassLoader
private static java.lang.ClassLoader getClassClassLoader(java.lang.Class c)
-
getSystemClassLoader
private static java.lang.ClassLoader getSystemClassLoader()
-
firstByServiceLoaderDeprecated
@Deprecated static java.lang.String firstByServiceLoaderDeprecated(java.lang.Class spiClass, java.lang.ClassLoader classLoader) throws JAXBException
Deprecated.- Throws:
JAXBException
-
jaxbProperties
private static java.lang.String jaxbProperties(java.lang.String contextPath, java.lang.ClassLoader classLoader, java.lang.String factoryId) throws JAXBException
- Throws:
JAXBException
-
jaxbProperties
private static java.lang.String jaxbProperties(java.lang.Class[] classesFromContextPath, java.lang.String factoryId) throws JAXBException
- Throws:
JAXBException
-
-