Package javax.xml.bind
Class ContextFinder
- java.lang.Object
-
- javax.xml.bind.ContextFinder
-
class ContextFinder extends java.lang.ObjectThis 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_HANDLERprivate static java.lang.StringJAXB_CONTEXT_FACTORY_DEPRECATEDprivate static java.util.logging.Loggerloggerprivate static java.lang.StringPLATFORM_DEFAULT_FACTORY_CLASSWhen JAXB is in J2SE, rt.jar has to have a JAXB implementation.
-
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.StringclassNameFromPackageProperties(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.StringclassNameFromSystemProperties()(package private) static JAXBContextfind(java.lang.Class<?>[] classes, java.util.Map<java.lang.String,?> properties)(package private) static JAXBContextfind(java.lang.String factoryId, java.lang.String contextPath, java.lang.ClassLoader classLoader, java.util.Map properties)(package private) static java.lang.StringfirstByServiceLoaderDeprecated(java.lang.Class spiClass, java.lang.ClassLoader classLoader)Deprecated.private static java.lang.ClassLoadergetClassClassLoader(java.lang.Class c)private static java.lang.ClassLoadergetContextClassLoader()private static java.lang.StringgetDeprecatedSystemProperty(java.lang.String property)private static java.net.URLgetResourceUrl(java.lang.Class<?> clazz, java.lang.String resourceName)private static java.net.URLgetResourceUrl(java.lang.ClassLoader classLoader, java.lang.String resourceName)If run on JPMS package containing resource must be open unconditionally.private static java.lang.ClassLoadergetSystemClassLoader()private static java.lang.StringgetSystemProperty(java.lang.String property)private static JAXBExceptionhandleClassCastException(java.lang.Class originalType, java.lang.Class targetType)Determine if two types (JAXBContext in this case) will generate a ClassCastException.private static java.lang.ThrowablehandleInvocationTargetException(java.lang.reflect.InvocationTargetException x)If theInvocationTargetExceptionwraps an exception that shouldn't be wrapped, throw the wrapped exception.private static java.lang.ObjectinstantiateProviderIfNecessary(java.lang.Class<?> implClass)private static java.lang.StringjaxbProperties(java.lang.Class[] classesFromContextPath, java.lang.String factoryId)private static java.lang.StringjaxbProperties(java.lang.String contextPath, java.lang.ClassLoader classLoader, java.lang.String factoryId)private static java.util.PropertiesloadJAXBProperties(java.net.URL url)(package private) static JAXBContextnewInstance(java.lang.Class[] classes, java.util.Map properties, java.lang.Class spFactory)(package private) static JAXBContextnewInstance(java.lang.Class[] classes, java.util.Map properties, java.lang.String className, java.lang.ClassLoader loader)Create an instance of a class using the thread context ClassLoader(package private) static JAXBContextnewInstance(java.lang.String contextPath, java.lang.Class[] contextPathClasses, java.lang.Class spFactory, java.lang.ClassLoader classLoader, java.util.Map properties)(package private) static JAXBContextnewInstance(java.lang.String contextPath, java.lang.Class[] contextPathClasses, java.lang.String className, java.lang.ClassLoader factoryClassloader, java.lang.ClassLoader classLoader, java.util.Map properties)(package private) static JAXBContextnewInstance(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.URLwhich(java.lang.Class clazz)Get the URL for the Class from it's ClassLoader.(package private) static java.net.URLwhich(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
-
PLATFORM_DEFAULT_FACTORY_CLASS
private static final java.lang.String PLATFORM_DEFAULT_FACTORY_CLASS
When JAXB is in J2SE, rt.jar has to have a JAXB implementation. However, rt.jar cannot have META-INF/services/javax.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 JAXB implementation, we'd like to use it, and we want the platform default to be used only when there's no other JAXB provider.
For this reason, we have to hard-code the class name into the API.
- See Also:
- Constant Field Values
-
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 JAXBExceptionIf theInvocationTargetExceptionwraps 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.String className, java.lang.ClassLoader factoryClassloader, java.lang.ClassLoader classLoader, java.util.Map properties) throws JAXBException
- 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, java.lang.ClassLoader loader) 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 JAXBExceptionfirst 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 JAXBExceptionDeprecated.- 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
-
-