Skip to content

Commit

Permalink
Polish apache#6173 : [Feature] Adding the "services" attribute into <…
Browse files Browse the repository at this point in the history
…dubbo:reference> element
  • Loading branch information
mercyblitz committed Jun 19, 2020
1 parent 36e21ca commit 7b03172
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
targetNamespace="http://dubbo.apache.org/schema/dubbo">

<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/beans"
schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/tool"/>

<xsd:annotation>
Expand Down Expand Up @@ -702,7 +703,8 @@
</xsd:attribute>
<xsd:attribute name="cluster" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The config center cluster, it's real meaning may very on different Config Center products. ]]></xsd:documentation>
<xsd:documentation>
<![CDATA[ The config center cluster, it's real meaning may very on different Config Center products. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="namespace" type="xsd:string" use="optional">
Expand Down Expand Up @@ -945,7 +947,8 @@
</xsd:attribute>
<xsd:attribute name="threadpool" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ Consumer threadpool: cached, fixed, limited, eager]]></xsd:documentation>
<xsd:documentation>
<![CDATA[ Consumer threadpool: cached, fixed, limited, eager]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="corethreads" type="xsd:string">
Expand Down Expand Up @@ -1011,6 +1014,14 @@
<xsd:documentation><![CDATA[ The service protocol. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="services" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[ The service names that the Dubbo interface subscribed.
If it is a multiple-values, the content will be a comma-delimited String. ]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:extension>
</xsd:complexContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@PropertySource("classpath:/META-INF/service-introspection/zookeeper-dubbb-consumer.properties")
public class ZookeeperDubboSpringConsumerBootstrap {

@DubboReference(services = "${dubbo.provider.name}")
@DubboReference(services = "${dubbo.provider.name},${dubbo.provider.name}")
private DemoService demoService;

public static void main(String[] args) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.dubbo.config.spring.samples;

import org.apache.dubbo.config.spring.api.DemoService;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
* Zookeeper Dubbo Spring Provider XML Bootstrap
*
* @since 2.7.8
*/
public class ZookeeperDubboSpringConsumerXmlBootstrap {

public static void main(String[] args) throws Exception {
String location = "classpath:/META-INF/service-introspection/zookeeper-dubbo-consumer.xml";
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(location);

DemoService demoService = context.getBean("demoService", DemoService.class);

for (int i = 0; i < 100; i++) {
System.out.println(demoService.sayName("Hello"));
}

context.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">

<!-- 当前应用信息配置 -->
<dubbo:application name="zookeeper-dubbo-spring-consumer"/>

<!-- 连接注册中心配置 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service" use-as-config-center="true"
use-as-metadata-center="true"/>

<dubbo:reference id="demoService" interface="org.apache.dubbo.config.spring.api.DemoService"
services="zookeeper-dubbo-spring-provider,zookeeper-dubbo-spring-provider"/>

</beans>

0 comments on commit 7b03172

Please sign in to comment.