In the last post, we go through the whole process about how to register a regular <bean>. Now, let's take a look at how to load <import> tag:
importBeanDefinitionResource has all the implementation.
the logic is as following:
1. get the value of attribute: resource
2. resolve the location string by replacing system properties: e.g. "${user.dir}"
3. check the location is starting with classpath or regular url.
4. Line 26 will use AbstractBeanDefinitionReader->loadBeanDefinitions to parse the spring beans as mentioned in my previous blog.
5. The actualResources is used to store all loaded resources.
6. Line 63 will trig the event of import definition done.
<import resource="services.xml"/> <import resource="resources/messageSource.xml"/> <import resource="/resources/themeSource.xml"/>
</import>
see the entry code here:
importBeanDefinitionResource has all the implementation.
the logic is as following:
1. get the value of attribute: resource
2. resolve the location string by replacing system properties: e.g. "${user.dir}"
3. check the location is starting with classpath or regular url.
4. Line 26 will use AbstractBeanDefinitionReader->loadBeanDefinitions to parse the spring beans as mentioned in my previous blog.
- get the file resource list (if the location path contains "*" or "?") or return the file resource directly.
- parse the resource to spring bean one by one.
5. The actualResources is used to store all loaded resources.
6. Line 63 will trig the event of import definition done.
Comments
Post a Comment