public class JAXBContext extends JAXBContext
Purpose:Provide a EclipseLink implementation of the JAXBContext interface.
Responsibilities:
This is the EclipseLink JAXB 2.0 implementation of javax.xml.bind.JAXBContext. This class is created by the JAXBContextFactory and is used to create Marshallers, Unmarshallers, Validators, Binders and Introspectors. A JAXBContext can also be used to create Schema Files.
Bootstrapping: When bootstrapping the JAXBContext from a EclipseLink externalized metadata file(s) a number of input options are available. The externalized metadata file (one per package) is passed in through a property when creating the JAXBContext. The key used in the properties map is "eclipselink-oxm-xml". The externalized metadata file can be set in the properties map in one of three ways:
i) For a single externalized metadata file, one of the following can be set in the properties map:
ii) For multiple externalized metadata files where the package name is specified within each externalized metadata file, a List can be used. The entries in the List are to be one of the types listed in i) above.
iii) For multiple externalized metadata files where the package name is not specified in each externalized metadata file, a Map can be used. The key must be a String (package name) and each value in the Map (externalized metadata file) is to be one of the types listed in i) above.
Note that in each of the above cases the package name can be set via package-name attribute on the xml-bindings element in the externalized metadata file. If set, any java-type names in the given metadata file that do not contain the package name will have that package name prepended to it. Also note that a List or Map can be used for a single externalized metadata file.
JAXBContext
,
JAXBMarshaller
,
JAXBUnmarshaller
,
JAXBBinder
,
JAXBIntrospector
,
JAXBContextProperties
Modifier and Type | Class and Description |
---|---|
static class |
JAXBContext.JAXBContextInput
The JAXBContextInput is used to create a JAXBContextState which is responsible for accessing
the underlying XMLContext
|
protected static class |
JAXBContext.JAXBContextState |
Modifier and Type | Field and Description |
---|---|
protected JAXBContext.JAXBContextInput |
contextInput |
protected JAXBContext.JAXBContextState |
contextState |
protected static ValidationEventHandler |
DEFAULT_VALIDATION_EVENT_HANDLER
For JAXB 2 there is no explicitly defined default validation handler
and the default event handling only terminates the operation after
encountering a fatal error.
|
JAXB_CONTEXT_FACTORY
Modifier | Constructor and Description |
---|---|
protected |
JAXBContext() |
protected |
JAXBContext(JAXBContext.JAXBContextInput contextInput) |
|
JAXBContext(XMLContext context)
Create a JAXBContext for a given XMLContext.
|
|
JAXBContext(XMLContext context,
Generator generator,
java.lang.reflect.Type[] boundTypes)
Create a JAXBContext.
|
|
JAXBContext(XMLContext context,
Generator generator,
TypeMappingInfo[] boundTypes)
Create a JAXBContext.
|
Modifier and Type | Method and Description |
---|---|
void |
applyORMMetadata(org.eclipse.persistence.internal.sessions.AbstractSession ormSession)
ADVANCED:
Adjust the OXM metadata to take into account ORM mapping metadata
|
JAXBBinder |
createBinder()
Create a JAXBBinder.
|
<T> JAXBBinder |
createBinder(java.lang.Class<T> nodeClass)
Create a JAXBBinder.
|
java.lang.Object |
createByQualifiedName(java.lang.String namespace,
java.lang.String typeName,
boolean isGlobalType)
Create a new object instance for a given XML namespace and name.
|
<T> T |
createByXPath(java.lang.Object parentObject,
java.lang.String xPath,
NamespaceResolver namespaceResolver,
java.lang.Class<T> returnType)
Create a new object instance for a given XPath, relative to the parentObject.
|
protected JAXBElement |
createJAXBElement(javax.xml.namespace.QName qname,
java.lang.Class theClass,
java.lang.Object value) |
protected JAXBElement |
createJAXBElementFromXMLRoot(org.eclipse.persistence.internal.oxm.Root xmlRoot,
java.lang.Class declaredType) |
JAXBIntrospector |
createJAXBIntrospector()
Creates a JAXBIntrospector object.
|
JAXBMarshaller |
createMarshaller()
Create a JAXBMarshaller.
|
ObjectGraph |
createObjectGraph(java.lang.Class type) |
ObjectGraph |
createObjectGraph(java.lang.String typeName) |
JAXBUnmarshaller |
createUnmarshaller()
Create a JAXBUnmarshaller.
|
JAXBValidator |
createValidator()
Create a JAXBValidator.
|
void |
generateJsonSchema(SchemaOutputResolver outputResolver,
java.lang.Class rootClass) |
void |
generateSchema(SchemaOutputResolver outputResolver)
Generate a Schema for this JAXBContext
|
void |
generateSchema(SchemaOutputResolver outputResolver,
java.util.Map<javax.xml.namespace.QName,java.lang.reflect.Type> additonalGlobalElements)
Generate a Schema for this JAXBContext
|
java.util.Map<java.lang.String,java.lang.Class> |
getArrayClassesToGeneratedClasses()
INTERNAL:
Get the map for which array class (by name) corresponds to which generated class
|
BeanValidationHelper |
getBeanValidationHelper()
Returns BeanValidationHelper.
|
java.util.Map<java.lang.String,java.lang.Class> |
getClassToGeneratedClasses()
INTERNAL:
Get the map containing which Class (by name) corresponds to which generated class.
|
java.util.Map<java.lang.reflect.Type,java.lang.Class> |
getCollectionClassesToGeneratedClasses()
INTERNAL:
Get the map for which collection class (by Type) corresponds to which generated class
|
java.util.Map<javax.xml.namespace.QName,java.lang.Class> |
getQNamesToDeclaredClasses()
INTERNAL:
Get the map of which QName corresponds to which declared class.
|
java.util.Map<TypeMappingInfo,javax.xml.namespace.QName> |
getTypeMappingInfoToSchemaType()
INTERNAL:
Get the map of which TypeMappingInfo corresponds to which QName.
|
java.util.Map<java.lang.reflect.Type,javax.xml.namespace.QName> |
getTypeToSchemaType()
INTERNAL:
Get the map of which Type corresponds to which QName.
|
<T> T |
getValueByXPath(java.lang.Object object,
java.lang.String xPath,
NamespaceResolver namespaceResolver,
java.lang.Class<T> returnType)
Get a value from an object based on an XPath statement.
|
XMLContext |
getXMLContext()
Return the XMLContext associated with this JAXBContext.
|
javax.xml.stream.XMLInputFactory |
getXMLInputFactory() |
boolean |
hasSwaRef()
Returns true if any Object in this context contains a property annotated with an XmlAttachmentRef
annotation.
|
void |
initTypeToSchemaType()
INTERNAL:
Populate the map of which Type corresponds to which QName.
|
void |
refreshMetadata()
ADVANCED:
Refresh the underlying metadata based on the inputs that were
used to create the JAXBContext.
|
void |
setClassToGeneratedClasses(java.util.HashMap<java.lang.String,java.lang.Class> classToClass)
INTERNAL:
Set the map containing which Class (by name) corresponds to which generated class.
|
void |
setQNamesToDeclaredClasses(java.util.HashMap<javax.xml.namespace.QName,java.lang.Class> nameToDeclaredClasses)
INTERNAL:
Set the map of which QName corresponds to which declared class.
|
void |
setQNameToGeneratedClasses(java.util.HashMap<javax.xml.namespace.QName,java.lang.Class> qNameToClass)
INTERNAL:
Set the map containing which QName corresponds to which generated class.
|
void |
setValueByXPath(java.lang.Object object,
java.lang.String xPath,
NamespaceResolver namespaceResolver,
java.lang.Object value)
Set a value on an object based on an XPath statement.
|
void |
setXMLContext(XMLContext xmlContext) |
newInstance, newInstance, newInstance, newInstance, newInstance
protected static final ValidationEventHandler DEFAULT_VALIDATION_EVENT_HANDLER
protected JAXBContext.JAXBContextInput contextInput
protected volatile JAXBContext.JAXBContextState contextState
protected JAXBContext()
protected JAXBContext(JAXBContext.JAXBContextInput contextInput) throws JAXBException
JAXBException
public JAXBContext(XMLContext context)
public JAXBContext(XMLContext context, Generator generator, java.lang.reflect.Type[] boundTypes)
public JAXBContext(XMLContext context, Generator generator, TypeMappingInfo[] boundTypes)
public BeanValidationHelper getBeanValidationHelper()
public javax.xml.stream.XMLInputFactory getXMLInputFactory()
public void refreshMetadata() throws JAXBException
Refresh the underlying metadata based on the inputs that were used to create the JAXBContext. This is particularly useful when using the virtual property mappings. The refreshMetadata call could be made in the following way:
org.eclipse.persistence.jaxb.JAXBHelper.getJAXBContext(aJAXBContext).refreshMetadata();Note:
JAXBException
public XMLContext getXMLContext()
public void setXMLContext(XMLContext xmlContext)
public void generateSchema(SchemaOutputResolver outputResolver)
generateSchema
in class JAXBContext
outputResolver
- Class that decides where the schema file (of the given namespace URI) will be writtenpublic void generateJsonSchema(SchemaOutputResolver outputResolver, java.lang.Class rootClass)
public void generateSchema(SchemaOutputResolver outputResolver, java.util.Map<javax.xml.namespace.QName,java.lang.reflect.Type> additonalGlobalElements)
outputResolver
- Class that decides where the schema file (of the given namespace URI) will be writtenadditonalGlobalElements
- Map of additional global elements to be added to the generated XSD.
Note that if any QName in this map conflicts with another global element (for example from a TypeMappingInfo object)
then the element generated from this map will be the one that is present in the XSD.public JAXBMarshaller createMarshaller() throws JAXBException
createMarshaller
in class JAXBContext
JAXBException
- if an error was encountered while creating the
Marshaller objectpublic JAXBUnmarshaller createUnmarshaller() throws JAXBException
createUnmarshaller
in class JAXBContext
JAXBException
- if an error was encountered while creating the
Unmarshaller objectpublic JAXBValidator createValidator()
createValidator
in class JAXBContext
public JAXBBinder createBinder()
createBinder
in class JAXBContext
public <T> JAXBBinder createBinder(java.lang.Class<T> nodeClass)
createBinder
in class JAXBContext
nodeClass
- The DOM Node class to usepublic JAXBIntrospector createJAXBIntrospector()
createJAXBIntrospector
in class JAXBContext
public void setQNameToGeneratedClasses(java.util.HashMap<javax.xml.namespace.QName,java.lang.Class> qNameToClass)
public java.util.Map<java.lang.String,java.lang.Class> getClassToGeneratedClasses()
public void setClassToGeneratedClasses(java.util.HashMap<java.lang.String,java.lang.Class> classToClass)
public void applyORMMetadata(org.eclipse.persistence.internal.sessions.AbstractSession ormSession)
public java.util.Map<javax.xml.namespace.QName,java.lang.Class> getQNamesToDeclaredClasses()
public void setQNamesToDeclaredClasses(java.util.HashMap<javax.xml.namespace.QName,java.lang.Class> nameToDeclaredClasses)
public java.util.Map<java.lang.String,java.lang.Class> getArrayClassesToGeneratedClasses()
public java.util.Map<java.lang.reflect.Type,java.lang.Class> getCollectionClassesToGeneratedClasses()
public void initTypeToSchemaType()
public java.util.Map<TypeMappingInfo,javax.xml.namespace.QName> getTypeMappingInfoToSchemaType()
public java.util.Map<java.lang.reflect.Type,javax.xml.namespace.QName> getTypeToSchemaType()
public <T> T getValueByXPath(java.lang.Object object, java.lang.String xPath, NamespaceResolver namespaceResolver, java.lang.Class<T> returnType)
T
- The return type of this method corresponds to the returnType parameter.object
- The XPath will be executed relative to this object.xPath
- The XPath statement.namespaceResolver
- A NamespaceResolver containing the prefix/URI pairings from the XPath statement.returnType
- The return type.public void setValueByXPath(java.lang.Object object, java.lang.String xPath, NamespaceResolver namespaceResolver, java.lang.Object value)
object
- The XPath will be executed relative to this object.xPath
- The XPath statement.namespaceResolver
- A NamespaceResolver containing the prefix/URI pairings from the XPath statement.value
- The value to be set.public java.lang.Object createByQualifiedName(java.lang.String namespace, java.lang.String typeName, boolean isGlobalType)
namespace
- The namespace of the complex type to create a new Java instance of.typeName
- The XML type name to create a new Java instance of.isGlobalType
- True if the object to be created represents a global type, false if it
represents a global element.public <T> T createByXPath(java.lang.Object parentObject, java.lang.String xPath, NamespaceResolver namespaceResolver, java.lang.Class<T> returnType)
T
- The return type of this method corresponds to the returnType parameter.parentObject
- The XPath will be executed relative to this object.xPath
- The XPath statement.namespaceResolver
- A NamespaceResolver containing the prefix/URI pairings from the XPath statement.returnType
- The return type.public ObjectGraph createObjectGraph(java.lang.Class type)
public ObjectGraph createObjectGraph(java.lang.String typeName)
protected JAXBElement createJAXBElementFromXMLRoot(org.eclipse.persistence.internal.oxm.Root xmlRoot, java.lang.Class declaredType)
protected JAXBElement createJAXBElement(javax.xml.namespace.QName qname, java.lang.Class theClass, java.lang.Object value)
public boolean hasSwaRef()