package com.fzzy.api.service;
|
|
import org.springframework.beans.BeansException;
|
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.stereotype.Component;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* @Desc: 推送平台接口调用封装
|
* @author: andy.jia
|
* @update-time: 2022/10/6 14:09
|
*/
|
@Component
|
public class ApiPushManager implements ApplicationContextAware {
|
|
public static Map<String, PushService11> pushMap11 = new HashMap<>();
|
|
public static Map<String, PushService12> pushMap12 = new HashMap<>();
|
|
public static Map<String, PushService13> pushMap13 = new HashMap<>();
|
|
public static Map<String, PushService14> pushMap14 = new HashMap<>();
|
|
public static Map<String, ApiRemoteService> remoteMap = new HashMap<>();
|
|
@Override
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
Map<String, PushService11> service11Map = applicationContext.getBeansOfType(PushService11.class);
|
|
for (String key : service11Map.keySet()) {
|
pushMap11.put(service11Map.get(key).getProtocol(), service11Map.get(key));
|
}
|
|
|
Map<String, PushService12> service12Map = applicationContext.getBeansOfType(PushService12.class);
|
|
for (String key : service12Map.keySet()) {
|
pushMap12.put(service12Map.get(key).getProtocol(), service12Map.get(key));
|
}
|
|
|
Map<String, PushService13> service13Map = applicationContext.getBeansOfType(PushService13.class);
|
|
for (String key : service13Map.keySet()) {
|
pushMap13.put(service13Map.get(key).getProtocol(), service13Map.get(key));
|
}
|
|
|
Map<String, PushService14> service14Map = applicationContext.getBeansOfType(PushService14.class);
|
|
for (String key : service14Map.keySet()) {
|
pushMap14.put(service14Map.get(key).getProtocol(), service14Map.get(key));
|
}
|
|
Map<String, ApiRemoteService> remoteServiceMap = applicationContext.getBeansOfType(ApiRemoteService.class);
|
|
for (String key : remoteServiceMap.keySet()) {
|
remoteMap.put(remoteServiceMap.get(key).getProtocol(), remoteServiceMap.get(key));
|
}
|
|
}
|
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public PushService11 getPushService11(String protocol) {
|
return pushMap11.get(protocol);
|
}
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public PushService12 getPushService12(String protocol) {
|
return pushMap12.get(protocol);
|
}
|
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public PushService13 getPushService13(String protocol) {
|
return pushMap13.get(protocol);
|
}
|
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public PushService14 getPushService14(String protocol) {
|
return pushMap14.get(protocol);
|
}
|
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public ApiRemoteService getApiRemoteService(String protocol) {
|
return remoteMap.get(protocol);
|
}
|
|
}
|