io.quarkus.resteasy.reactive.jaxb.runtime.JAXBContextContextResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-rest-jaxb Show documentation
Show all versions of quarkus-rest-jaxb Show documentation
JAXB serialization support for Quarkus REST. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.
package io.quarkus.resteasy.reactive.jaxb.runtime;
import java.util.concurrent.ConcurrentHashMap;
import jakarta.enterprise.inject.Instance;
import jakarta.ws.rs.ext.ContextResolver;
import jakarta.xml.bind.JAXBContext;
import io.quarkus.jaxb.runtime.JaxbContextCustomizer;
import io.quarkus.jaxb.runtime.JaxbContextProducer;
public class JAXBContextContextResolver implements ContextResolver {
private final ConcurrentHashMap, JAXBContext> cache = new ConcurrentHashMap<>();
private final Instance customizers;
private final JaxbContextProducer jaxbContextProducer;
public JAXBContextContextResolver(Instance customizers,
JaxbContextProducer jaxbContextProducer) {
this.customizers = customizers;
this.jaxbContextProducer = jaxbContextProducer;
}
@Override
public JAXBContext getContext(Class> clazz) {
JAXBContext jaxbContext = cache.get(clazz);
if (jaxbContext == null) {
jaxbContext = jaxbContextProducer.createJAXBContext(customizers, clazz);
cache.put(clazz, jaxbContext);
}
return jaxbContext;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy