美文网首页
spring源码---BeanDefinition

spring源码---BeanDefinition

作者: 追赶的程序猿 | 来源:发表于2019-10-23 22:21 被阅读0次

分为三个步骤:resource文件定位、加载、注册。IOC容器其实就是一个map,concurrentHashMap

加载过程中,默认会读取xml文件中前缀是classpath的文件路径。呈上代码:

StringCLASSPATH_ALL_URL_PREFIX ="classpath*:";

public Resource[] getResources(String locationPattern)throws IOException {

Assert.notNull(locationPattern,"Location pattern must not be null");

if (locationPattern.startsWith(CLASSPATH_ALL_URL_PREFIX)) {

// a class path resource (multiple resources for same name possible)

      if (getPathMatcher().isPattern(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()))) {

// a class path resource pattern

        return findPathMatchingResources(locationPattern);

}

else {

// all class path resources with the given name

        return findAllClassPathResources(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()));

}

}

相关文章

网友评论

      本文标题:spring源码---BeanDefinition

      本文链接:https://www.haomeiwen.com/subject/urusdqtx.html