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 onConcurrentHashMap
without 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 theJaxbContextCache
interface.- Since:
- 9.0
-
-
Constructor Summary
Constructors Constructor Description JaxbContextCacheImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Drops all cached contextsjakarta.xml.bind.JAXBContext
clear(java.lang.Class clazz)
Drops the cached context for the specific MX implementation classjakarta.xml.bind.JAXBContext
get(java.lang.Class messageClass, java.lang.Class<?>[] classes)
Gets a context from the static cache.int
size()
-
-
-
Method Detail
-
get
public jakarta.xml.bind.JAXBContext get(java.lang.Class messageClass, java.lang.Class<?>[] classes) throws jakarta.xml.bind.JAXBException
Gets 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:
get
in 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
-
-