CZT
2023-09-12 e8a5205acec61a431868c9b083fb62c2f187dd34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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);
    }
    
}