mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 17:48:25 +08:00
不变属性添加final关键字
This commit is contained in:
parent
2be8dc0c39
commit
203b7dff12
@ -25,8 +25,8 @@ import java.util.Enumeration;
|
||||
*/
|
||||
public class DefaultMessageFactory implements MessageFactory {
|
||||
|
||||
private String platform = "mybatis-flex";
|
||||
private String hostIp = getHostIp();
|
||||
private final String platform = "mybatis-flex";
|
||||
private final String hostIp = getHostIp();
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -28,12 +28,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
*/
|
||||
public class ScheduledMessageCollector implements MessageCollector, Runnable {
|
||||
|
||||
private long period;
|
||||
private ScheduledExecutorService scheduler;
|
||||
private MessageReporter messageSender;
|
||||
private final long period;
|
||||
private final ScheduledExecutorService scheduler;
|
||||
private final MessageReporter messageSender;
|
||||
|
||||
private List<AuditMessage> messages = Collections.synchronizedList(new ArrayList<>());
|
||||
private ReentrantReadWriteLock rrwLock = new ReentrantReadWriteLock();
|
||||
private final List<AuditMessage> messages = Collections.synchronizedList(new ArrayList<>());
|
||||
private final ReentrantReadWriteLock rrwLock = new ReentrantReadWriteLock();
|
||||
|
||||
public ScheduledMessageCollector() {
|
||||
this(10, new ConsoleMessageReporter());
|
||||
|
||||
@ -22,9 +22,9 @@ import java.util.List;
|
||||
|
||||
public class HttpMessageReporter implements MessageReporter {
|
||||
|
||||
private String endpoint;
|
||||
private String secretKey;
|
||||
private JSONFormatter jsonFormatter;
|
||||
private final String endpoint;
|
||||
private final String secretKey;
|
||||
private final JSONFormatter jsonFormatter;
|
||||
|
||||
public HttpMessageReporter(String endpoint, String secretKey, JSONFormatter jsonFormatter) {
|
||||
this.endpoint = endpoint;
|
||||
|
||||
@ -27,7 +27,7 @@ import java.util.Map;
|
||||
|
||||
public class DataSourceBuilder {
|
||||
|
||||
private static Map<String, String> dataSourceAlias = new HashMap<>();
|
||||
private static final Map<String, String> dataSourceAlias = new HashMap<>();
|
||||
|
||||
static {
|
||||
dataSourceAlias.put("druid", "com.alibaba.druid.pool.DruidDataSource");
|
||||
@ -39,7 +39,7 @@ public class DataSourceBuilder {
|
||||
dataSourceAlias.put("dbcp2", "org.apache.commons.dbcp2.BasicDataSource");
|
||||
}
|
||||
|
||||
private Map<String, String> dataSourceProperties;
|
||||
private final Map<String, String> dataSourceProperties;
|
||||
|
||||
public DataSourceBuilder(Map<String, String> dataSourceProperties) {
|
||||
this.dataSourceProperties = dataSourceProperties;
|
||||
@ -49,11 +49,7 @@ public class DataSourceBuilder {
|
||||
String dataSourceClassName = null;
|
||||
String type = dataSourceProperties.get("type");
|
||||
if (StringUtil.isNotBlank(type)) {
|
||||
if (dataSourceAlias.containsKey(type)) {
|
||||
dataSourceClassName = dataSourceAlias.get(type);
|
||||
} else {
|
||||
dataSourceClassName = type;
|
||||
}
|
||||
dataSourceClassName = dataSourceAlias.getOrDefault(type, type);
|
||||
} else {
|
||||
dataSourceClassName = detectDataSourceClass();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user