dubbo源码之一——xml schema扩展

时间:2021-08-30 09:06:33

dubbo源码版本:2.5.4

dubbo-parent

|----dubbo-config

|----dubbo-config-api

|----com.alibaba.dubbo.config.*

|----dubbo-config-spring

|----com.alibaba.dubbo.config.spring.schema.DubboNamespaceHandler.java

|----com.alibaba.dubbo.config.spring.schema.DubboBeanDefinitionParser.java

|----META-INF/dubbo.xsd

|----META-INF/spring.handlers

|----META-INF/spring.schemas

注:*代表任意文件或目录。

阿里巴巴的工程师利用spring schema扩展为dubbo定义了

XML Schema:http://code.alibabatech.com/schema/dubbo/dubbo.xsd

XML namespace:http://code.alibabatech.com/schema/dubbo

----------------------------------------------------------------------------------------------------------------------------------

dubbo schema定义了如下对象:

ApplicationConfig
ModuleConfig
RegistryConfig
MonitorConfig
ProviderConfig
ConsumerConfig
ProtocolConfig
ServiceBean
ReferenceBean
AnnotationBean

在spring xml文件中按照下面的方式注入dubbo schema中定义的对象:

----------------------------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

<dubbo:application name="annotation-consumer" />
<dubbo:registry address="127.0.0.1:4548" />
<dubbo:annotation package="com.alibaba.dubbo.config.spring.annotation.consumer" />

</beans>