Interface JaxbContextCache

  • All Known Implementing Classes:
    JaxbContextCacheImpl

    public interface JaxbContextCache
    Cache for JAXBContext instances per message type.

    It is used to achieve better performance when marshalling or unmarshalling MX messages.

    Since:
    9.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      jakarta.xml.bind.JAXBContext get​(java.lang.Class messageClass, java.lang.Class<?>[] classes)
      Returns the cached context to marshall or unmarshall a message.
    • Method Detail

      • get

        jakarta.xml.bind.JAXBContext get​(java.lang.Class messageClass,
                                         java.lang.Class<?>[] classes)
                                  throws jakarta.xml.bind.JAXBException,
                                         java.util.concurrent.ExecutionException
        Returns the cached context to marshall or unmarshall a message.

        Cache implementations should be per message type, so the actual message class name could be used as key.

        Regarding the JAXBContext creation, notice the namespace or package cannot be used because all dictionary classes in the model share the same "dic" package.

        The classes parameter is used to avoid reflection and improve performance. Can be used when the set of jaxb generated classes for a specific model is known. This is the case for MX messages, where the set of classes is available in the AbstractMX subclass. Thus when the classes array is received, the context can be created directly with: JAXBContext.newInstance(classes). And the messageClass can be used as key.

        When the classes parameter is not available, the context can be created with: JAXBContext.newInstance(messageClass).

        Parameters:
        messageClass - class of the message to be read or written, cannot be null
        classes - comprehensive list of classes for the context, null or empty to create a context with the messageClass
        Returns:
        cached context for the message type
        Throws:
        jakarta.xml.bind.JAXBException
        java.util.concurrent.ExecutionException