refactor: 抽象通知器管理器

This commit is contained in:
椰子 2021-07-03 18:22:09 +08:00
parent e121652f62
commit 2d48623733
6 changed files with 7 additions and 8 deletions

View File

@ -8,7 +8,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* @author xueye
*/
public class DefaultNotifierManager implements NotifierManager {
public abstract class AbstractNotifierManager implements NotifierManager {
private final Map<String, Map<String, NotifierProvider>> providers = new ConcurrentHashMap<>();
private Map<String, Notifier> notifiers = new ConcurrentHashMap<>();
@ -17,7 +17,7 @@ public class DefaultNotifierManager implements NotifierManager {
// private EventBus eventBus;
public DefaultNotifierManager(NotifyConfigManager manager/*, EventBus eventBus*/) {
public AbstractNotifierManager(NotifyConfigManager manager/*, EventBus eventBus*/) {
this.configManager = manager;
// this.eventBus = eventBus;
}

View File

@ -54,7 +54,7 @@ public class DingTalkTest {
}
};
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
// register
DingTalkNotifierProvider provider = new DingTalkNotifierProvider(templateManager);

View File

@ -61,7 +61,7 @@ public class DefaultEmailTest {
}
};
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
DefaultEmailNotifierProvider defaultEmailNotifierProvider = new DefaultEmailNotifierProvider(templateManager);
// register
notifierManager.registerProvider(defaultEmailNotifierProvider);

View File

@ -8,7 +8,6 @@ import com.cicdi.notify.template.TemplateManager;
import com.cicdi.notify.template.TemplateProperties;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@ -53,7 +52,7 @@ public class AliyunSmsTest {
}
};
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
AliyunSmsNotifierProvider aliyunSmsNotifierProvider = new AliyunSmsNotifierProvider(templateManager);
// register
notifierManager.registerProvider(aliyunSmsNotifierProvider);

View File

@ -52,7 +52,7 @@ public class TelecomSmsTest {
}
};
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
// register
AliyunSmsNotifierProvider aliyunSmsNotifierProvider = new AliyunSmsNotifierProvider(templateManager);

View File

@ -54,7 +54,7 @@ public class WechatTest {
}
};
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
// register
WechatNotifierProvider provider = new WechatNotifierProvider(templateManager);