se.hiq.oss.spring.nats.config.xmlns.parser.NatsGsonBeanDefinitionParser Maven / Gradle / Ivy
package se.hiq.oss.spring.nats.config.xmlns.parser;
import java.util.Optional;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
import static se.hiq.oss.spring.nats.config.NatsBeans.SER_DE_FACTORY;
import se.hiq.oss.spring.nats.message.serde.json.NatsGsonMessageSerDeFactory;
public class NatsGsonBeanDefinitionParser extends AbstractNatsBeanDefinitionParser {
@Override
protected Class> getBeanClass(Element element) {
return NatsGsonMessageSerDeFactory.class;
}
@Override
protected void doParse(Element element, ParserContext pc,
BeanDefinitionBuilder bean) {
element.setAttribute(ID_ATTRIBUTE, SER_DE_FACTORY);
element.setAttribute(NAME_ATTRIBUTE, SER_DE_FACTORY);
Optional objectValidator = getAttributeValue(element, "object-validator");
objectValidator.ifPresent(v -> bean.addPropertyReference("validator", v));
Optional gsonBean = getAttributeValue(element, "gson");
gsonBean.ifPresent(n -> bean.addConstructorArgReference(n));
createBeans(pc, element, SER_DE_FACTORY);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy