package com.shkpr.service.aimodelpower.dbdao; import com.shkpr.service.aimodelpower.SpringContextUtil; import com.shkpr.service.aimodelpower.dbdao.otherDataSource.service.intef.WaterTapWaterService; import com.shkpr.service.aimodelpower.dbdao.services.intef.*; public class DBMgrProxy { private volatile RolePowerDBService rolePowerDBService = null; private volatile PartitionInfoDBService partitionInfoDBService = null; private volatile RoleInfoDBService roleInfoDBService = null; private volatile UserDBService userDBService = null; private volatile FileAttachmentDBService fileAttachmentDBService = null; private volatile TypeDefineDBService typeDefineDBService = null; private volatile TestGeomInfoDBService testGeomInfoDBService = null; //TODO 其他数据源 private volatile WaterTapWaterService waterTapWaterService = null; private static volatile DBMgrProxy msInstance = null; public static DBMgrProxy getInstance(){ if (msInstance == null){ synchronized (DBMgrProxy.class){ if (msInstance == null) msInstance = new DBMgrProxy(); } } return msInstance; } private DBMgrProxy() { } public void init(){ if (rolePowerDBService == null) rolePowerDBService = (RolePowerDBService)SpringContextUtil.getBean(RolePowerDBService.class); if (partitionInfoDBService == null) partitionInfoDBService = (PartitionInfoDBService)SpringContextUtil.getBean(PartitionInfoDBService.class); if (roleInfoDBService == null) roleInfoDBService = (RoleInfoDBService)SpringContextUtil.getBean(RoleInfoDBService.class); if (userDBService == null) userDBService = (UserDBService)SpringContextUtil.getBean(UserDBService.class); if (fileAttachmentDBService == null) fileAttachmentDBService = (FileAttachmentDBService)SpringContextUtil.getBean(FileAttachmentDBService.class); if (typeDefineDBService == null) typeDefineDBService = (TypeDefineDBService)SpringContextUtil.getBean(TypeDefineDBService.class); if (waterTapWaterService == null) waterTapWaterService = (WaterTapWaterService)SpringContextUtil.getBean(WaterTapWaterService.class); } public RolePowerDBService applyRolePowerApi() {return rolePowerDBService;} public PartitionInfoDBService applyPartitionApi() {return partitionInfoDBService;} public RoleInfoDBService applyRoleInfoApi() {return roleInfoDBService;} public UserDBService applyUserInfoApi() {return userDBService;} public FileAttachmentDBService applyFileAttachmentApi() {return fileAttachmentDBService;} public TypeDefineDBService applyTypeDefineApi() { return typeDefineDBService; } public TestGeomInfoDBService applyTestGeomApi() {return testGeomInfoDBService;} public WaterTapWaterService applyWaterTapWaterService() {return waterTapWaterService;} }