|
|
|
@ -16,6 +16,25 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.cloud.alibaba.sentinel.custom;
|
|
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.cloud.alibaba.sentinel.SentinelProperties;
|
|
|
|
|
import org.springframework.cloud.alibaba.sentinel.datasource.converter.JsonConverter;
|
|
|
|
|
import org.springframework.cloud.alibaba.sentinel.datasource.converter.XmlConverter;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.RequestOriginParser;
|
|
|
|
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
|
|
|
|
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner;
|
|
|
|
@ -32,25 +51,9 @@ import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule;
|
|
|
|
|
import com.alibaba.csp.sentinel.slots.system.SystemRule;
|
|
|
|
|
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.util.AppNameUtil;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.cloud.alibaba.sentinel.SentinelProperties;
|
|
|
|
|
import org.springframework.cloud.alibaba.sentinel.datasource.converter.JsonConverter;
|
|
|
|
|
import org.springframework.cloud.alibaba.sentinel.datasource.converter.XmlConverter;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author xiaojing
|
|
|
|
@ -159,6 +162,7 @@ public class SentinelAutoConfiguration {
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnMissingBean
|
|
|
|
|
@ConditionalOnClass(name = "org.springframework.web.client.RestTemplate")
|
|
|
|
|
@ConditionalOnProperty(name = "resttemplate.sentinel.enabled", havingValue = "true", matchIfMissing = true)
|
|
|
|
|
public SentinelBeanPostProcessor sentinelBeanPostProcessor(
|
|
|
|
|
ApplicationContext applicationContext) {
|
|
|
|
|
return new SentinelBeanPostProcessor(applicationContext);
|
|
|
|
|