AbstractXmlApplicationContext 中组合了一个 XmlBeanDefinitionReader 组件来解析 xml 配置文件
资源模型:
原生java加载资源方式:
借助 ClassLoader 加载类路径下的资源
借助 File 加载文件系统中的资源
借助 URL 和不同的协议加载本地 / 网络上的资源
DefaultResourceLoader组合了一堆ProtocolResolver:
private final Set<ProtocolResolver> protocolResolvers = new LinkedHashSet<>(4);
public Resource getResource(String location) {
Assert.notNull(location, "Location must not be null");
for (ProtocolResolver protocolResolver : getProtocolResolvers()) {
Resource resource = protocolResolver.resolve(location, this);
if (resource != null) {
return resource;
}
}
// ......
}
@FunctionalInterface
public interface ProtocolResolver {
Resource resolve(String location, ResourceLoader resourceLoader);
}
标签:Resource,ProtocolResolver,location,resource,IOC,资源管理,资源,加载
From: https://www.cnblogs.com/sjj123/p/16754597.html