Top Description Fields Constructors Methods
jakarta.xml.bind

pack-priv Class ContextFinder

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.lang.reflect.InvocationTargetException, .Method, java.net.URL, java.security.AccessController, .PrivilegedAction, .PrivilegedActionException, .PrivilegedExceptionAction, java.util.Iterator, .Map, .Properties, java.util.logging.ConsoleHandler, .Level, .Logger

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
Author
See Also
JAXBContext

Field Summary

Modifier and TypeField and Description
pack-priv static final String
DEFAULT_FACTORY_CLASS

When JAXB is in J2SE, rt.jar has to have a JAXB implementation.

private static ServiceLoaderUtil.ExceptionHandler<JAXBException>
private static final Logger

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static String
pack-priv static JAXBContext
find(String factoryId, String contextPath, ClassLoader classLoader, Map<String, ?> properties)

pack-priv static JAXBContext
find(Class<?>[] classes, Map<String, ?> properties)

private static ClassLoader
private static ClassLoader
private static ClassLoader
private static String
private static JAXBException

Returns:

JAXBException to be thrown.
handleClassCastException
(Class<?>
The Class object of the type being cast
originalType
,
Class<?>
The Class object of the type that is being cast to
targetType
)

Determine if two types (JAXBContext in this case) will generate a ClassCastException.

private static Throwable
handleInvocationTargetException(InvocationTargetException x)

If the InvocationTargetException wraps an exception that shouldn't be wrapped, throw the wrapped exception.

private static Object
pack-priv static JAXBContext
newInstance(String contextPath, Class<?>[] contextPathClasses, String className, ClassLoader classLoader, Map<String, ?> properties)

Create an instance of a class using the specified ClassLoader

pack-priv static JAXBContext
newInstance(String contextPath, Class<?>[] contextPathClasses, Class<?> spFactory, ClassLoader classLoader, Map<String, ?> properties)

private static JAXBContext
newInstance(Class<?>[] classes, Map<String, ?> properties, String className)

Create an instance of a class using the thread context ClassLoader

private static JAXBContext
newInstance(Class<?>[] classes, Map<String, ?> properties, String className, ClassLoader loader)

Create an instance of a class using passed in ClassLoader

pack-priv static JAXBContext
newInstance(Class<?>[] classes, Map<String, ?> properties, Class<?> spFactory)

pack-priv static URL

Returns:

the URL for the class or null if it wasn't found
which
(Class<?>
The class to search for
clazz
,
ClassLoader
The ClassLoader to search. If this parameter is null, then the system class loader will be searched
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.

pack-priv static URL

Returns:

the URL for the class or null if it wasn't found
which
(Class<?>
The class to search for
clazz
)

Get the URL for the Class from it's ClassLoader.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FACTORY_CLASSback to summary
pack-priv static final String 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.

EXCEPTION_HANDLERback to summary
private static ServiceLoaderUtil.ExceptionHandler<JAXBException> EXCEPTION_HANDLER
loggerback to summary
private static final Logger logger

Constructor Detail

ContextFinderback to summary
pack-priv ContextFinder()

Method Detail

classNameFromSystemPropertiesback to summary
private static String classNameFromSystemProperties() throws JAXBException
findback to summary
pack-priv static JAXBContext find(String factoryId, String contextPath, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException
findback to summary
pack-priv static JAXBContext find(Class<?>[] classes, Map<String, ?> properties) throws JAXBException
getClassClassLoaderback to summary
private static ClassLoader getClassClassLoader(final Class<?> c)
getContextClassLoaderback to summary
private static ClassLoader getContextClassLoader()
getSystemClassLoaderback to summary
private static ClassLoader getSystemClassLoader()
getSystemPropertyback to summary
private static String getSystemProperty(String property)
handleClassCastExceptionback to summary
private static JAXBException handleClassCastException(Class<?> originalType, Class<?> targetType)

Determine if two types (JAXBContext in this case) will generate a ClassCastException. For example, (targetType)originalType

Parameters
originalType:Class<?>

The Class object of the type being cast

targetType:Class<?>

The Class object of the type that is being cast to

Returns:JAXBException

JAXBException to be thrown.

handleInvocationTargetExceptionback to summary
private static Throwable handleInvocationTargetException(InvocationTargetException x) throws JAXBException

If the InvocationTargetException wraps an exception that shouldn't be wrapped, throw the wrapped exception. Otherwise returns exception to be wrapped for further processing.

instantiateProviderIfNecessaryback to summary
private static Object instantiateProviderIfNecessary(final Class<?> implClass) throws JAXBException
newInstanceback to summary
pack-priv static JAXBContext newInstance(String contextPath, Class<?>[] contextPathClasses, String className, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException

Create an instance of a class using the specified ClassLoader

newInstanceback to summary
pack-priv static JAXBContext newInstance(String contextPath, Class<?>[] contextPathClasses, Class<?> spFactory, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException
newInstanceback to summary
private static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, String className) throws JAXBException

Create an instance of a class using the thread context ClassLoader

newInstanceback to summary
private static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, String className, ClassLoader loader) throws JAXBException

Create an instance of a class using passed in ClassLoader

newInstanceback to summary
pack-priv static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, Class<?> spFactory) throws JAXBException
whichback to summary
pack-priv 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.

Parameters
clazz:Class<?>

The class to search for

loader:ClassLoader

The ClassLoader to search. If this parameter is null, then the system class loader will be searched

Returns:URL

the URL for the class or null if it wasn't found

whichback to summary
pack-priv static URL which(Class<?> clazz)

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:Class<?>

The class to search for

Returns:URL

the URL for the class or null if it wasn't found