Class JaxbContextCacheImpl
- java.lang.Object
-
- com.prowidesoftware.swift.model.mx.JaxbContextCacheImpl
-
- All Implemented Interfaces:
JaxbContextCache
public class JaxbContextCacheImpl extends java.lang.Object implements JaxbContextCache
Simple cache based onConcurrentHashMapwithout eviction. This implementation is aimed to avoid additional third party dependencies. For a more robust solution You can easily implement your own cache with Guava, Ecache, Caffeine or any other cache library. See some code references in theJaxbContextCacheinterface.- Since:
- 9.0
-
-
Constructor Summary
Constructors Constructor Description JaxbContextCacheImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Drops all cached contextsjakarta.xml.bind.JAXBContextclear(java.lang.Class clazz)Drops the cached context for the specific MX implementation classjakarta.xml.bind.JAXBContextget(java.lang.Class messageClass, java.lang.Class<?>[] classes)Gets a context from the static cache.intsize()
-
-
-
Method Detail
-
get
public jakarta.xml.bind.JAXBContext get(java.lang.Class messageClass, java.lang.Class<?>[] classes) throws jakarta.xml.bind.JAXBExceptionGets a context from the static cache. If the context for the specific message type is not present, a new context is initialized with the given classes or messageClass and stored in the cache.- Specified by:
getin interfaceJaxbContextCache- Parameters:
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 messageClass- Returns:
- the cached or created context for the specific message type
- Throws:
jakarta.xml.bind.JAXBException
-
clear
public void clear()
Drops all cached contexts
-
clear
public jakarta.xml.bind.JAXBContext clear(java.lang.Class clazz)
Drops the cached context for the specific MX implementation class- Returns:
- the remove context, if it was present, or null otherwise
-
size
public int size()
- Returns:
- the number of cached contexts
-
-