javax.xml.bind
Class ContextFinder

java.lang.Object
  extended by 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

Version:
$Revision: 1.25 $
Author:
See Also:
JAXBContext

Field Summary
private static java.util.logging.Logger logger
           
private static java.lang.String PLATFORM_DEFAULT_FACTORY_CLASS
          When JAXB is in J2SE, rt.jar has to have a JAXB implementation.
 
Constructor Summary
ContextFinder()
           
 
Method Summary
(package private) static JAXBContext find(java.lang.Class[] classes, java.util.Map properties)
           
(package private) static JAXBContext find(java.lang.String factoryId, java.lang.String contextPath, java.lang.ClassLoader classLoader, java.util.Map properties)
           
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 void handleInvocationTargetException(java.lang.reflect.InvocationTargetException x)
          If the InvocationTargetException wraps an exception that shouldn't be wrapped, throw the wrapped exception.
private static java.util.Properties loadJAXBProperties(java.lang.ClassLoader classLoader, java.lang.String propFileName)
           
(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 specified ClassLoader
(package private) static JAXBContext newInstance(java.lang.String contextPath, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

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
Constructor Detail

ContextFinder

ContextFinder()
Method Detail

handleInvocationTargetException

private static void handleInvocationTargetException(java.lang.reflect.InvocationTargetException x)
                                             throws JAXBException
If the InvocationTargetException wraps an exception that shouldn't be wrapped, throw the wrapped exception.

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 cast
targetType - 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.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.Class[] classes,
                               java.util.Map properties,
                               java.lang.String className)
                        throws JAXBException
Create an instance of a class using the specified ClassLoader

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 properties)
                 throws JAXBException
Throws:
JAXBException

loadJAXBProperties

private static java.util.Properties loadJAXBProperties(java.lang.ClassLoader classLoader,
                                                       java.lang.String propFileName)
                                                throws JAXBException
Throws:
JAXBException

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 for
loader - 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 for which(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