Skip to content

Commit e99a9f5

Browse files
authored
0.1.x (#364)
* Bug fix on test case * Polish #327 & #325 * Polish #321 * Polish #220 no program * Switch Yaml file * Update version to be 0.2.0 * Polish #218 * Update Documents * Fix the test case's bugs * Fix plugins' issues * Fix test-cases * Fix test cases * Fixes an issue on DubboMvcEndpoint * Polish: Fix a relaxed property name issue * Optimize Awaiting implementation * Remove author from JavaDoc * Refactor * Merge * Update dependencies and implementations * Update Samples * Fix the test cases
1 parent a5b15d7 commit e99a9f5

File tree

45 files changed

+1535
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1535
-200
lines changed

dubbo-spring-boot-autoconfigure/pom.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
<parent>
2121
<groupId>com.alibaba.boot</groupId>
2222
<artifactId>dubbo-spring-boot-parent</artifactId>
23-
2423
<version>0.1.2-SNAPSHOT</version>
25-
<relativePath>../dubbo-spring-boot-parent</relativePath>
24+
<relativePath>../dubbo-spring-boot-parent/pom.xml</relativePath>
2625
</parent>
2726
<modelVersion>4.0.0</modelVersion>
2827

dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java

+20
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
6464
*/
6565
private static final String DUBBO_APPLICATION_NAME_PROPERTY = "dubbo.application.name";
6666

67+
/**
68+
* The property name of {@link EnableDubboConfig#multiple() @EnableDubboConfig.multiple()}
69+
*/
70+
private static final String DUBBO_CONFIG_MULTIPLE_PROPERTY = "dubbo.config.multiple";
71+
72+
/**
73+
* The property name of {@link ApplicationConfig#getQosEnable() application's QOS enable}
74+
*/
75+
private static final String DUBBO_APPLICATION_QOS_ENABLE_PROPERTY = "dubbo.application.qos-enable";
76+
6777
@Override
6878
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
6979
MutablePropertySources propertySources = environment.getPropertySources();
@@ -81,6 +91,8 @@ public int getOrder() {
8191
private Map<String, Object> createDefaultProperties(ConfigurableEnvironment environment) {
8292
Map<String, Object> defaultProperties = new HashMap<String, Object>();
8393
setDubboApplicationNameProperty(environment, defaultProperties);
94+
setDubboConfigMultipleProperty(defaultProperties);
95+
setDubboApplicationQosEnableProperty(defaultProperties);
8496
return defaultProperties;
8597
}
8698

@@ -92,6 +104,14 @@ private void setDubboApplicationNameProperty(Environment environment, Map<String
92104
}
93105
}
94106

107+
private void setDubboConfigMultipleProperty(Map<String, Object> defaultProperties) {
108+
defaultProperties.put(DUBBO_CONFIG_MULTIPLE_PROPERTY, Boolean.TRUE.toString());
109+
}
110+
111+
private void setDubboApplicationQosEnableProperty(Map<String, Object> defaultProperties) {
112+
defaultProperties.put(DUBBO_APPLICATION_QOS_ENABLE_PROPERTY, Boolean.FALSE.toString());
113+
}
114+
95115
/**
96116
* Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)
97117
*

dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
/**
4444
* {@link DubboAutoConfiguration} Test On multiple Dubbo Configuration
4545
*
46+
* @author <a href="mailto:[email protected]">Mercy</a>
4647
* @since 1.0.0
4748
*/
4849
@RunWith(SpringJUnit4ClassRunner.class)
@@ -152,7 +153,7 @@ public class DubboAutoConfigurationOnMultipleConfigTest {
152153
public void testMultipleDubboConfigBindingProperties() {
153154

154155

155-
Assert.assertEquals(2, applications.size());
156+
Assert.assertEquals(3, applications.size());
156157

157158
Assert.assertEquals(1, modules.size());
158159

@@ -176,7 +177,7 @@ public void testApplicationContext() {
176177
*/
177178
Map<String, ApplicationConfig> applications = beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class);
178179

179-
Assert.assertEquals(2, applications.size());
180+
Assert.assertEquals(3, applications.size());
180181

181182
/**
182183
* Multiple {@link ModuleConfig}

dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void testConsumerConfig() {
150150

151151
@Test
152152
public void testMultipleDubboConfigConfiguration() {
153-
Assert.assertNull(multipleDubboConfigConfiguration);
153+
Assert.assertNotNull(multipleDubboConfigConfiguration);
154154
}
155155

156156
@Test
@@ -160,7 +160,7 @@ public void testSingleDubboConfigConfiguration() {
160160

161161
@Test
162162
public void testServiceAnnotationBeanPostProcessor() {
163-
Assert.assertNull(multipleDubboConfigConfiguration);
163+
Assert.assertNotNull(multipleDubboConfigConfiguration);
164164
}
165165

166166
}

dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public void testPostProcessEnvironment() {
5151
MutablePropertySources propertySources = environment.getPropertySources();
5252
// Nothing to change
5353
PropertySource defaultPropertySource = propertySources.get("defaultProperties");
54-
Assert.assertNull(defaultPropertySource);
54+
Assert.assertNotNull(defaultPropertySource);
55+
Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple"));
56+
Assert.assertEquals("false", defaultPropertySource.getProperty("dubbo.application.qos-enable"));
5557

5658
// Case 2 : Only set property "spring.application.name"
5759
environment.setProperty("spring.application.name", "demo-dubbo-application");
@@ -67,7 +69,7 @@ public void testPostProcessEnvironment() {
6769
environment.setProperty("dubbo.application.name", "demo-dubbo-application");
6870
instance.postProcessEnvironment(environment, springApplication);
6971
defaultPropertySource = propertySources.get("defaultProperties");
70-
Assert.assertNull(defaultPropertySource);
72+
Assert.assertNotNull(defaultPropertySource);
7173
dubboApplicationName = environment.getProperty("dubbo.application.name");
7274
Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
7375

@@ -81,5 +83,15 @@ public void testPostProcessEnvironment() {
8183
defaultPropertySource = propertySources.get("defaultProperties");
8284
dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
8385
Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
86+
87+
// Case 5 : Rest dubbo.config.multiple and dubbo.application.qos-enable
88+
environment = new MockEnvironment();
89+
propertySources = environment.getPropertySources();
90+
propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap<String, Object>()));
91+
environment.setProperty("dubbo.config.multiple", "false");
92+
environment.setProperty("dubbo.application.qos-enable", "true");
93+
instance.postProcessEnvironment(environment, springApplication);
94+
Assert.assertEquals("false", environment.getProperty("dubbo.config.multiple"));
95+
Assert.assertEquals("true", environment.getProperty("dubbo.application.qos-enable"));
8496
}
85-
}
97+
}

dubbo-spring-boot-parent/pom.xml

+19-50
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@
3939
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4040
<spring-boot.version>1.5.18.RELEASE</spring-boot.version>
4141
<dubbo.version>2.6.5</dubbo.version>
42-
<zkclient.version>0.2</zkclient.version>
43-
<zookeeper.version>3.4.9</zookeeper.version>
44-
<curator-framework.version>2.12.0</curator-framework.version>
45-
<alibaba-spring-context-support.version>1.0.2</alibaba-spring-context-support.version>
46-
42+
<dubbo-registry-nacos.version>0.0.2</dubbo-registry-nacos.version>
43+
<nacos-client.version>0.6.2</nacos-client.version>
4744
<!-- Build args -->
4845
<argline>-server -Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8
4946
-Djava.net.preferIPv4Stack=true
@@ -63,7 +60,6 @@
6360

6461
<dependencyManagement>
6562
<dependencies>
66-
6763
<!-- Spring Boot -->
6864
<dependency>
6965
<groupId>org.springframework.boot</groupId>
@@ -73,6 +69,15 @@
7369
<scope>import</scope>
7470
</dependency>
7571

72+
<!-- Dubbo dependencies -->
73+
<dependency>
74+
<groupId>com.alibaba</groupId>
75+
<artifactId>dubbo-dependencies-bom</artifactId>
76+
<version>${dubbo.version}</version>
77+
<type>pom</type>
78+
<scope>import</scope>
79+
</dependency>
80+
7681
<!-- Dubbo -->
7782
<dependency>
7883
<groupId>com.alibaba</groupId>
@@ -94,54 +99,18 @@
9499
</exclusions>
95100
</dependency>
96101

97-
<!-- Alibaba Spring Context extension -->
98-
<dependency>
99-
<groupId>com.alibaba.spring</groupId>
100-
<artifactId>spring-context-support</artifactId>
101-
<version>${alibaba-spring-context-support.version}</version>
102-
</dependency>
103-
104-
<!-- ZK -->
105-
<dependency>
106-
<groupId>org.apache.zookeeper</groupId>
107-
<artifactId>zookeeper</artifactId>
108-
<version>${zookeeper.version}</version>
109-
<exclusions>
110-
<exclusion>
111-
<groupId>org.slf4j</groupId>
112-
<artifactId>slf4j-log4j12</artifactId>
113-
</exclusion>
114-
<exclusion>
115-
<groupId>log4j</groupId>
116-
<artifactId>log4j</artifactId>
117-
</exclusion>
118-
</exclusions>
119-
</dependency>
120-
102+
<!-- Dubbo Nacos registry dependency -->
121103
<dependency>
122-
<groupId>com.101tec</groupId>
123-
<artifactId>zkclient</artifactId>
124-
<version>${zkclient.version}</version>
125-
<exclusions>
126-
<exclusion>
127-
<artifactId>slf4j-api</artifactId>
128-
<groupId>org.slf4j</groupId>
129-
</exclusion>
130-
<exclusion>
131-
<artifactId>log4j</artifactId>
132-
<groupId>log4j</groupId>
133-
</exclusion>
134-
<exclusion>
135-
<artifactId>slf4j-log4j12</artifactId>
136-
<groupId>org.slf4j</groupId>
137-
</exclusion>
138-
</exclusions>
104+
<groupId>com.alibaba</groupId>
105+
<artifactId>dubbo-registry-nacos</artifactId>
106+
<version>${dubbo-registry-nacos.version}</version>
139107
</dependency>
140108

109+
<!-- Keep latest Nacos client version -->
141110
<dependency>
142-
<groupId>org.apache.curator</groupId>
143-
<artifactId>curator-framework</artifactId>
144-
<version>${curator-framework.version}</version>
111+
<groupId>com.alibaba.nacos</groupId>
112+
<artifactId>nacos-client</artifactId>
113+
<version>${nacos-client.version}</version>
145114
</dependency>
146115

147116
</dependencies>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xmlns="http://maven.apache.org/POM/4.0.0"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<parent>
21+
<groupId>com.alibaba.boot.samples</groupId>
22+
<artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
23+
<version>0.1.2-SNAPSHOT</version>
24+
<relativePath>../pom.xml</relativePath>
25+
</parent>
26+
<modelVersion>4.0.0</modelVersion>
27+
28+
<artifactId>dubbo-spring-boot-auto-configure-consumer-sample</artifactId>
29+
<name>Dubbo Spring Boot Samples : Auto-Configure :: Consumer Sample</name>
30+
<dependencies>
31+
32+
<!-- Spring Boot dependencies -->
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter</artifactId>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>com.alibaba.boot</groupId>
40+
<artifactId>dubbo-spring-boot-starter</artifactId>
41+
<version>${project.version}</version>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>com.alibaba</groupId>
46+
<artifactId>dubbo</artifactId>
47+
</dependency>
48+
49+
<dependency>
50+
<groupId>${project.groupId}</groupId>
51+
<artifactId>dubbo-spring-boot-sample-api</artifactId>
52+
<version>${project.version}</version>
53+
</dependency>
54+
55+
</dependencies>
56+
57+
<build>
58+
<plugins>
59+
<plugin>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-maven-plugin</artifactId>
62+
<version>${spring-boot.version}</version>
63+
<executions>
64+
<execution>
65+
<goals>
66+
<goal>repackage</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
74+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.alibaba.boot.dubbo.demo.consumer.bootstrap;
18+
19+
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
20+
import com.alibaba.dubbo.config.annotation.Reference;
21+
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
24+
import org.springframework.boot.ApplicationArguments;
25+
import org.springframework.boot.ApplicationRunner;
26+
import org.springframework.boot.SpringApplication;
27+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
28+
import org.springframework.context.annotation.Bean;
29+
30+
/**
31+
* Dubbo Auto Configuration Consumer Bootstrap
32+
*
33+
* @since 1.0.0
34+
*/
35+
@EnableAutoConfiguration
36+
public class DubboAutoConfigurationConsumerBootstrap {
37+
38+
private final Logger logger = LoggerFactory.getLogger(getClass());
39+
40+
@Reference(version = "1.0.0", url = "dubbo://localhost:12345")
41+
private DemoService demoService;
42+
43+
@Bean
44+
public ApplicationRunner runner() {
45+
return new ApplicationRunner() {
46+
@Override
47+
public void run(ApplicationArguments args) throws Exception {
48+
logger.info(demoService.sayHello("mercyblitz"));
49+
}
50+
};
51+
}
52+
53+
public static void main(String[] args) {
54+
SpringApplication.run(DubboAutoConfigurationConsumerBootstrap.class).close();
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
spring:
2+
application:
3+
name: dubbo-auto-configure-consumer-sample

0 commit comments

Comments
 (0)