Skip to content

Commit

Permalink
refactor: 统一常量命名
Browse files Browse the repository at this point in the history
  • Loading branch information
fxbin committed Aug 20, 2023
1 parent d8d3ad9 commit 72adc8b
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public class AppUtils {

public static final String SPRING_BOOT_GITHUB_URL = "https://github.com/spring-projects/spring-boot";

public static final String BUBBLE_FIREWORKS_GITHUB_URL = "https://github.com/fxbin/bubble";
public static final String BUBBLE_GITHUB_URL = "https://github.com/fxbin/bubble";

}
6 changes: 6 additions & 0 deletions bubble-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<layers>
<enabled>true</enabled>
</layers>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
proxyBeanMethods = false
)
@AllArgsConstructor
@ConditionalOnProperty(prefix = ElasticsearchProperties.BUBBLE_FIREWORKS_ELASTICSEARCH_PREFIX, name = "cluster-nodes", matchIfMissing = false)
@ConditionalOnProperty(prefix = ElasticsearchProperties.BUBBLE_ELASTICSEARCH_PREFIX, name = "cluster-nodes", matchIfMissing = false)
@EnableConfigurationProperties(ElasticsearchProperties.class)
public class ElasticsearchAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Collections;
import java.util.List;

import static cn.fxbin.bubble.data.elasticsearch.autoconfigure.ElasticsearchProperties.BUBBLE_FIREWORKS_ELASTICSEARCH_PREFIX;
import static cn.fxbin.bubble.data.elasticsearch.autoconfigure.ElasticsearchProperties.BUBBLE_ELASTICSEARCH_PREFIX;

