public enum JaxbContextLoader extends java.lang.Enum<JaxbContextLoader>
JaxbContextCache used when marshalling or unmarshalling MX messages.
This class is just a holder for the currently set cache. It is invoked in the static parse and write calls of the MX message model classes.
By default the loader will use no cache at all, creating new contexts for each parse or write call. Jaxb marshalling and unmarshalling is known to be a resource intensive task, so if you need to parse large burst of messages it is highly recommended that you set a proper cache here.
A basic cache implementation is provided in the JaxbContextCacheImpl class. This implementation uses
a simple static Map with no eviction. It is aimed to provide something out-ot-the-box without adding additional
third party libraries. You can easily inject your own cache implementation based on Guava, Ecache, Caffeine or any
other cache implementation of choice. See some code references in the JaxbContextCache interface.
| Enum Constant and Description |
|---|
INSTANCE |
| Modifier and Type | Method and Description |
|---|---|
javax.xml.bind.JAXBContext |
get(AbstractMX mx)
Gets a context from the static cache.
|
javax.xml.bind.JAXBContext |
get(java.lang.Class messageClass,
java.lang.Class<?>[] classes)
Gets a context from the static cache.
|
JaxbContextCache |
getCacheImpl()
Currently set cache implementation
|
void |
setCacheImpl(JaxbContextCache cacheImpl)
Sets a new cache implementation
|
void |
setNoCache()
Sets the current cache implementation to null, meaning for all subsequent calls new context will always be
created without any caching.
|
static JaxbContextLoader |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static JaxbContextLoader[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final JaxbContextLoader INSTANCE
public static JaxbContextLoader[] values()
for (JaxbContextLoader c : JaxbContextLoader.values()) System.out.println(c);
public static JaxbContextLoader valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic javax.xml.bind.JAXBContext get(AbstractMX mx) throws javax.xml.bind.JAXBException, java.util.concurrent.ExecutionException
mx - an MX message instancejavax.xml.bind.JAXBExceptionjava.util.concurrent.ExecutionExceptionpublic javax.xml.bind.JAXBContext get(java.lang.Class messageClass,
java.lang.Class<?>[] classes)
throws javax.xml.bind.JAXBException,
java.util.concurrent.ExecutionException
messageClass - class of the message to be read or writtenclasses - comprehensive list of classes for the context, null or empty to create a context with the messageClassjavax.xml.bind.JAXBExceptionjava.util.concurrent.ExecutionExceptionpublic JaxbContextCache getCacheImpl()
public void setCacheImpl(JaxbContextCache cacheImpl)
cacheImpl - cache implementation to setpublic void setNoCache()