- java.lang.Object
-
- jakarta.xml.bind.JAXBContext
-
- org.glassfish.jaxb.runtime.api.JAXBRIContext
-
- org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl
-
public final class JAXBContextImpl extends JAXBRIContext
This class provides the implementation of JAXBContext.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJAXBContextImpl.JAXBContextBuilder
-
Field Summary
Fields Modifier and Type Field Description booleanallNillableBooleanbackupWithParentNamespaceIf true, despite the specification, unmarshall child element with parent namespace, if child namespace is not specified.protected Map<RuntimeTypeInfo,JaxBeanInfo>beanInfosAll createdJaxBeanInfos.protected booleanc14nSupporttrue to reorder attributes lexicographically in preparation of the c14n support.booleandisableSecurityProcessingDisable security processing.booleanfastBootIf true, we aim for fasterJAXBContextinstantiation performance, instead of going after efficient sustained unmarshalling/marshalling performance.booleanimprovedXsiTypeHandlingImproved xsi type handling.Pool<jakarta.xml.bind.Marshaller>marshallerPoolPool ofMarshallers.intmaxErrorsCountThe maximum number of errors unmarshall operation reports.NameBuildernameBuilderUsed to assign indices to known names in this grammar.NameListnameListKeeps the list of known names.booleanretainPropertyInfoStore properties, so that they can be recovered in the run (is here because of JSON encoding of Jersey).booleansupressAccessorWarningsSuppress reflection accessor warnings.Pool<jakarta.xml.bind.Unmarshaller>unmarshallerPoolbooleanxmlAccessorFactorySupportFlag that user has provided a custom AccessorFactory for JAXB to use-
Fields inherited from class org.glassfish.jaxb.runtime.api.JAXBRIContext
ANNOTATION_READER, BACKUP_WITH_PARENT_NAMESPACE, CANONICALIZATION_SUPPORT, DEFAULT_NAMESPACE_REMAP, DISABLE_XML_SECURITY, ENABLE_XOP, IMPROVED_XSI_TYPE_HANDLING, MAX_ERRORS, RETAIN_REFERENCE_TO_INFO, SUBCLASS_REPLACEMENTS, SUPRESS_ACCESSOR_WARNINGS, TREAT_EVERYTHING_NILLABLE, TYPE_REFERENCES, XMLACCESSORFACTORY_SUPPORT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JAXBContextImplcreateAugmented(Class<?> clazz)Creates aJAXBContextImplthat includes the specified additional classes.jakarta.xml.bind.Binder<Node>createBinder()<T> jakarta.xml.bind.Binder<T>createBinder(Class<T> domType)BridgecreateBridge(TypeReference ref)Creates a mini-marshaller/unmarshaller that can process aTypeReference.BridgeContextcreateBridgeContext()Creates a newBridgeContextinstance.jakarta.xml.bind.JAXBIntrospectorcreateJAXBIntrospector()MarshallerImplcreateMarshaller()static TransformerHandlercreateTransformerHandler(boolean disableSecureProcessing)Creates a new identity transformer.UnmarshallerImplcreateUnmarshaller()jakarta.xml.bind.ValidatorcreateValidator()voidgenerateEpisode(Result output)Generates the episode file that represents the binding known to thisJAXBContext, so that XJC can later do separate compilation.voidgenerateSchema(jakarta.xml.bind.SchemaOutputResolver outputResolver)Generates the schema documents from the model.<T> JaxBeanInfo<T>getBeanInfo(Class<T> clazz)Gets theJaxBeanInfoobject that can handle the given JAXB-bound class.<T> JaxBeanInfo<T>getBeanInfo(Class<T> clazz, boolean fatal)Gets theJaxBeanInfoobject that can handle the given JAXB-bound class.JaxBeanInfogetBeanInfo(Object o)Gets theJaxBeanInfoobject that can handle the given JAXB-bound object.JaxBeanInfogetBeanInfo(Object o, boolean fatal)Gets theJaxBeanInfoobject that can handle the given JAXB-bound object.StringgetBuildId()Gets the build information of the JAXB runtime.ElementBeanInfoImplgetElement(Class scope, QName name)QNamegetElementName(Class o)Allows to retrieve the element name based on Class.QNamegetElementName(Object o)If the given object is bound to an element in XML by JAXB, returns the element name.RawAccessorgetElementPropertyAccessor(Class wrapperBean, String nsUri, String localName)Gets aRawAccessorfor the specified element property of the specified wrapper bean class.JaxBeanInfogetGlobalType(QName name)Gets theJaxBeanInfofor the given named XML Schema type.List<String>getKnownNamespaceURIs()Gets the namespace URIs statically known to thisJAXBContext.StringgetNearestTypeName(QName name)Finds a type name that this context recognizes which is "closest" to the given type name.intgetNumberOfAttributeNames()intgetNumberOfElementNames()intgetNumberOfLocalNames()protected JaxBeanInfogetOrCreate(RuntimeArrayInfo ai)protected ClassBeanInfoImplgetOrCreate(RuntimeClassInfo ci)protected JaxBeanInfogetOrCreate(RuntimeEnumLeafInfo eli)JaxBeanInfogetOrCreate(RuntimeTypeInfo e)RuntimeTypeInfoSetgetRuntimeTypeInfoSet()Allows you to access the runtime model information of the JAXB XML/Java binding.RuntimeTypeInfoSetgetTypeInfoSet()Creates aRuntimeTypeInfoSet.QNamegetTypeName(TypeReference tr)Returns the name of the XML Type bound to the specified Java type.Encoded[]getUTF8NameTable()Set<QName>getValidRootNames()Returns the set of valid root tag names.StringgetXMIMEContentType(Object o)Gets the value of the xmime:contentType attribute on the given object, or null if for some reason it couldn't be found, including any error.Set<jakarta.xml.bind.annotation.XmlNs>getXmlNsSet()Returns declared XmlNs annotations (from package-level annotation XmlSchemabooleanhasSwaRef()True if this JAXBContext hasXmlAttachmentRef.LoaderselectRootLoader(UnmarshallingContext.State state, TagName tag)Based on the tag name, determine what object to unmarshal, and then set a new object and its loader to the current unmarshaller state.StringtoString()-
Methods inherited from class org.glassfish.jaxb.runtime.api.JAXBRIContext
getBaseType, mangleNameToClassName, mangleNameToPropertyName, mangleNameToVariableName, newInstance, newInstance, newInstance
-
-
-
-
Field Detail
-
beanInfos
protected Map<RuntimeTypeInfo,JaxBeanInfo> beanInfos
All createdJaxBeanInfos. Updated from eachJaxBeanInfos constructors to avoid infinite recursion for a cyclic reference.This map is only used while the
JAXBContextImplis built and set to null to avoid keeping references too long.
-
marshallerPool
public final Pool<jakarta.xml.bind.Marshaller> marshallerPool
Pool ofMarshallers.
-
unmarshallerPool
public final Pool<jakarta.xml.bind.Unmarshaller> unmarshallerPool
-
nameBuilder
public NameBuilder nameBuilder
Used to assign indices to known names in this grammar. Reset to null once the build phase is completed.
-
nameList
public final NameList nameList
Keeps the list of known names. This field is set once the build pahse is completed.
-
c14nSupport
protected final boolean c14nSupport
true to reorder attributes lexicographically in preparation of the c14n support.
-
xmlAccessorFactorySupport
public final boolean xmlAccessorFactorySupport
Flag that user has provided a custom AccessorFactory for JAXB to use
-
allNillable
public final boolean allNillable
- See Also:
JAXBRIContext.TREAT_EVERYTHING_NILLABLE
-
retainPropertyInfo
public final boolean retainPropertyInfo
Store properties, so that they can be recovered in the run (is here because of JSON encoding of Jersey).
-
supressAccessorWarnings
public final boolean supressAccessorWarnings
Suppress reflection accessor warnings.
-
improvedXsiTypeHandling
public final boolean improvedXsiTypeHandling
Improved xsi type handling.
-
disableSecurityProcessing
public final boolean disableSecurityProcessing
Disable security processing.
-
fastBoot
public final boolean fastBoot
If true, we aim for fasterJAXBContextinstantiation performance, instead of going after efficient sustained unmarshalling/marshalling performance.- Since:
- 2.0.4
-
backupWithParentNamespace
public Boolean backupWithParentNamespace
If true, despite the specification, unmarshall child element with parent namespace, if child namespace is not specified. The default value is null for Systemorg.glassfish.jaxb.backupWithParentNamespaceproperty to be used, and false is assumed if it's not set either. Boolean- Since:
- 2.3.0
-
maxErrorsCount
public final int maxErrorsCount
The maximum number of errors unmarshall operation reports. Use negative value to report all errors. The default value is 10.- Since:
- 2.3.3
-
-
Method Detail
-
getXmlNsSet
public Set<jakarta.xml.bind.annotation.XmlNs> getXmlNsSet()
Returns declared XmlNs annotations (from package-level annotation XmlSchema- Returns:
- set of all present XmlNs annotations
-
hasSwaRef
public boolean hasSwaRef()
True if this JAXBContext hasXmlAttachmentRef.- Specified by:
hasSwaRefin classJAXBRIContext
-
getRuntimeTypeInfoSet
public RuntimeTypeInfoSet getRuntimeTypeInfoSet()
Description copied from class:JAXBRIContextAllows you to access the runtime model information of the JAXB XML/Java binding.This is useful for doing a deeper integration with the JAXB RI. For more information about the model, see https://jaxb2-reflection.dev.java.net/
- Specified by:
getRuntimeTypeInfoSetin classJAXBRIContext
-
getTypeInfoSet
public RuntimeTypeInfoSet getTypeInfoSet() throws IllegalAnnotationsException
Creates aRuntimeTypeInfoSet.- Throws:
IllegalAnnotationsException
-
getElement
public ElementBeanInfoImpl getElement(Class scope, QName name)
-
getOrCreate
protected JaxBeanInfo getOrCreate(RuntimeEnumLeafInfo eli)
-
getOrCreate
protected ClassBeanInfoImpl getOrCreate(RuntimeClassInfo ci)
-
getOrCreate
protected JaxBeanInfo getOrCreate(RuntimeArrayInfo ai)
-
getOrCreate
public JaxBeanInfo getOrCreate(RuntimeTypeInfo e)
-
getBeanInfo
public final JaxBeanInfo getBeanInfo(Object o)
Gets theJaxBeanInfoobject that can handle the given JAXB-bound object.This method traverses the base classes of the given object.
- Returns:
- null
if
cisn't a JAXB-bound class andfatal==false.
-
getBeanInfo
public final JaxBeanInfo getBeanInfo(Object o, boolean fatal) throws jakarta.xml.bind.JAXBException
Gets theJaxBeanInfoobject that can handle the given JAXB-bound object.- Parameters:
fatal- if true, the failure to look up will throw an exception. Otherwise it will just return null.- Throws:
jakarta.xml.bind.JAXBException
-
getBeanInfo
public final <T> JaxBeanInfo<T> getBeanInfo(Class<T> clazz)
Gets theJaxBeanInfoobject that can handle the given JAXB-bound class.This method doesn't look for base classes.
- Returns:
- null
if
cisn't a JAXB-bound class andfatal==false.
-
getBeanInfo
public final <T> JaxBeanInfo<T> getBeanInfo(Class<T> clazz, boolean fatal) throws jakarta.xml.bind.JAXBException
Gets theJaxBeanInfoobject that can handle the given JAXB-bound class.- Parameters:
fatal- if true, the failure to look up will throw an exception. Otherwise it will just return null.- Throws:
jakarta.xml.bind.JAXBException
-
selectRootLoader
public final Loader selectRootLoader(UnmarshallingContext.State state, TagName tag)
Based on the tag name, determine what object to unmarshal, and then set a new object and its loader to the current unmarshaller state.- Returns:
- null if the given name pair is not recognized.
-
getGlobalType
public JaxBeanInfo getGlobalType(QName name)
Gets theJaxBeanInfofor the given named XML Schema type.- Returns:
- null if the type name is not recognized. For schema languages other than XML Schema, this method always returns null.
-
getNearestTypeName
public String getNearestTypeName(QName name)
Finds a type name that this context recognizes which is "closest" to the given type name.This method is used for error recovery.
-
getValidRootNames
public Set<QName> getValidRootNames()
Returns the set of valid root tag names. For diagnostic use.
-
getUTF8NameTable
public Encoded[] getUTF8NameTable()
-
getNumberOfLocalNames
public int getNumberOfLocalNames()
-
getNumberOfElementNames
public int getNumberOfElementNames()
-
getNumberOfAttributeNames
public int getNumberOfAttributeNames()
-
createTransformerHandler
public static TransformerHandler createTransformerHandler(boolean disableSecureProcessing)
Creates a new identity transformer.
-
createMarshaller
public MarshallerImpl createMarshaller()
- Specified by:
createMarshallerin classjakarta.xml.bind.JAXBContext
-
createUnmarshaller
public UnmarshallerImpl createUnmarshaller()
- Specified by:
createUnmarshallerin classjakarta.xml.bind.JAXBContext
-
createValidator
public jakarta.xml.bind.Validator createValidator()
- Specified by:
createValidatorin classjakarta.xml.bind.JAXBContext
-
createJAXBIntrospector
public jakarta.xml.bind.JAXBIntrospector createJAXBIntrospector()
- Overrides:
createJAXBIntrospectorin classjakarta.xml.bind.JAXBContext
-
generateEpisode
public void generateEpisode(Result output)
Description copied from class:JAXBRIContextGenerates the episode file that represents the binding known to thisJAXBContext, so that XJC can later do separate compilation.Episode file is really just a JAXB customization file, except that currently we use the RI-specific SCD to refer to schema components.
- Specified by:
generateEpisodein classJAXBRIContext- Parameters:
output- This receives the generated episode file.
-
generateSchema
public void generateSchema(jakarta.xml.bind.SchemaOutputResolver outputResolver) throws IOExceptionDescription copied from class:JAXBRIContextGenerates the schema documents from the model.The caller can use the additionalElementDecls parameter to add element declarations to the generate schema. For example, if the JAX-RPC passes in the following entry:
{foo}bar -> DeclaredType for java.lang.Stringthen JAXB generates the following element declaration (in the schema document for the namespace "foo")"<xs:element name="bar" type="xs:string" />This can be used for generating schema components necessary for WSDL.- Specified by:
generateSchemain classJAXBRIContext- Parameters:
outputResolver- this object controls the output to which schemas will be sent.- Throws:
IOException- ifSchemaOutputResolverthrows anIOException.
-
getTypeName
public QName getTypeName(TypeReference tr)
Description copied from class:JAXBRIContextReturns the name of the XML Type bound to the specified Java type.- Specified by:
getTypeNamein classJAXBRIContext- Parameters:
tr- must not be null. This must be one of theTypeReferences specified in theJAXBRIContext.newInstance(java.lang.Class[], java.util.Collection<org.glassfish.jaxb.runtime.api.TypeReference>, java.util.Map<java.lang.Class, java.lang.Class>, java.lang.String, boolean, org.glassfish.jaxb.runtime.v2.model.annotation.RuntimeAnnotationReader)method.- Returns:
- null if the referenced type is an anonymous and therefore doesn't have a name.
-
createBinder
public <T> jakarta.xml.bind.Binder<T> createBinder(Class<T> domType)
- Overrides:
createBinderin classjakarta.xml.bind.JAXBContext
-
createBinder
public jakarta.xml.bind.Binder<Node> createBinder()
- Overrides:
createBinderin classjakarta.xml.bind.JAXBContext
-
getElementName
public QName getElementName(Object o) throws jakarta.xml.bind.JAXBException
Description copied from class:JAXBRIContextIf the given object is bound to an element in XML by JAXB, returns the element name.- Specified by:
getElementNamein classJAXBRIContext- Returns:
- null if the object is not bound to an element.
- Throws:
jakarta.xml.bind.JAXBException- if the object is not known to this context.
-
getElementName
public QName getElementName(Class o) throws jakarta.xml.bind.JAXBException
Description copied from class:JAXBRIContextAllows to retrieve the element name based on Class.- Specified by:
getElementNamein classJAXBRIContext- Returns:
- Throws:
jakarta.xml.bind.JAXBException
-
createBridge
public Bridge createBridge(TypeReference ref)
Description copied from class:JAXBRIContextCreates a mini-marshaller/unmarshaller that can process aTypeReference.- Specified by:
createBridgein classJAXBRIContext- Returns:
- null if the specified reference is not given to
JAXBRIContext.newInstance(java.lang.Class[], java.util.Collection<org.glassfish.jaxb.runtime.api.TypeReference>, java.util.Map<java.lang.Class, java.lang.Class>, java.lang.String, boolean, org.glassfish.jaxb.runtime.v2.model.annotation.RuntimeAnnotationReader).
-
createBridgeContext
@NotNull public BridgeContext createBridgeContext()
Description copied from class:JAXBRIContextCreates a newBridgeContextinstance.- Specified by:
createBridgeContextin classJAXBRIContext- Returns:
- always a valid non-null instance.
-
getElementPropertyAccessor
public RawAccessor getElementPropertyAccessor(Class wrapperBean, String nsUri, String localName) throws jakarta.xml.bind.JAXBException
Description copied from class:JAXBRIContextGets aRawAccessorfor the specified element property of the specified wrapper bean class.This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.) In the said mode, a wrapper bean is supposed to only have properties that match elements, and for each element that appear in the content model there's one property.
Therefore, this method takes a wrapper bean and a tag name that identifies a property on the given wrapper bean, then returns a
RawAccessorthat allows the caller to set/get a value from the property of the bean.This method is not designed for a performance. The caller is expected to cache the result.
- Specified by:
getElementPropertyAccessorin classJAXBRIContext- Returns:
- always return non-null valid accessor object.
- Throws:
jakarta.xml.bind.JAXBException- if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property of the given name.
-
getKnownNamespaceURIs
public List<String> getKnownNamespaceURIs()
Description copied from class:JAXBRIContextGets the namespace URIs statically known to thisJAXBContext.When JAXB is used to marshal into sub-trees, it declares these namespace URIs at each top-level element that it marshals. To avoid repeated namespace declarations at sub-elements, the application may declare those namespaces at a higher level.
- Specified by:
getKnownNamespaceURIsin classJAXBRIContext- Returns:
- always non-null.
-
getBuildId
public String getBuildId()
Description copied from class:JAXBRIContextGets the build information of the JAXB runtime.- Specified by:
getBuildIdin classJAXBRIContext- Returns:
- may be null, if the runtime is loaded by a class loader that doesn't support the access to the manifest informatino.
-
getXMIMEContentType
public String getXMIMEContentType(Object o)
Gets the value of the xmime:contentType attribute on the given object, or null if for some reason it couldn't be found, including any error.
-
createAugmented
public JAXBContextImpl createAugmented(Class<?> clazz) throws jakarta.xml.bind.JAXBException
Creates aJAXBContextImplthat includes the specified additional classes.- Throws:
jakarta.xml.bind.JAXBException
-
-