mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-06 08:58:38 +08:00
commit
9366a4d0f5
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
* 2023/6/8 22:35
|
||||
**/
|
||||
public class MailFactory{
|
||||
private static final Map<Object,MailSmtpConfig> configs = new HashMap<>();
|
||||
private static final Map<Object,MailSmtpConfig> CONFIGS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* createMailClient
|
||||
@ -27,7 +27,7 @@ public class MailFactory{
|
||||
*/
|
||||
public static MailClient createMailClient(Object key){
|
||||
try {
|
||||
return MailBuild.build(configs.get(key));
|
||||
return MailBuild.build(CONFIGS.get(key));
|
||||
} catch (MessagingException e) {
|
||||
throw new MailException(e);
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class MailFactory{
|
||||
*/
|
||||
public static MailClient createMailClient(Object key, Blacklist blacklist){
|
||||
try {
|
||||
return MailBuild.build(configs.get(key),blacklist);
|
||||
return MailBuild.build(CONFIGS.get(key),blacklist);
|
||||
} catch (MessagingException e) {
|
||||
throw new MailException(e);
|
||||
}
|
||||
@ -57,7 +57,7 @@ public class MailFactory{
|
||||
* @author :Wind
|
||||
*/
|
||||
public static void put(Object key, MailSmtpConfig config){
|
||||
configs.put(key,config);
|
||||
CONFIGS.put(key,config);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ public class SmsLoad {
|
||||
// 服务器列表,每个服务器有一个权重和当前权重
|
||||
private final List<LoadServer> LoadServers = new ArrayList<>();
|
||||
|
||||
private static final SmsLoad smsLoad = new SmsLoad();
|
||||
private static final SmsLoad SMS_LOAD = new SmsLoad();
|
||||
|
||||
private SmsLoad() {
|
||||
}
|
||||
@ -100,15 +100,15 @@ public class SmsLoad {
|
||||
public static void starConfig(SmsBlend smsBlend, SupplierConfig supplierConfig) {
|
||||
Map<String, Object> supplierConfigMap = BeanUtil.beanToMap(supplierConfig);
|
||||
Object weight = supplierConfigMap.getOrDefault("weight", 1);
|
||||
smsLoad.addLoadServer(smsBlend, Integer.parseInt(weight.toString()));
|
||||
SMS_LOAD.addLoadServer(smsBlend, Integer.parseInt(weight.toString()));
|
||||
}
|
||||
|
||||
public static void starConfig(SmsBlend smsBlend,Integer weight) {
|
||||
smsLoad.addLoadServer(smsBlend,weight);
|
||||
SMS_LOAD.addLoadServer(smsBlend,weight);
|
||||
}
|
||||
|
||||
public static SmsLoad getBeanLoad() {
|
||||
return smsLoad;
|
||||
return SMS_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,10 +27,10 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class SmsProxyFactory {
|
||||
private static final LinkedList<SmsProcessor> processors = new LinkedList<>();
|
||||
private static final LinkedList<SmsProcessor> PROCESSORS = new LinkedList<>();
|
||||
|
||||
public static SmsBlend getProxySmsBlend(SmsBlend smsBlend) {
|
||||
LinkedList<SmsProcessor> ownerProcessors = processors.stream().filter(processor -> !shouldSkipProcess(processor,smsBlend)).collect(Collectors.toCollection(LinkedList::new));
|
||||
LinkedList<SmsProcessor> ownerProcessors = PROCESSORS.stream().filter(processor -> !shouldSkipProcess(processor,smsBlend)).collect(Collectors.toCollection(LinkedList::new));
|
||||
return (SmsBlend) Proxy.newProxyInstance(smsBlend.getClass().getClassLoader(), new Class[]{SmsBlend.class}, new SmsInvocationHandler(smsBlend, ownerProcessors));
|
||||
}
|
||||
|
||||
@ -41,8 +41,8 @@ public abstract class SmsProxyFactory {
|
||||
//校验拦截器是否正确
|
||||
processorValidate(processor);
|
||||
awareTransfer(processor);
|
||||
processors.add(processor);
|
||||
processors.sort(Comparator.comparingInt(Order::getOrder));
|
||||
PROCESSORS.add(processor);
|
||||
PROCESSORS.sort(Comparator.comparingInt(Order::getOrder));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
* 2023/6/8 22:35
|
||||
**/
|
||||
public class MailFactory{
|
||||
private static final Map<Object,MailSmtpConfig> configs = new HashMap<>();
|
||||
private static final Map<Object,MailSmtpConfig> CONFIGS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* createMailClient
|
||||
@ -27,7 +27,7 @@ public class MailFactory{
|
||||
*/
|
||||
public static MailClient createMailClient(Object key){
|
||||
try {
|
||||
return MailBuild.build(configs.get(key));
|
||||
return MailBuild.build(CONFIGS.get(key));
|
||||
} catch (MessagingException e) {
|
||||
throw new MailException(e);
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class MailFactory{
|
||||
*/
|
||||
public static MailClient createMailClient(Object key, Blacklist blacklist){
|
||||
try {
|
||||
return MailBuild.build(configs.get(key),blacklist);
|
||||
return MailBuild.build(CONFIGS.get(key),blacklist);
|
||||
} catch (MessagingException e) {
|
||||
throw new MailException(e);
|
||||
}
|
||||
@ -57,7 +57,7 @@ public class MailFactory{
|
||||
* @author :Wind
|
||||
*/
|
||||
public static void put(Object key, MailSmtpConfig config){
|
||||
configs.put(key,config);
|
||||
CONFIGS.put(key,config);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -16,13 +16,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class ProviderFactoryHolder {
|
||||
|
||||
|
||||
private static final Map<String, OaBaseProviderFactory<? extends OaSender, ? extends OaSupplierConfig>> factories = new ConcurrentHashMap<>();
|
||||
private static final Map<String, OaBaseProviderFactory<? extends OaSender, ? extends OaSupplierConfig>> FACTORIES = new ConcurrentHashMap<>();
|
||||
|
||||
public static void registerFactory(OaBaseProviderFactory<? extends OaSender, ? extends OaSupplierConfig> factory) {
|
||||
if (factory == null) {
|
||||
throw new OaException("注册供应商工厂失败,工厂实例不能为空");
|
||||
}
|
||||
factories.put(factory.getSupplier(), factory);
|
||||
FACTORIES.put(factory.getSupplier(), factory);
|
||||
}
|
||||
|
||||
public static void registerFactory(List<OaBaseProviderFactory<? extends OaSender, ? extends OaSupplierConfig>> factoryList) {
|
||||
@ -38,6 +38,6 @@ public class ProviderFactoryHolder {
|
||||
}
|
||||
|
||||
public static OaBaseProviderFactory<? extends OaSender, ? extends OaSupplierConfig> requireForSupplier(String supplier) {
|
||||
return factories.getOrDefault(supplier, null);
|
||||
return FACTORIES.getOrDefault(supplier, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package org.dromara.sms4j.provider.config;
|
||||
|
||||
public class SmsBanner {
|
||||
private static final String banner =
|
||||
private static final String BANNER =
|
||||
" ________ _____ ______ ________ ___ ___ ___ \n" +
|
||||
"|\\ ____\\|\\ _ \\ _ \\|\\ ____\\|\\ \\ |\\ \\ |\\ \\ \n" +
|
||||
"\\ \\ \\___|\\ \\ \\\\\\__\\ \\ \\ \\ \\___|\\ \\ \\\\_\\ \\ \\ \\ \\ \n" +
|
||||
@ -12,6 +12,6 @@ public class SmsBanner {
|
||||
" \\|_________| \\|_________| \n";
|
||||
/** 初始化配置文件时打印banner*/
|
||||
public static void PrintBanner(String version) {
|
||||
System.out.println(banner+version);
|
||||
System.out.println(BANNER +version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,13 +17,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class ProviderFactoryHolder {
|
||||
|
||||
private static final Map<String, BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig>> factories = new ConcurrentHashMap<>();
|
||||
private static final Map<String, BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig>> FACTORIES = new ConcurrentHashMap<>();
|
||||
|
||||
public static void registerFactory(BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig> factory) {
|
||||
if(factory == null) {
|
||||
throw new SmsBlendException("注册供应商工厂失败,工厂实例不能为空");
|
||||
}
|
||||
factories.put(factory.getSupplier(), factory);
|
||||
FACTORIES.put(factory.getSupplier(), factory);
|
||||
}
|
||||
|
||||
public static void registerFactory(List<BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig>> factoryList) {
|
||||
@ -39,7 +39,7 @@ public class ProviderFactoryHolder {
|
||||
}
|
||||
|
||||
public static BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig> requireForSupplier(String supplier) {
|
||||
return factories.getOrDefault(supplier, null);
|
||||
return FACTORIES.getOrDefault(supplier, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ public class Uni {
|
||||
/** 模仿SDK版本*/
|
||||
public static final String VERSION = "0.0.4";
|
||||
|
||||
public static final String signingAlgorithm = "hmac-sha256";
|
||||
public static final String SIGNING_ALGORITHM = "hmac-sha256";
|
||||
public static String endpoint = System.getenv().getOrDefault("UNI_ENDPOINT", "https://uni.apistd.com");
|
||||
public static String accessKeyId = System.getenv("UNI_ACCESS_KEY_ID");
|
||||
|
||||
@ -86,7 +86,7 @@ public class Uni {
|
||||
builder.isSimple(false);
|
||||
}
|
||||
builder.endpoint(Uni.endpoint);
|
||||
builder.signingAlgorithm(Uni.signingAlgorithm);
|
||||
builder.signingAlgorithm(Uni.SIGNING_ALGORITHM);
|
||||
builder.setRetryInterval(retryInterval);
|
||||
builder.setMaxRetries(maxRetries);
|
||||
return builder.build();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user