编写这两个文件
META-INF/spring.handlers
META-INF/spring.schemas
写法可以参照spring 那包下那两个文件,
Handler 继承 org.springframework.beans.factory.xml.NamespaceHandlerSupport
覆盖父类的 init(),
方法里调用
----------------------------------------------------------------------------------
下面是 Spring 加载原理
可以看到那两个文件都是 properties 格式的。
spring Application context 启动时执行:
直到调用
通过
获取对应文件的 URL ,然后就可以获取 Input 流,读取这两个 properties 文件。
META-INF/spring.handlers
META-INF/spring.schemas
写法可以参照spring 那包下那两个文件,
Handler 继承 org.springframework.beans.factory.xml.NamespaceHandlerSupport
覆盖父类的 init(),
方法里调用
void org.springframework.beans.factory.xml.NamespaceHandlerSupport.registerBeanDefinitionParser(String elementName, BeanDefinitionParser parser)
----------------------------------------------------------------------------------
下面是 Spring 加载原理
可以看到那两个文件都是 properties 格式的。
spring Application context 启动时执行:
void org.springframework.context.support.AbstractApplicationContext.refresh()
直到调用
String org.springframework.beans.factory.xml.PluggableSchemaResolver.getSchemaMapping(String systemId)
通过
Enumeration<URL> = ClassLoader.getResources(String name)
获取对应文件的 URL ,然后就可以获取 Input 流,读取这两个 properties 文件。