package com.ld.igds.io;
|
|
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;
|
|
/**
|
* 协议实现类管理
|
*
|
* @author Andy
|
*
|
*/
|
@Component(EsRemoteManager.BEAN_ID)
|
public class EsRemoteManager implements ApplicationContextAware {
|
|
public static final String BEAN_ID = "es.remoteManager";
|
|
public static Map<String, RemoteEsService> remoteEsMap = new HashMap<>();
|
|
@Override
|
public void setApplicationContext(ApplicationContext applicationContext)
|
throws BeansException {
|
|
Map<String, RemoteEsService> esMap = applicationContext
|
.getBeansOfType(RemoteEsService.class);
|
for (String key : esMap.keySet()) {
|
remoteEsMap.put(esMap.get(key).getProtocol(), esMap.get(key));
|
}
|
}
|
|
/**
|
* 根据协议获取能耗接口
|
*
|
* @param protocol
|
* @return
|
*/
|
public RemoteEsService getRemoteEsService(String protocol) {
|
return remoteEsMap.get(protocol);
|
}
|
|
}
|