/**
* @Description: 利用键值模式控制service
* @Author: zhanglifeng
* @Date: 2019年 04月 28日 14:41
**/
public class ServiceManagerSingleton {
private static final Logger logger = LoggerFactory.getLogger(ServiceManagerSingleton.class);
private static Map<String, IChannelService> serviceMap;
@Resource(type = com.***.***.service.impl.CCBServiceImpl.class)
private IChannelService ccbService;
private static class SingletonHolder {
//由JVM保证只初始化一次
private static ServiceManagerSingleton instance = new ServiceManagerSingleton();
}
//初始化需要使用的service
private ServiceManagerSingleton() {
serviceMap = Maps.newHashMap();
serviceMap.put(CommonConst.MQ_KEY_WXZX,ccbService);
}
public static ServiceManagerSingleton getInstance() {
return SingletonHolder.instance;
}
}