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 ApiSyncManager implements ApplicationContextAware {
|
|
public static Map<String, SyncService11> map11 = new HashMap<>();
|
|
public static Map<String, SyncService12> map12 = new HashMap<>();
|
|
public static Map<String, SyncService13> map13 = new HashMap<>();
|
|
public static Map<String, SyncService14> map14 = new HashMap<>();
|
|
@Override
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
Map<String, SyncService11> service11Map = applicationContext.getBeansOfType(SyncService11.class);
|
|
for (String key : service11Map.keySet()) {
|
map11.put(service11Map.get(key).getProtocol(), service11Map.get(key));
|
}
|
|
|
Map<String, SyncService12> service12Map = applicationContext.getBeansOfType(SyncService12.class);
|
|
for (String key : service12Map.keySet()) {
|
map12.put(service12Map.get(key).getProtocol(), service12Map.get(key));
|
}
|
|
|
Map<String, SyncService13> service13Map = applicationContext.getBeansOfType(SyncService13.class);
|
|
for (String key : service13Map.keySet()) {
|
map13.put(service13Map.get(key).getProtocol(), service13Map.get(key));
|
}
|
|
|
Map<String, SyncService14> service14Map = applicationContext.getBeansOfType(SyncService14.class);
|
|
for (String key : service14Map.keySet()) {
|
map14.put(service14Map.get(key).getProtocol(), service14Map.get(key));
|
}
|
|
}
|
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public SyncService11 getSyncService11(String protocol) {
|
return map11.get(protocol);
|
}
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public SyncService12 getSyncService12(String protocol) {
|
return map12.get(protocol);
|
}
|
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public SyncService13 getSyncService13(String protocol) {
|
return map13.get(protocol);
|
}
|
|
|
/**
|
* 根据实现协议获取当前实现方法
|
*
|
* @param protocol
|
* @return
|
*/
|
public SyncService14 getSyncService14(String protocol) {
|
return map14.get(protocol);
|
}
|
|
|
}
|