The JAXBContext
provides the JAXB users anchor to the implmentation and hos generated classes. A JAXBContext is used to obtain instances of {@link javax.xml.bind.Marshaller}, {@link javax.xml.bind.Unmarshaller}, and {@link javax.xml.bind.Validator}. To obtain a JAXBContext, the application invokes
JAXBContext context = JAXBContext.newInstance("com.mycompany:com.mycompany.xml");
The list of colon separated package names matches the list in the schemas used to generate classes. In other words: If you have a schema using package name "com.mycompany.xml", then this package name has to be part of the list.
The JAXBContext
class will scan the given list of packages for a file called jaxb.properties. This file contains the name of an instantiation class in the property {@link #JAXB_CONTEXT_FACTORY}. (See {@link #newInstance(String)} fordetails on how the class name is obtained.) Once such a file is found, the given class is loaded via {@link ClassLoader#loadClass(java.lang.String)}. The JAXBContext
class demands, that the created object has a method
public static JAXBContext createContext(String pPath, ClassLoader pClassLoader) throws JAXBException;
This method is invoked with the same path and {@link ClassLoader} thanabove. See {@link #newInstance(String,ClassLoader)}} for details on the choice of the {@link ClassLoader}.
The created context will scan the same package path for implementation specific configuration details (in the case of the JaxMe
application a file called Configuration.xml in any of the packages) and do whatever else is required to initialize the runtime. In particular it will invoke {@link DatatypeConverter#setDatatypeConverter(DatatypeConverterInterface)}.
@author JSR-31
@since JAXB1.0
@see Marshaller
@see Unmarshaller
@see Validator