All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.sentinel.base.config.configurer.SentinelXmlConfigurer Maven / Gradle / Ivy

package org.zodiac.sentinel.base.config.configurer;

import org.zodiac.sdk.toolkit.util.ObjectUtil;
import org.zodiac.sentinel.base.datasource.converter.XmlSentinelDataSourceConverter;

import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule;
import com.alibaba.csp.sentinel.slots.system.SystemRule;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;

public class SentinelXmlConfigurer {

    private XmlMapper xmlMapper;

    public SentinelXmlConfigurer() {
        this(null);
    }

    public SentinelXmlConfigurer(XmlMapper xmlMapper) {
        this.xmlMapper = ObjectUtil.defaultIfNull(xmlMapper, new XmlMapper());
        this.xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    }

    public XmlSentinelDataSourceConverter xmlFlowConverter() {
        return new XmlSentinelDataSourceConverter(xmlMapper, FlowRule.class);
    }

    public XmlSentinelDataSourceConverter xmlDegradeConverter() {
        return new XmlSentinelDataSourceConverter(xmlMapper, DegradeRule.class);
    }

    public XmlSentinelDataSourceConverter xmlSystemConverter() {
        return new XmlSentinelDataSourceConverter(xmlMapper, SystemRule.class);
    }

    public XmlSentinelDataSourceConverter xmlAuthorityConverter() {
        return new XmlSentinelDataSourceConverter(xmlMapper, AuthorityRule.class);
    }

    public XmlSentinelDataSourceConverter xmlParamFlowConverter() {
        return new XmlSentinelDataSourceConverter(xmlMapper, ParamFlowRule.class);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy