motan解读:添加spring 支持
代码位置:
motan-core的目录下
motan中使用spring管理配置对象。motan利用Spring的spi机制创建了自定义标签和相应的标签处理代码。具体使用方法见这篇。本文以motan为例,探讨如何扩展spring的schema.
1.首先,如果要自定义标签,不得不加上响应的xsd文件,这个文件可以对xml的格式进行约束。可以看到以下的自定义标签应该遵循的格式。对于新增的xsd文件,还要建立一个spring.schemas文件,加上这个xsd文件。
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2009-2016 Weibo, Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
--> <xsd:schema xmlns="http://api.weibo.com/schema/motan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tool="http://www.springframework.org/schema/tool"
xmlns:beans="http://www.springframework.org/schema/beans"
targetNamespace="http://api.weibo.com/schema/motan"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
<xsd:import namespace="http://www.springframework.org/schema/beans"/> <xsd:complexType name="abstractConfig">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="beans:property" minOccurs="0" maxOccurs="unbounded" />
</xsd:choice>
<xsd:anyAttribute namespace="##other" processContents="lax" />
</xsd:complexType>
<xsd:complexType name="abstractRegistryConfig" >
<xsd:complexContent>
<xsd:extension base="abstractConfig">
<xsd:attribute name="id" type="xsd:ID" />
<xsd:attribute name="name" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册名称. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="regProtocol" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册协议. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="address" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心地址. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="username" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心登录用户名. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="password" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心登录密码. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="port" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心缺省端口. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="connectTimeout" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心连接超时时间(毫秒). ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="requestTimeout" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心请求超时时间(毫秒). ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="registrySessionTimeout" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心会话超时时间(毫秒). ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="registryRetryPeriod" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ registryRetryPeriod. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="check" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 启动时检查注册中心是否存在. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="dynamic" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 在该注册中心是否自动注册. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="register" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 在该注册中心上服务是否暴露. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="subscribe" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 在该注册中心上服务是否引用. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="excise" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心移除策略,仅对vitage生效. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ is default protocol ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> </xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="abstractInterfaceConfig" >
<xsd:complexContent>
<xsd:extension base="abstractConfig">
<xsd:attribute name="proxy" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 代理类型. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="group" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 服务分组. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="version" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ version. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="throwException" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ throwException. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="requestTimeout" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ requestTimeout. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="connectTimeout" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 连接请求超时时间(毫秒). ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="retries" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ retries ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="filter" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 过滤器配置. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="listener" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 监听器配置. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="connections" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 连接数限制,0表示共享连接,否则为该服务独享连接数;默认共享. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="application" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 应用信息. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="module" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 模块信息. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="shareChannel" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 是否共享channel. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="timeout" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The method invoke timeout. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="actives" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The max active requests. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="async" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The method does async. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mock" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ Use service mock implemention. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="check" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 检查服务提供者是否存在 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="registry" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 注册中心的id列表,多个用“,”分隔,如果为空,则使用所有的配置中心. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="register" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 在该注册中心上服务是否暴露. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="subscribe" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 在该注册中心上服务是否引用. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="accessLog" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ accessLog ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="localServiceAddress" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 当使用VintageRetryLookupRegistry时,从config server同步三次失败并且feature.motanmcq.loadaddressfromfs开关打开时,把这个配置指定的地址作为服务地址,以逗号分割 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="usegz" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 是否开启gzip压缩.只有compressMotan的codec才能支持 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mingzSize" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 开启gzip压缩的阈值.usegz开关开启,且传输数据大于此阈值时,才会进行gzip压缩。只有compressMotan的codec才能支持 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="codec" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 协议编码. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType> <xsd:complexType name="abstractProtocolConfig">
<xsd:complexContent>
<xsd:extension base="abstractConfig">
<xsd:attribute name="id" type="xsd:ID" />
<xsd:attribute name="name" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[ 服务协议 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="serialization" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 序列化方式 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="payload" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 最大请求数据长度 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="buffer" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 缓存区大小 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="heartbeat" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 心跳间隔 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="transporter" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 网络传输方式 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="threads" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 线程池大小 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="iothreads" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ IO线程池大小 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="requestTimeout" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 请求超时 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="minClientConnection" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ minClientConnection ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="maxClientConnection" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ maxClientConnection ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="minWorkerThread" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ minWorkerThread ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="maxWorkerThread" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ maxWorkerThread ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="maxContentLength" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ maxContentLength ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="maxServerConnection" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ maxContentLength ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="poolLifo" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ is poolLifo ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="lazyInit" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ is lazyInit ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="endpointFactory" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ endpointFactory ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cluster" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ cluster ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="loadbalance" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ loadbalance ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="haStrategy" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ haStrategy ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="workerQueueSize" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ workerQueueSize ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="acceptConnections" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ acceptConnections ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="proxy" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ proxy ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="filter" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ filter ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="retries" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ retries ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="async" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ is async ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="queueSize" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 线程池队列大小 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="accepts" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 最大接收连接数 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="dispatcher" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 信息线程模型派发方式 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="server" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 服务器端实现 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="client" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 客户端端实现 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="codec" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ codec ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ is default protocol ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="switcherService" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ switcherService ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="heartbeatFactory" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ heartbeatFactory ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType> <xsd:element name="protocol" type="abstractProtocolConfig">
<xsd:annotation>
<xsd:documentation><![CDATA[ Service provider config ]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="registry" type="abstractRegistryConfig">
<xsd:annotation>
<xsd:documentation><![CDATA[ Registry config ]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="method">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[ The method name (method.toString()). ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="argumentTypes" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 参数类型(逗号分隔), 无参数用void. 如果方法无重载,则可不写 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="requestTimeout" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The method invoke timeout. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="retries" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The method retry times. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="service">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="abstractInterfaceConfig">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="method" minOccurs="0" maxOccurs="unbounded" />
<xsd:element ref="beans:property" minOccurs="0" maxOccurs="unbounded" />
</xsd:choice>
<xsd:attribute name="id" type="xsd:ID" />
<xsd:attribute name="export" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 服务暴露的方式,包含协议及端口号,多个协议端口用"," 分隔. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="basicService" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 基本service配置 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="host" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 如果有多个ip,但只想暴露指定的某个ip,设置该参数 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="interface" type="xsd:token">
<xsd:annotation>
<xsd:documentation><![CDATA[ Defines the interface to advertise for this service in the service registry. ]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:expected-type type="java.lang.Class"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="ref" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The service implementation instance bean id. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="class" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The service implementation class name. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute> <xsd:attribute name="path" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The service path. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="serialization" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 序列化方式. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="extConfig" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 扩展配置. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="referer">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="abstractInterfaceConfig">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="method" minOccurs="0" maxOccurs="unbounded" />
<xsd:element ref="beans:property" minOccurs="0" maxOccurs="unbounded" />
</xsd:choice>
<xsd:attribute name="id" type="xsd:ID" />
<xsd:attribute name="protocol" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 使用的协议 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="interface" type="xsd:token" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[ The service interface class name. ]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:expected-type type="java.lang.Class"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="client" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 客户端类型 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="directUrl" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[点对点直连服务提供地址 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="basicReferer" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 基本referer配置 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="extConfig" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 扩展配置. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element> <xsd:element name="basicService">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="abstractInterfaceConfig">
<xsd:attribute name="id" type="xsd:ID" />
<xsd:attribute name="export" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 暴露的协议及端口,多个协议端口之间用","分隔 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="host" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 如果有多个ip,但只想暴露指定的某个ip,设置该参数 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element> <xsd:element name="basicReferer">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="abstractInterfaceConfig">
<xsd:attribute name="id" type="xsd:ID" />
<xsd:attribute name="protocol" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ 使用的协议 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mean" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ SLA平均响应时间 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="p90" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ SLA90%的响应时间 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="p99" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ SLA99%的响应时间 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="p999" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ SLA999%的响应时间 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="errorRate" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ SLA错误率 ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element> <xsd:element name="spi">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="abstractConfig">
<xsd:attribute name="interfaceClass" type="xsd:token">
<xsd:annotation>
<xsd:documentation><![CDATA[ spi interface ]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:expected-type type="java.lang.Class" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="spiClass" type="xsd:token">
<xsd:annotation>
<xsd:documentation><![CDATA[ spi impl ]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:expected-type type="java.lang.Class" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element> </xsd:schema>
2.有个标签的格式,还需要标签的处理器,标签的处理器只要简单的继承NamespaceHandlerSupport这个类,具体的类如下,其中在init方法中,定义了标签和对应的解析器。motan中的对XML的解析起都是MotanBeanDefinitionParser,最终一对标签,最终转化为相应的BeanDefination.并放在一个并发的hashMap中,key为id,value是相应的beanDefination.
public class MotanNamespaceHandler extends NamespaceHandlerSupport {
public final static Set<String> protocolDefineNames = new ConcurrentHashSet<String>();
public final static Set<String> registryDefineNames = new ConcurrentHashSet<String>();
public final static Set<String> basicServiceConfigDefineNames = new ConcurrentHashSet<String>();
public final static Set<String> basicRefererConfigDefineNames = new ConcurrentHashSet<String>(); @Override
public void init() {
registerBeanDefinitionParser("referer", new MotanBeanDefinitionParser(RefererConfigBean.class, false));
registerBeanDefinitionParser("service", new MotanBeanDefinitionParser(ServiceConfigBean.class, true));
registerBeanDefinitionParser("protocol", new MotanBeanDefinitionParser(ProtocolConfig.class, true));
registerBeanDefinitionParser("registry", new MotanBeanDefinitionParser(RegistryConfig.class, true));
registerBeanDefinitionParser("basicService", new MotanBeanDefinitionParser(BasicServiceInterfaceConfig.class, true));
registerBeanDefinitionParser("basicReferer", new MotanBeanDefinitionParser(BasicRefererInterfaceConfig.class, true));
registerBeanDefinitionParser("spi", new MotanBeanDefinitionParser(SpiConfigBean.class, true));
} }
motan解读:添加spring 支持的更多相关文章
- myeclipse重新添加spring支持
需求:添加一次可能失败,需要再添加,但是一般点击右键add spring capabilities 不存在了 解决办法: 打开工程找到.project 注释掉spring支持 重新项目右键加入支持即可 ...
- 【liferay】3、liferay 添加spring支持
1.添加对应的spring的jar 地址:https://spring.io/projects 选中springframework 进入git源码的地方,看简介 我们需要编译好的jar 当然也可以自己 ...
- 手动添加SSH支持、使用c3p0
之前做的笔记,现在整理一下:大家有耐心的跟着做就能成功: SSH(struts2.spring.hibernate) * struts2 * 充当mvc的角色 * hibernate ...
- Spring Boot 添加Shiro支持
前言: Shiro是一个权限.会话管理的开源Java安全框架:Spring Boot集成Shiro后可以方便的使用Session: 工程概述: (工程结构图) 一.建立Spring Boot工程 参照 ...
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
上篇博客使用Spring Boot开发Web项目我们简单介绍了使用如何使用Spring Boot创建一个使用了Thymeleaf模板引擎的Web项目,当然这还远远不够.今天我们再来看看如何给我们的We ...
- Spring Boot 添加JSP支持【转】
Spring Boot 添加JSP支持 大体步骤: (1) 创建Maven web project: (2) 在pom.xml文件添加依赖: (3) ...
- IDEA02 利用Maven创建Web项目、为Web应用添加Spring框架支持、bean的创建于获取、利用注解配置Bean、自动装配Bean、MVC配置
1 环境版本说明 Jdk : 1.8 Maven : 3.5 IDEA : 专业版 2017.2 2 环境准备 2.1 Maven安装及其配置 2.2 Tomcat安装及其配置 3 详细步骤 3.1 ...
- step6----->往工程中添加spring boot项目------->修改pom.xml使得我的project是基于spring boot的,而非直接基于spring framework
文章内容概述: spring项目组其实有多个projects,如spring IO platform用于管理external dependencies的版本,通过定义BOM(bill of mater ...
- eclipse 新建 maven 项目 添加 spring hibernate 的配置文件 详情
主要配置文件 pom.xml 项目的maven 配置文件 管理项目所需 jar 依赖支持 web.xml 项目的总 配置文件 :添加 spring和hibernate 支持 applicationC ...
随机推荐
- *[codility]AscendingPaths
https://codility.com/programmers/challenges/magnesium2014 图形上的DP,先按照路径长度排序,然后依次遍历,状态是使用到当前路径为止的情况:每个 ...
- Zookeeper安装部署
Zookeeper安装 1. 安装 wget http://www.apache.org/dist//zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz ...
- windows系统下Python环境的搭建
1.下载最新的Python版本3.5.0.
- NSDictionary 键值对查找
NSDictionary *dic1=[NSDictionary dictionaryWithObjectsAndKeys: @"1",@"a", ...
- android actionbar标题栏
在android的actionBar中,actionBar的视图是固定的,左边是程序的图标和title,右边是添加的menuItem,如果想要定制actionbar中的view就要自定义视图. 首先要 ...
- Android 线程通讯类Handler
handler是线程通讯工具类.用于传递消息.它有两个队列: 1.消息队列 2.线程队列 消息队列使用sendMessage和HandleMessage的组合来发送和处理消息. 线程队列类似一段代码, ...
- SqlServer 如何以脚本形式导出数据
你是否遇到这样的情况,在公司导出一个数据库,回到家里导入自己的电脑里,然后发现数据库版本不匹配,这真是一个悲剧. 那么以下这个方法就可以避免这个悲剧,将数据以脚本的形式导出,这样灵活性更好. 1.选择 ...
- 关于ssh的一篇很好的文章
源地址:http://www.w3hacker.com/?p=156 ssh-agent的manual写得倒是挺详细,可看了好几次都没怎么搞明白.08年在网上找到了非常好的一篇文章,An Illu ...
- 如何屏蔽LOGD\LOGI等打印输出
今天被打印信息的去除困扰了,想了想,如果靠一个一个的改动未免太繁琐.因此就仔细的看了下这部分的打印原理.当然下面只是简单的进行了知识罗列不过有需要的朋友可以随便看看.说不准会有些收获呢. Includ ...
- OGG-00782 - OGG 11.2.1.0.2 FOR Windows x64 Microsoft SQL Server
OS ENV:主机名: WIN-NO42QRNPMFAOS 名称: Microsoft Windows Server 2008 R2 Datacenter OS ...