Files
contract-manager/client/src/main/java/com/ecep/contract/util/BeanCacher.java
songqq effd7b103c feat: 新增多个服务类及工具类,重构部分代码结构
重构服务类结构,将分散的服务统一整合到service包下
新增ProjectConstant常量类及多个实体服务类
添加SecurityUtils安全工具类和BeanCacher工具类
优化部分UI控件和转换器的实现
2025-09-06 13:43:52 +08:00

23 lines
586 B
Java

package com.ecep.contract.util;
import java.util.HashMap;
import org.springframework.beans.BeansException;
import com.ecep.contract.SpringApp;
public class BeanCacher {
private HashMap<Class<?>, Object> cachedBeans = new HashMap<>();
@SuppressWarnings("unchecked")
public <T> T getBean(Class<T> requiredType) throws BeansException {
Object object = cachedBeans.get(requiredType);
if (object == null) {
object = SpringApp.getBean(requiredType);
cachedBeans.put(requiredType, object);
}
return (T) object;
}
}