JAXBContextFactory (Java SE 10 & JDK 10 ) (original) (raw)
public interface JAXBContextFactory
Factory that creates new JAXBContext
instances. JAXBContextFactory can be located using ServiceLoader.load(Class)
Since:
9, JAXB 2.3
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type Method Description JAXBContext createContext(Class\[\] classesToBeBound,[Map](../../../java/util/Map.html "interface in java.util")<[String](../../../java/lang/String.html "class in java.lang"),?> properties) Create a new instance of a JAXBContext class. JAXBContext createContext(String contextPath,ClassLoader classLoader,Map<String,?> properties) Create a new instance of a JAXBContext class. Method Detail
* #### createContext [JAXBContext](../../../javax/xml/bind/JAXBContext.html "class in javax.xml.bind") createContext([Class](../../../java/lang/Class.html "class in java.lang")<?>[] classesToBeBound, [Map](../../../java/util/Map.html "interface in java.util")<[String](../../../java/lang/String.html "class in java.lang"),?> properties) throws [JAXBException](../../../javax/xml/bind/JAXBException.html "class in javax.xml.bind") Parameters: `classesToBeBound` \- List of java classes to be recognized by the new [JAXBContext](../../../javax/xml/bind/JAXBContext.html "class in javax.xml.bind"). Classes in `classesToBeBound` that are in named modules must be in a package that is [open](../../../java/lang/Module.html#isOpen%28java.lang.String,java.lang.Module%29) to at least the `java.xml.bind` module. Can be empty, in which case a [JAXBContext](../../../javax/xml/bind/JAXBContext.html "class in javax.xml.bind") that only knows about spec-defined classes will be returned. `properties` \- provider-specific properties. Can be null, which means the same thing as passing in an empty map. Returns: A new instance of a `JAXBContext`. Throws: `[JAXBException](../../../javax/xml/bind/JAXBException.html "class in javax.xml.bind")` \- if an error was encountered while creating the`JAXBContext`, such as (but not limited to): 1. No JAXB implementation was discovered 2. Classes use JAXB annotations incorrectly 3. Classes have colliding annotations (i.e., two classes with the same type name) 4. The JAXB implementation was unable to locate provider-specific out-of-band information (such as additional files generated at the development time.) 5. `classesToBeBound` are not open to `java.xml.bind` module `[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if the parameter contains `null` (i.e., `newInstance(null,someMap);`) Since: 9, JAXB 2.3 * #### createContext [JAXBContext](../../../javax/xml/bind/JAXBContext.html "class in javax.xml.bind") createContext([String](../../../java/lang/String.html "class in java.lang") contextPath, [ClassLoader](../../../java/lang/ClassLoader.html "class in java.lang") classLoader, [Map](../../../java/util/Map.html "interface in java.util")<[String](../../../java/lang/String.html "class in java.lang"),?> properties) throws [JAXBException](../../../javax/xml/bind/JAXBException.html "class in javax.xml.bind") Parameters: `contextPath` \- List of java package names that contain schema derived classes. Classes in `classesToBeBound` that are in named modules must be in a package that is [open](../../../java/lang/Module.html#isOpen%28java.lang.String,java.lang.Module%29) to at least the `java.xml.bind` module. `classLoader` \- This class loader will be used to locate the implementation classes. `properties` \- provider-specific properties. Can be null, which means the same thing as passing in an empty map. Returns: a new instance of a `JAXBContext` Throws: `[JAXBException](../../../javax/xml/bind/JAXBException.html "class in javax.xml.bind")` \- if an error was encountered while creating the`JAXBContext` such as 1. failure to locate either ObjectFactory.class or jaxb.index in the packages 2. an ambiguity among global elements contained in the contextPath 3. failure to locate a value for the context factory provider property 4. mixing schema derived packages from different providers on the same contextPath 5. packages are not open to `java.xml.bind` module Since: 9, JAXB 2.3
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.