/**
* ElasticsearchProperties
Expand All @@ -18,13 +18,13 @@
* @since 2020/4/20 18:28
*/
@Data
@ConfigurationProperties(prefix = BUBBLE_FIREWORKS_ELASTICSEARCH_PREFIX)
@ConfigurationProperties(prefix = BUBBLE_ELASTICSEARCH_PREFIX)
public class ElasticsearchProperties {

/**
* elasticsearch prefix
*/
public static final String BUBBLE_FIREWORKS_ELASTICSEARCH_PREFIX = "bubble.elasticsearch";
public static final String BUBBLE_ELASTICSEARCH_PREFIX = "bubble.elasticsearch";

/**
* 请求协议
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;

import static cn.fxbin.bubble.plugin.dynamic.threadpool.autoconfigure.DynamicThreadPoolProperties.BUBBLE_FIREWORKS_DYNAMIC_THREAD_POOL_PREFIX;
import static cn.fxbin.bubble.plugin.dynamic.threadpool.autoconfigure.DynamicThreadPoolProperties.BUBBLE_DYNAMIC_THREAD_POOL_PREFIX;

/**
* ThreadPoolAutoConfiguration
Expand All @@ -44,7 +44,7 @@
)
@ConditionalOnClass({ThreadContextRefreshEvent.class, ThreadPoolExecutorOperations.class})
@EnableConfigurationProperties(DynamicThreadPoolProperties.class)
@ConditionalOnProperty(prefix = BUBBLE_FIREWORKS_DYNAMIC_THREAD_POOL_PREFIX, name = "enabled", matchIfMissing = true)
@ConditionalOnProperty(prefix = BUBBLE_DYNAMIC_THREAD_POOL_PREFIX, name = "enabled", matchIfMissing = true)
public class DynamicThreadPoolAutoConfiguration implements InitializingBean {

@Resource
Expand Down Expand Up @@ -132,7 +132,7 @@ public void loadThreadPool() {
private void refresh(Map<String, Object> propertyMap) {
ConfigurationPropertySource configurationPropertySource = new MapConfigurationPropertySource(propertyMap);
Binder binder = new Binder(configurationPropertySource);
binder.bind(BUBBLE_FIREWORKS_DYNAMIC_THREAD_POOL_PREFIX, Bindable.ofInstance(dynamicThreadPoolProperties));
binder.bind(BUBBLE_DYNAMIC_THREAD_POOL_PREFIX, Bindable.ofInstance(dynamicThreadPoolProperties));
}

/***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*/
@Data
@RefreshScope
@ConfigurationProperties(prefix = DynamicThreadPoolProperties.BUBBLE_FIREWORKS_DYNAMIC_THREAD_POOL_PREFIX)
@ConfigurationProperties(prefix = DynamicThreadPoolProperties.BUBBLE_DYNAMIC_THREAD_POOL_PREFIX)
public class DynamicThreadPoolProperties {


public static final String BUBBLE_FIREWORKS_DYNAMIC_THREAD_POOL_PREFIX = "bubble.dynamic.thread";
public static final String BUBBLE_DYNAMIC_THREAD_POOL_PREFIX = "bubble.dynamic.thread";

private String applicationName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import static cn.fxbin.bubble.plugin.dynamic.threadpool.autoconfigure.DynamicThreadPoolProperties.BUBBLE_FIREWORKS_DYNAMIC_THREAD_POOL_PREFIX;
import static cn.fxbin.bubble.plugin.dynamic.threadpool.autoconfigure.DynamicThreadPoolProperties.BUBBLE_DYNAMIC_THREAD_POOL_PREFIX;

/**
* ConfigServerHandler
Expand Down Expand Up @@ -49,7 +49,7 @@ public void refreshConfig() {
Map<String, Object> propertyResult = new HashMap<>();
PropertySource<?> propertySource = sourceLocator.locate(context.getEnvironment());
for (String key : ((EnumerablePropertySource<?>) propertySource).getPropertyNames()) {
if (key.contains(BUBBLE_FIREWORKS_DYNAMIC_THREAD_POOL_PREFIX)) {
if (key.contains(BUBBLE_DYNAMIC_THREAD_POOL_PREFIX)) {
propertyResult.put(key, propertySource.getProperty(key));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
proxyBeanMethods = false
)
@EnableConfigurationProperties(LoggingProperties.class)
@ConditionalOnProperty(prefix = LoggingProperties.BUBBLE_FIREWORKS_LOGGING_ALIYUN_PREFIX, name = "project-name", matchIfMissing = false)
@ConditionalOnProperty(prefix = LoggingProperties.BUBBLE_LOGGING_ALIYUN_PREFIX, name = "project-name", matchIfMissing = false)
public class AliyunLogContextAutoConfigure {

@Resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)
@ConditionalOnClass(LoggingWebAspect.class)
@EnableConfigurationProperties(LoggingProperties.class)
@ConditionalOnProperty(prefix = LoggingProperties.BUBBLE_FIREWORKS_LOGGING_PREFIX, name = "enabled", matchIfMissing = true)
@ConditionalOnProperty(prefix = LoggingProperties.BUBBLE_LOGGING_PREFIX, name = "enabled", matchIfMissing = true)
public class LoggingAutoConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/
@Data
@RefreshScope
@ConfigurationProperties(prefix = LoggingProperties.BUBBLE_FIREWORKS_LOGGING_PREFIX)
@ConfigurationProperties(prefix = LoggingProperties.BUBBLE_LOGGING_PREFIX)
public class LoggingProperties {

public static final String BUBBLE_FIREWORKS_LOGGING_PREFIX = "bubble.logging";
public static final String BUBBLE_LOGGING_PREFIX = "bubble.logging";

public static final String BUBBLE_FIREWORKS_LOGGING_ALIYUN_PREFIX = "bubble.logging.aliyun";
public static final String BUBBLE_LOGGING_ALIYUN_PREFIX = "bubble.logging.aliyun";

/**
* 默认开启日志
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.ArrayList;
import java.util.List;

import static cn.fxbin.bubble.openfeign.FeignProperties.BUBBLE_FIREWORKS_FEIGN_PREFIX;
import static cn.fxbin.bubble.openfeign.FeignProperties.BUBBLE_FEIGN_PREFIX;

/**
* FeignGlobalProperties
Expand All @@ -19,13 +19,13 @@
*/
@Data
@RefreshScope
@ConfigurationProperties(prefix = BUBBLE_FIREWORKS_FEIGN_PREFIX)
@ConfigurationProperties(prefix = BUBBLE_FEIGN_PREFIX)
public class FeignProperties {

/**
* swagger prefix
*/
public static final String BUBBLE_FIREWORKS_FEIGN_PREFIX = "bubble.feign";
public static final String BUBBLE_FEIGN_PREFIX = "bubble.feign";

/**
* 默认的全局透传header 全局透传请求头:X-Real-IP x-forwarded-for 请求和转发的ip, Authorization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public TokenPayload parseToken(String token) {
* @return cn.fxbin.bubble.plugin.token.model.TokenPayload
*/
public TokenPayload parseAccessToken(String token) {
return this.parseAccessToken(token, TokenConstants.BUBBLE_FIREWORKS_SCOPE);
return this.parseAccessToken(token, TokenConstants.BUBBLE_SCOPE);
}

/**
Expand Down Expand Up @@ -195,7 +195,7 @@ public TokenPayload parseAccessToken(String token, String scope) {
* @return cn.fxbin.bubble.plugin.token.model.TokenPayload
*/
public TokenPayload parseRefreshToken(String token) {
return this.parseRefreshToken(token, TokenConstants.BUBBLE_FIREWORKS_SCOPE);
return this.parseRefreshToken(token, TokenConstants.BUBBLE_SCOPE);
}

/**
Expand Down Expand Up @@ -272,7 +272,7 @@ private void checkTokenType(String type, String accessType) {
* @return java.lang.String
*/
public String generateAccessToken(long identity) {
return generateToken(TokenConstants.ACCESS_TYPE, identity, TokenConstants.BUBBLE_FIREWORKS_SCOPE, this.accessExpire);
return generateToken(TokenConstants.ACCESS_TYPE, identity, TokenConstants.BUBBLE_SCOPE, this.accessExpire);
}

/**
Expand All @@ -284,7 +284,7 @@ public String generateAccessToken(long identity) {
* @return java.lang.String
*/
public String generateAccessToken(String identity) {
return generateToken(TokenConstants.ACCESS_TYPE, identity, TokenConstants.BUBBLE_FIREWORKS_SCOPE, this.accessExpire);
return generateToken(TokenConstants.ACCESS_TYPE, identity, TokenConstants.BUBBLE_SCOPE, this.accessExpire);
}

/**
Expand All @@ -296,7 +296,7 @@ public String generateAccessToken(String identity) {
* @return java.lang.String
*/
public String generateRefreshToken(long identity) {
return generateToken(TokenConstants.REFRESH_TYPE, identity, TokenConstants.BUBBLE_FIREWORKS_SCOPE, this.refreshExpire);
return generateToken(TokenConstants.REFRESH_TYPE, identity, TokenConstants.BUBBLE_SCOPE, this.refreshExpire);
}

/**
Expand All @@ -308,7 +308,7 @@ public String generateRefreshToken(long identity) {
* @return java.lang.String
*/
public String generateRefreshToken(String identity) {
return generateToken(TokenConstants.REFRESH_TYPE, identity, TokenConstants.BUBBLE_FIREWORKS_SCOPE, this.refreshExpire);
return generateToken(TokenConstants.REFRESH_TYPE, identity, TokenConstants.BUBBLE_SCOPE, this.refreshExpire);
}

/**
Expand All @@ -332,7 +332,7 @@ public Tokens generateTokens(long identity) {
* @return cn.fxbin.bubble.plugin.token.model.Tokens
*/
public Tokens generateTokens(String identity) {
return this.generateTokens(identity, TokenConstants.BUBBLE_FIREWORKS_SCOPE);
return this.generateTokens(identity, TokenConstants.BUBBLE_SCOPE);
}

/**
Expand Down Expand Up @@ -371,7 +371,7 @@ public Tokens generateTokens(String identity, String scope) {
* @return cn.fxbin.bubble.plugin.token.model.Tokens
*/
public Tokens generateTokens(long identity, Map<String, Object> extra) {
return this.generateTokens(String.valueOf(identity), TokenConstants.BUBBLE_FIREWORKS_SCOPE, extra);
return this.generateTokens(String.valueOf(identity), TokenConstants.BUBBLE_SCOPE, extra);
}

/**
Expand All @@ -384,7 +384,7 @@ public Tokens generateTokens(long identity, Map<String, Object> extra) {
* @return cn.fxbin.bubble.plugin.token.model.Tokens
*/
public Tokens generateTokens(String identity, Map<String, Object> extra) {
return this.generateTokens(identity, TokenConstants.BUBBLE_FIREWORKS_SCOPE, extra);
return this.generateTokens(identity, TokenConstants.BUBBLE_SCOPE, extra);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.security.Key;

import static cn.fxbin.bubble.plugin.token.autoconfigure.TokenProperties.BUBBLE_FIREWORKS_TOKEN_PREFIX;
import static cn.fxbin.bubble.plugin.token.autoconfigure.TokenProperties.BUBBLE_TOKEN_PREFIX;

/**
* TokenProperties
Expand All @@ -19,10 +19,10 @@
*/
@Data
@RefreshScope
@ConfigurationProperties(prefix = BUBBLE_FIREWORKS_TOKEN_PREFIX)
@ConfigurationProperties(prefix = BUBBLE_TOKEN_PREFIX)
public class TokenProperties {

public static final String BUBBLE_FIREWORKS_TOKEN_PREFIX = "bubble.token";
public static final String BUBBLE_TOKEN_PREFIX = "bubble.token";

/**
* 是否开启 token,默认:true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface TokenConstants {

String REFRESH_TYPE = "refresh";

String BUBBLE_FIREWORKS_SCOPE = "bubble";
String BUBBLE_SCOPE = "bubble";

String OTHER_SCOPE = "other";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import com.xxl.job.core.executor.XxlJobExecutor;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -12,7 +11,7 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import static cn.fxbin.bubble.plugin.xxl.job.autoconfigure.XxlJobProperties.BUBBLE_FIREWORKS_XXl_JOB_PREFIX;
import static cn.fxbin.bubble.plugin.xxl.job.autoconfigure.XxlJobProperties.BUBBLE_XXL_JOB_PREFIX;

/**
* XxlJobAutoConfiguration
Expand All @@ -21,6 +20,7 @@
* @version v1.0
* @since 2020/10/28 10:47
*/
@Slf4j
@Configuration(
proxyBeanMethods = false
)
Expand All @@ -29,15 +29,13 @@
)
@ConditionalOnClass(XxlJobExecutor.class)
@EnableConfigurationProperties(XxlJobProperties.class)
@ConditionalOnProperty(prefix = BUBBLE_FIREWORKS_XXl_JOB_PREFIX, name = "enabled", havingValue = "true")
@ConditionalOnProperty(prefix = BUBBLE_XXL_JOB_PREFIX, name = "enabled", havingValue = "true")
public class XxlJobAutoConfiguration {

private static Logger logger = LoggerFactory.getLogger(XxlJobAutoConfiguration.class);

@Bean
@ConditionalOnMissingBean
public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) {
logger.info(">>>>>>>>>>> xxl-job config init.");
log.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdmin().getAddresses());
xxlJobSpringExecutor.setAppname(xxlJobProperties.getExecutor().getAppname());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ String buildBannerText(String startInfo, String url) {
.append(SPRING_BOOT_GITHUB_URL)
.append(LINE_SEPARATOR)
.append(" :: Bubble Project (v").append(Version.getVersion()).append(") : ")
.append(BUBBLE_FIREWORKS_GITHUB_URL)
.append(BUBBLE_GITHUB_URL)
.append(LINE_SEPARATOR)
.append(" :: 启动信息 : (").append(startInfo).append(")")
.append(LINE_SEPARATOR)
Expand Down

0 comments on commit 72adc8b

Please sign in to comment.