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 Stringprivate static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringclassNameFromPackageProperties(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 JAXBContextfind(String factoryId, String contextPath, ClassLoader classLoader, Map properties) (package private) static StringfirstByServiceLoaderDeprecated(Class spiClass, ClassLoader classLoader) Deprecated.private static ClassLoaderprivate static ClassLoaderprivate static StringgetDeprecatedSystemProperty(String property) private static URLgetResourceUrl(Class<?> clazz, String resourceName) private static URLgetResourceUrl(ClassLoader classLoader, String resourceName) If run on JPMS package containing resource must be open unconditionally.private static ClassLoaderprivate static StringgetSystemProperty(String property) private static JAXBExceptionhandleClassCastException(Class originalType, Class targetType) Determine if two types (JAXBContext in this case) will generate a ClassCastException.private static ThrowableIf theInvocationTargetExceptionwraps an exception that shouldn't be wrapped, throw the wrapped exception.private static ObjectinstantiateProviderIfNecessary(Class<?> implClass) private static StringjaxbProperties(Class[] classesFromContextPath, String factoryId) private static StringjaxbProperties(String contextPath, ClassLoader classLoader, String factoryId) private static PropertiesloadJAXBProperties(URL url) (package private) static JAXBContextnewInstance(Class[] classes, Map properties, Class spFactory) (package private) static JAXBContextnewInstance(Class[] classes, Map properties, String className) Create an instance of a class using the thread context ClassLoader(package private) static JAXBContextnewInstance(String contextPath, Class[] contextPathClasses, Class spFactory, ClassLoader classLoader, Map properties) (package private) static JAXBContextnewInstance(String contextPath, Class[] contextPathClasses, String className, ClassLoader classLoader, Map properties) Create an instance of a class using the specified ClassLoader(package private) static URLGet the URL for the Class from it's ClassLoader.(package private) static URLwhich(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 theInvocationTargetExceptionwraps 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
-