Class ExtendedUnmarshaller<R,I>
java.lang.Object
com.foursoft.harness.navext.runtime.ExtendedUnmarshaller<R,I>
- Type Parameters:
R- Type of the root element to unmarshall.I- Type of elements that are identifiable.
Provides extended unmarshalling capabilities for a JAXB model. Capabilities
are:
- Initializing of parent associations and back references (see
XmlParentandXmlBackReference). - Creation of an
IdLookupProviderto provide a fast id-based index for the unmarshalled model. - Registration and execution of custom
ModelPostProcessor.
Unmarshaller.
The ExtendedUnmarshaller is required in order to correctly integrate
the two phase model post processing (see ModelPostProcessor into the
unmarshalling process.
- Author:
- becker
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.xml.bind.UnmarshallerProvides access to the internal jax-b unmarshaller for further configuration.protected XMLReaderObtains a configured XMLReader.unmarshall(InputStream resource) Turns on the capability to initialize parent associations and backreferences.withCustomPostProcessor(ModelPostProcessor modelPostProcessor) Adds a customModelPostProcessorto the deserialization.withEventLogging(Consumer<jakarta.xml.bind.ValidationEvent> eventConsumer) The jaxb unmarshaller has an event handler which is intercepted to provide the event for the consumer.Defines an id mapper to create aIdLookupProviderduring the unmarshalling process.
-
Constructor Details
-
ExtendedUnmarshaller
- Throws:
jakarta.xml.bind.JAXBException
-
-
Method Details
-
withBackReferences
Turns on the capability to initialize parent associations and backreferences.- Returns:
- Returns this for method chaining / fluent initialization.
-
withEventLogging
public ExtendedUnmarshaller<R,I> withEventLogging(Consumer<jakarta.xml.bind.ValidationEvent> eventConsumer) throws jakarta.xml.bind.JAXBException The jaxb unmarshaller has an event handler which is intercepted to provide the event for the consumer. This will reset the handler first to the default handler, and then add the given consumer to it- Parameters:
eventConsumer- the consumer for the jaxb validation event- Returns:
- this for fluent API
- Throws:
jakarta.xml.bind.JAXBException- if the unmarshalling goes wrong
-
withIdMapper
public ExtendedUnmarshaller<R,I> withIdMapper(Class<I> classOfIdentifiableElements, Function<I, String> idMapper) Defines an id mapper to create aIdLookupProviderduring the unmarshalling process.If no id mapper is defined, the resulting
JaxbModelwill have noIdLookupProviderinitialized.If more than one id mapper is registered, all are processed and the result is merged into one
IdLookupProvider. This allows a common the handling of all classes during the unmarshalling, even if the do not have a shared superclass or interface.- Parameters:
classOfIdentifiableElements- the class of the identifiable elementidMapper- the mapper function to get the id of each element- Returns:
- this for fluent API
-
unmarshall
- Throws:
jakarta.xml.bind.JAXBException
-
getUnmarshaller
public jakarta.xml.bind.Unmarshaller getUnmarshaller()Provides access to the internal jax-b unmarshaller for further configuration. Use with caution.- Returns:
- the internal jax-b unmarshaller
-
getXMLReader
Obtains a configured XMLReader.Unmarshalleris not re-entrant, so we will only use one instance of XMLReader.Overriden in order to fix potential security issue. See jakarta.xml.bind.helpers.AbstractUnmarshallerImpl#getXMLReader()
- Throws:
jakarta.xml.bind.JAXBException
-