1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

修改代码风格为eclipse风格

This commit is contained in:
xiejiashuai 2018-09-27 10:08:23 +08:00
parent 156404554e
commit 03a64885d4
3 changed files with 309 additions and 290 deletions

View File

@ -16,12 +16,12 @@
package org.springframework.cloud.alibaba.sentinel; package org.springframework.cloud.alibaba.sentinel;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import java.util.List;
/** /**
* @author xiaojing * @author xiaojing
* @author hengyunabc * @author hengyunabc
@ -30,7 +30,6 @@ import java.util.List;
@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX) @ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
public class SentinelProperties { public class SentinelProperties {
/** /**
* 是否提前初始化心跳连接 * 是否提前初始化心跳连接
*/ */
@ -207,7 +206,8 @@ public class SentinelProperties {
private String port = "8721"; private String port = "8721";
/** /**
* Sentinel dashboard address, won't try to connect dashboard when address is empty * Sentinel dashboard address, won't try to connect dashboard when address is
* empty
*/ */
private String dashboard = ""; private String dashboard = "";

View File

@ -16,7 +16,11 @@
package org.springframework.cloud.alibaba.sentinel; package org.springframework.cloud.alibaba.sentinel;
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter; import java.util.ArrayList;
import java.util.List;
import javax.servlet.Filter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -27,9 +31,7 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.servlet.Filter; import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author xiaojing * @author xiaojing

View File

@ -16,17 +16,10 @@
package org.springframework.cloud.alibaba.sentinel.custom; package org.springframework.cloud.alibaba.sentinel.custom;
import com.alibaba.csp.sentinel.Env; import java.util.Optional;
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner; import javax.annotation.PostConstruct;
import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
import com.alibaba.csp.sentinel.adapter.servlet.config.WebServletConfig;
import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
import com.alibaba.csp.sentinel.config.SentinelConfig;
import com.alibaba.csp.sentinel.init.InitExecutor;
import com.alibaba.csp.sentinel.node.NodeBuilder;
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import com.alibaba.csp.sentinel.util.AppNameUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -39,8 +32,17 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct; import com.alibaba.csp.sentinel.Env;
import java.util.Optional; import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner;
import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
import com.alibaba.csp.sentinel.adapter.servlet.config.WebServletConfig;
import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
import com.alibaba.csp.sentinel.config.SentinelConfig;
import com.alibaba.csp.sentinel.init.InitExecutor;
import com.alibaba.csp.sentinel.node.NodeBuilder;
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import com.alibaba.csp.sentinel.util.AppNameUtil;
/** /**
* @author xiaojing * @author xiaojing
@ -69,26 +71,42 @@ public class SentinelAutoConfiguration {
if (StringUtils.isEmpty(System.getProperty(AppNameUtil.APP_NAME))) { if (StringUtils.isEmpty(System.getProperty(AppNameUtil.APP_NAME))) {
System.setProperty(AppNameUtil.APP_NAME, projectName); System.setProperty(AppNameUtil.APP_NAME, projectName);
} }
if (StringUtils.isEmpty(System.getProperty(TransportConfig.SERVER_PORT)) && StringUtils.hasText(properties.getTransport().getPort())) { if (StringUtils.isEmpty(System.getProperty(TransportConfig.SERVER_PORT))
System.setProperty(TransportConfig.SERVER_PORT, properties.getTransport().getPort()); && StringUtils.hasText(properties.getTransport().getPort())) {
System.setProperty(TransportConfig.SERVER_PORT,
properties.getTransport().getPort());
} }
if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER)) && StringUtils.hasText(properties.getTransport().getDashboard())) { if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER))
System.setProperty(TransportConfig.CONSOLE_SERVER, properties.getTransport().getDashboard()); && StringUtils.hasText(properties.getTransport().getDashboard())) {
System.setProperty(TransportConfig.CONSOLE_SERVER,
properties.getTransport().getDashboard());
} }
if (StringUtils.isEmpty(System.getProperty(TransportConfig.HEARTBEAT_INTERVAL_MS)) && StringUtils.hasText(properties.getTransport().getHeartbeatIntervalMs())) { if (StringUtils.isEmpty(System.getProperty(TransportConfig.HEARTBEAT_INTERVAL_MS))
System.setProperty(TransportConfig.HEARTBEAT_INTERVAL_MS, properties.getTransport().getHeartbeatIntervalMs()); && StringUtils
.hasText(properties.getTransport().getHeartbeatIntervalMs())) {
System.setProperty(TransportConfig.HEARTBEAT_INTERVAL_MS,
properties.getTransport().getHeartbeatIntervalMs());
} }
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.CHARSET)) && StringUtils.hasText(properties.getCharset())) { if (StringUtils.isEmpty(System.getProperty(SentinelConfig.CHARSET))
&& StringUtils.hasText(properties.getCharset())) {
System.setProperty(SentinelConfig.CHARSET, properties.getCharset()); System.setProperty(SentinelConfig.CHARSET, properties.getCharset());
} }
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE)) && StringUtils.hasText(properties.getMetric().getFileSingleSize())) { if (StringUtils
System.setProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE, properties.getMetric().getFileSingleSize()); .isEmpty(System.getProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE))
&& StringUtils.hasText(properties.getMetric().getFileSingleSize())) {
System.setProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE,
properties.getMetric().getFileSingleSize());
} }
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT)) && StringUtils.hasText(properties.getMetric().getFileTotalCount())) { if (StringUtils
System.setProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT, properties.getMetric().getFileTotalCount()); .isEmpty(System.getProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT))
&& StringUtils.hasText(properties.getMetric().getFileTotalCount())) {
System.setProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT,
properties.getMetric().getFileTotalCount());
} }
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.COLD_FACTOR)) && StringUtils.hasText(properties.getFlow().getColdFactor())) { if (StringUtils.isEmpty(System.getProperty(SentinelConfig.COLD_FACTOR))
System.setProperty(SentinelConfig.COLD_FACTOR, properties.getFlow().getColdFactor()); && StringUtils.hasText(properties.getFlow().getColdFactor())) {
System.setProperty(SentinelConfig.COLD_FACTOR,
properties.getFlow().getColdFactor());
} }
if (StringUtils.hasText(properties.getServlet().getBlockPage())) { if (StringUtils.hasText(properties.getServlet().getBlockPage())) {
@ -112,7 +130,6 @@ public class SentinelAutoConfiguration {
return new SentinelResourceAspect(); return new SentinelResourceAspect();
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@ConditionalOnClass(name = "org.springframework.web.client.RestTemplate") @ConditionalOnClass(name = "org.springframework.web.client.RestTemplate")