代码拉取完成,页面将自动刷新
同步操作将从 huifer/Code-Analysis 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
org.springframework.jndi.support.SimpleJndiBeanFactory
SimpleJndiBeanFactory
存在三个属性变量, 关注三个属性的作用下面是源码文档.
/**
* JNDI names of resources that are known to be shareable, i.e. can be cached
* 存储资源名称
* */
private final Set<String> shareableResources = new HashSet<>();
/**
* Cache of shareable singleton objects: bean name to bean instance.
* 存储单例bean和bean实例
* */
private final Map<String, Object> singletonObjects = new HashMap<>();
/**
* Cache of the types of nonshareable resources: bean name to bean type.
* key: beanName
* value: bean class
* */
private final Map<String, Class<?>> resourceTypes = new HashMap<>();
getBean
方法, 逻辑如下
public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
try {
// 判断是否是单例bean
if (isSingleton(name)) {
return doGetSingleton(name, requiredType);
}
// 寻找
else {
return lookup(name, requiredType);
}
}
catch (NameNotFoundException ex) {
throw new NoSuchBeanDefinitionException(name, "not found in JNDI environment");
}
catch (TypeMismatchNamingException ex) {
throw new BeanNotOfRequiredTypeException(name, ex.getRequiredType(), ex.getActualType());
}
catch (NamingException ex) {
throw new BeanDefinitionStoreException("JNDI environment", name, "JNDI lookup failed", ex);
}
}
lookup
org.springframework.jndi.JndiLocatorSupport.lookup(java.lang.String, java.lang.Class<T>)
方法的理解不是很深入, 这一块内容还请各位读者自行理解了. @SuppressWarnings("unchecked")
private <T> T doGetSingleton(String name, @Nullable Class<T> requiredType) throws NamingException {
synchronized (this.singletonObjects) {
// 从单例对象容器中根据名称获取
Object singleton = this.singletonObjects.get(name);
// 对象不为空
if (singleton != null) {
// 类型相同
if (requiredType != null && !requiredType.isInstance(singleton)) {
throw new TypeMismatchNamingException(convertJndiName(name), requiredType, singleton.getClass());
}
return (T) singleton;
}
T jndiObject = lookup(name, requiredType);
// 放入容器
this.singletonObjects.put(name, jndiObject);
return jndiObject;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。