| | |
| | | @Component |
| | | public class GatewayRemoteManager implements ApplicationContextAware { |
| | | |
| | | public static Map<String, GatewayRemoteService> remoteMap1 = new HashMap<>(); |
| | | public static Map<String, GatewayRemoteService> remoteMap = new HashMap<>(); |
| | | |
| | | public static Map<String, GatewaySyncService> syncMap = new HashMap<>(); |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
| | | Map<String, GatewayRemoteService> serviceMap = applicationContext.getBeansOfType(GatewayRemoteService.class); |
| | | Map<String, GatewayRemoteService> serviceMap1 = applicationContext.getBeansOfType(GatewayRemoteService.class); |
| | | |
| | | for (String key : serviceMap.keySet()) { |
| | | remoteMap1.put(serviceMap.get(key).getProtocol(), serviceMap.get(key)); |
| | | for (String key : serviceMap1.keySet()) { |
| | | remoteMap.put(serviceMap1.get(key).getProtocol(), serviceMap1.get(key)); |
| | | } |
| | | |
| | | |
| | | Map<String, GatewaySyncService> serviceMap2 = applicationContext.getBeansOfType(GatewaySyncService.class); |
| | | |
| | | for (String key : serviceMap2.keySet()) { |
| | | syncMap.put(serviceMap2.get(key).getProtocol(), serviceMap2.get(key)); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public GatewayRemoteService getRemoteService(String protocol) { |
| | | return remoteMap1.get(protocol); |
| | | return remoteMap.get(protocol); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据实现协议获取当前实现方法 |
| | | * |
| | | * @param protocol |
| | | * @return |
| | | */ |
| | | public GatewaySyncService getSyncService(String protocol) { |
| | | return syncMap.get(protocol); |
| | | } |
| | | |
| | | } |