refactor: 抽象通知器管理器
This commit is contained in:
parent
e121652f62
commit
2d48623733
@ -8,7 +8,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
/**
|
/**
|
||||||
* @author xueye
|
* @author xueye
|
||||||
*/
|
*/
|
||||||
public class DefaultNotifierManager implements NotifierManager {
|
public abstract class AbstractNotifierManager implements NotifierManager {
|
||||||
private final Map<String, Map<String, NotifierProvider>> providers = new ConcurrentHashMap<>();
|
private final Map<String, Map<String, NotifierProvider>> providers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private Map<String, Notifier> notifiers = new ConcurrentHashMap<>();
|
private Map<String, Notifier> notifiers = new ConcurrentHashMap<>();
|
||||||
@ -17,7 +17,7 @@ public class DefaultNotifierManager implements NotifierManager {
|
|||||||
|
|
||||||
// private EventBus eventBus;
|
// private EventBus eventBus;
|
||||||
|
|
||||||
public DefaultNotifierManager(NotifyConfigManager manager/*, EventBus eventBus*/) {
|
public AbstractNotifierManager(NotifyConfigManager manager/*, EventBus eventBus*/) {
|
||||||
this.configManager = manager;
|
this.configManager = manager;
|
||||||
// this.eventBus = eventBus;
|
// this.eventBus = eventBus;
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ public class DingTalkTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
|
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
|
||||||
|
|
||||||
// register
|
// register
|
||||||
DingTalkNotifierProvider provider = new DingTalkNotifierProvider(templateManager);
|
DingTalkNotifierProvider provider = new DingTalkNotifierProvider(templateManager);
|
||||||
|
@ -61,7 +61,7 @@ public class DefaultEmailTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
|
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
|
||||||
DefaultEmailNotifierProvider defaultEmailNotifierProvider = new DefaultEmailNotifierProvider(templateManager);
|
DefaultEmailNotifierProvider defaultEmailNotifierProvider = new DefaultEmailNotifierProvider(templateManager);
|
||||||
// register
|
// register
|
||||||
notifierManager.registerProvider(defaultEmailNotifierProvider);
|
notifierManager.registerProvider(defaultEmailNotifierProvider);
|
||||||
|
@ -8,7 +8,6 @@ import com.cicdi.notify.template.TemplateManager;
|
|||||||
import com.cicdi.notify.template.TemplateProperties;
|
import com.cicdi.notify.template.TemplateProperties;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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);
|
AliyunSmsNotifierProvider aliyunSmsNotifierProvider = new AliyunSmsNotifierProvider(templateManager);
|
||||||
// register
|
// register
|
||||||
notifierManager.registerProvider(aliyunSmsNotifierProvider);
|
notifierManager.registerProvider(aliyunSmsNotifierProvider);
|
||||||
|
@ -52,7 +52,7 @@ public class TelecomSmsTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
|
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
|
||||||
|
|
||||||
// register
|
// register
|
||||||
AliyunSmsNotifierProvider aliyunSmsNotifierProvider = new AliyunSmsNotifierProvider(templateManager);
|
AliyunSmsNotifierProvider aliyunSmsNotifierProvider = new AliyunSmsNotifierProvider(templateManager);
|
||||||
|
@ -54,7 +54,7 @@ public class WechatTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NotifierManager notifierManager = new DefaultNotifierManager(notifyConfigManager);
|
NotifierManager notifierManager = new AbstractNotifierManager(notifyConfigManager){};
|
||||||
|
|
||||||
// register
|
// register
|
||||||
WechatNotifierProvider provider = new WechatNotifierProvider(templateManager);
|
WechatNotifierProvider provider = new WechatNotifierProvider(templateManager);
|
||||||
|
Loading…
Reference in New Issue
Block a user