Merge remote-tracking branch 'upstream/master'
diff --git a/.travis.yml b/.travis.yml
index 5883b89..041395b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,7 @@
sudo: false # faster builds
jdk:
- - oraclejdk10
- - oraclejdk9
+ - openjdk11
- oraclejdk8
script: "mvn clean package"
diff --git a/DISCLAIMER b/DISCLAIMER
new file mode 100644
index 0000000..bed312a
--- /dev/null
+++ b/DISCLAIMER
@@ -0,0 +1 @@
+Apache Dubbo is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
\ No newline at end of file
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..97fefd0
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,14 @@
+Apache Dubbo (incubating)
+Copyright 2018-2019 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This product contains code form the Netty Project:
+
+The Netty Project
+=================
+Please visit the Netty web site for more information:
+ * http://netty.io/
+
+Copyright 2014 The Netty Project
\ No newline at end of file
diff --git a/README.md b/README.md
index 2c4db88..e7afdad 100644
--- a/README.md
+++ b/README.md
@@ -20,24 +20,50 @@
You can introduce the latest `dubbo-spring-boot-starter` to your project by adding the following dependency to your pom.xml
```xml
-<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-starter</artifactId>
- <version>0.2.0</version>
-</dependency>
+<properties>
+ <spring-boot.version>2.1.1.RELEASE</spring-boot.version>
+ <dubbo.version>2.6.5</dubbo.version>
+</properties>
+
+<dependencyManagement>
+ <dependencies>
+ <!-- Spring Boot -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${spring-boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <!-- Dubbo dependencies -->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-dependencies-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+</dependencyManagement>
-<!-- Dubbo -->
-<dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>2.6.5</version>
-</dependency>
-<!-- Spring Context Extras -->
-<dependency>
- <groupId>com.alibaba.spring</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>1.0.2</version>
-</dependency>
+<dependencies>
+ <!-- Dubbo Spring Boot Starter -->
+ <dependency>
+ <groupId>com.alibaba.boot</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
+</dependencies>
```
If your project failed to resolve the dependency, try to add the following repository:
@@ -78,14 +104,14 @@
| versions | Java | Spring Boot | Dubbo |
| -------- | ----- | ----------- | ---------- |
-| `0.2.0` | 1.8+ | `2.0.x` | `2.6.2` + |
+| `0.2.1` | 1.8+ | `2.1.x` | `2.6.2` + |
| `0.1.1` | 1.7+ | `1.5.x` | `2.6.2` + |
## Getting Started
-If you don't know about Dubbo, please take a few minutes to learn http://dubbo.apache.org/. After that you could dive deep into dubbo [user guide](http://dubbo.apache.org/books/dubbo-user-book-en/).
+If you don't know about Dubbo, please take a few minutes to learn http://dubbo.apache.org/. After that you could dive deep into dubbo [user guide](http://dubbo.apache.org/en-us/docs/user/quick-start.html).
Usually, There are two usage scenarios for Dubbo applications, one is Dubbo service(s) provider, another is Dubbo service(s) consumer, thus let's get a quick start on them.
@@ -103,148 +129,108 @@
### Dubbo service(s) provider
-Service Provider implements `DemoService`:
+1. Service Provider implements `DemoService`
-```java
-@Service(
- version = "1.0.0",
- application = "${dubbo.application.id}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
-public class DefaultDemoService implements DemoService {
+ ```java
+ @Service(version = "1.0.0")
+ public class DefaultDemoService implements DemoService {
- public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+
+ public String sayHello(String name) {
+ return String.format("[%s] : Hello, %s", serviceName, name);
+ }
}
+ ```
-}
-```
+2. Provides a bootstrap class
+ ```java
+ @EnableAutoConfiguration
+ public class DubboProviderDemo {
-
-then, provides a bootstrap class:
-
-```java
-@SpringBootApplication
-public class DubboProviderDemo {
-
- public static void main(String[] args) {
-
- SpringApplication.run(DubboProviderDemo.class,args);
-
+ public static void main(String[] args) {
+ SpringApplication.run(DubboProviderDemo.class,args);
+ }
}
+ ```
-}
-```
+3. Configures the `application.properties`:
+ ```properties
+ # Spring boot application
+ spring.application.name=dubbo-auto-configuration-provider-demo
+ # Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+ dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
-last, configures `application.properties`:
+ # Dubbo Application
+ ## The default value of dubbo.application.name is ${spring.application.name}
+ ## dubbo.application.name=${spring.application.name}
-```properties
-# Spring boot application
-spring.application.name = dubbo-provider-demo
-server.port = 9090
-management.port = 9091
+ # Dubbo Protocol
+ dubbo.protocol.name=dubbo
+ dubbo.protocol.port=12345
-# Base packages to scan Dubbo Components (e.g., @Service, @Reference)
-dubbo.scan.basePackages = com.alibaba.boot.dubbo.demo.provider.service
-
-# Dubbo Config properties
-## ApplicationConfig Bean
-dubbo.application.id = dubbo-provider-demo
-dubbo.application.name = dubbo-provider-demo
-
-## ProtocolConfig Bean
-dubbo.protocol.id = dubbo
-dubbo.protocol.name = dubbo
-dubbo.protocol.port = 12345
-
-## RegistryConfig Bean
-dubbo.registry.id = my-registry
-dubbo.registry.address = N/A
-```
-
-
-
-`DefaultDemoService`'s placeholders( `${dubbo.application.id}`, `${dubbo.protocol.id}`, `${dubbo.registry.id}` ) sources from `application.properties`.
-
-
-
-More details, please refer to [Dubbo Provider Sample](dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider).
+ ## Dubbo Registry
+ dubbo.registry.address=N/A
+ ```
### Dubbo service(s) consumer
+1. Service consumer also provides a bootstrap class to reference `DemoService`
+ ```java
+ @EnableAutoConfiguration
+ public class DubboConsumerBootstrap {
-Service consumer requires Spring Beans to reference `DemoService`:
+ private final Logger logger = LoggerFactory.getLogger(getClass());
-```java
-@RestController
-public class DemoConsumerController {
+ @Reference(version = "1.0.0", url = "dubbo://localhost:12345")
+ private DemoService demoService;
- @Reference(version = "1.0.0",
- application = "${dubbo.application.id}",
- url = "dubbo://localhost:12345")
- private DemoService demoService;
+ @Bean
+ public ApplicationRunner runner() {
+ return args -> {
+ logger.info(demoService.sayHello("mercyblitz"));
+ };
+ }
- @RequestMapping("/sayHello")
- public String sayHello(@RequestParam String name) {
- return demoService.sayHello(name);
+ public static void main(String[] args) {
+ SpringApplication.run(DubboConsumerBootstrap.class).close();
+ }
}
+ ```
-}
-```
+2. configures `application.properties`
+
+ ```properties
+ # Spring boot application
+ spring.application.name = dubbo-consumer-demo
+ server.port = 8080
+ management.port = 8081
+ # Dubbo Config properties
+ ## ApplicationConfig Bean
+ dubbo.application.id = dubbo-consumer-demo
+ dubbo.application.name = dubbo-consumer-demo
-then, also provide a bootstrap class:
+ ## ProtocolConfig Bean
+ dubbo.protocol.id = dubbo
+ dubbo.protocol.name = dubbo
+ dubbo.protocol.port = 12345
+ ```
-```java
-@SpringBootApplication(scanBasePackages = "com.alibaba.boot.dubbo.demo.consumer.controller")
-public class DubboConsumerDemo {
+If `DubboProviderDemo` works well, please mark sure `DubboProviderDemo` is started.
- public static void main(String[] args) {
-
- SpringApplication.run(DubboConsumerDemo.class,args);
-
- }
-
-}
-```
-
-
-
-last, configures `application.properties`:
-
-```properties
-# Spring boot application
-spring.application.name = dubbo-consumer-demo
-server.port = 8080
-management.port = 8081
-
-
-# Dubbo Config properties
-## ApplicationConfig Bean
-dubbo.application.id = dubbo-consumer-demo
-dubbo.application.name = dubbo-consumer-demo
-
-## ProtocolConfig Bean
-dubbo.protocol.id = dubbo
-dubbo.protocol.name = dubbo
-dubbo.protocol.port = 12345
-```
-
-
-
-If `DubboProviderDemo` works well, please mark sure Dubbo service(s) is active.
-
-
-
-More details, please refer to [Dubbo Consumer Sample](dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer)
+More details, please refer to [Samples](dubbo-spring-boot-samples).
@@ -261,7 +247,7 @@
## Building from Source
-If you want to try out thr latest features of Dubbo Spring Boot, it can be easily built with the [maven wrapper](https://github.com/takari/maven-wrapper). Your JDK is 1.7 or above.
+If you want to try out thr latest features of Dubbo Spring Boot, it can be easily built with the [maven wrapper](https://github.com/takari/maven-wrapper). Your JDK is 1.8 or above.
```
$ ./mvnw clean install
@@ -301,24 +287,10 @@
### [dubbo-spring-boot-samples](dubbo-spring-boot-samples)
-The samples project of Dubbo Spring Boot that includes two parts:
+The samples project of Dubbo Spring Boot that includes:
-
-
-#### [Dubbo Provider Sample](dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider)
-
-Dubbo Service will be exported on localhost with port `12345`.
-
-* [Health Checks](dubbo-spring-boot-actuator#health-checks): http://localhost:9091/health
-* [Dubbo Endpoint](dubbo-spring-boot-actuator#endpoints): http://localhost:9091/dubbo
-
-
-
-#### [Dubbo Consumer Sample](dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer)
-
-Dubbo Service will be consumed at Spring WebMVC `Controller`.
-
-* Demo `Controller`: http://localhost:8080/sayHello?name=HelloWorld
-* [Health Checks](dubbo-spring-boot-actuator#health-checks): http://localhost:8081/actuator/health
-* [Dubbo Endpoint](dubbo-spring-boot-actuator#endpoints): http://localhost:8081/actuator/dubbo
-
+- [Auto-Configuaration Samples](dubbo-spring-boot-samples/auto-configure-samples)
+- [Externalized Configuration Samples](dubbo-spring-boot-samples/externalized-configuration-samples)
+- [Registry Zookeeper Samples](dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples)
+- [Registry Nacos Samples](dubbo-spring-boot-samples/dubbo-registry-nacos-samples)
+- [Sample API](dubbo-spring-boot-samples/sample-api)
\ No newline at end of file
diff --git a/README_CN.md b/README_CN.md
index fb19660..aa50001 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -26,7 +26,7 @@
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
- <version>0.2.0</version>
+ <version>0.2.1</version>
</dependency>
<!-- Dubbo -->
@@ -87,7 +87,7 @@
## 快速开始
-如果您对 Dubbo 不是非常了解,耽误您几分钟访问 http://dubbo.apache.org/ 。了解后,如果你期望更深入的探讨,可以移步[用户手册](http://dubbo.apache.org/books/dubbo-user-book/)。
+如果您对 Dubbo 不是非常了解,耽误您几分钟访问 http://dubbo.apache.org/ 。了解后,如果你期望更深入的探讨,可以移步[用户手册](http://dubbo.apache.org/zh-cn/docs/user/quick-start.html)。
通常情况 , Dubbo 应用有两种使用场景 , 其一为 Dubbo 服务提供方 , 另外一个是 Dubbo 服务消费方,当然也允许两者混合,下面我们一起快速开始!
diff --git a/dubbo-spring-boot-actuator/README.md b/dubbo-spring-boot-actuator/README.md
index 103aa7d..0b74034 100644
--- a/dubbo-spring-boot-actuator/README.md
+++ b/dubbo-spring-boot-actuator/README.md
@@ -23,7 +23,7 @@
* `0.1.x` is a legacy version for maintaining Spring Boot 1.x
-
+
## Integrate with Maven
@@ -33,7 +33,7 @@
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>0.2.0</version>
+ <version>0.2.1</version>
</dependency>
```
If your project failed to resolve the dependency, try to add the following repository:
@@ -162,11 +162,11 @@
| ID | Enabled | HTTP URI | HTTP Method | Description | Content Type |
| ------------------- | ----------- | ----------------------------------- | ------------------ | ------------------ | ------------------ |
| `dubbo` | `true` | `/actuator/dubbo` | `GET` | Exposes Dubbo's meta data | `application/json` |
-| `dubbo-properties` | `true` | `/actuator/dubbo/properties` | `GET` | Exposes all Dubbo's Properties | `application/json` |
-| `dubbo-services` | `false` | `/dubbo/services` | `GET` | Exposes all Dubbo's `ServiceBean` | `application/json` |
-| `dubbo-references` | `false` | `/actuator/dubbo/references` | `GET` | Exposes all Dubbo's `ReferenceBean` | `application/json` |
-| `dubbo-configs` | `true` | `/actuator/dubbo/configs` | `GET` | Exposes all Dubbo's `*Config` | `application/json` |
-| `dubbo-shutdown` | `false` | `/actuator/dubbo/shutdown` | `POST` | Shutdown Dubbo services | `application/json` |
+| `dubboProperties` | `true` | `/actuator/dubbo/properties` | `GET` | Exposes all Dubbo's Properties | `application/json` |
+| `dubboServices` | `false` | `/dubbo/services` | `GET` | Exposes all Dubbo's `ServiceBean` | `application/json` |
+| `dubboReferences` | `false` | `/actuator/dubbo/references` | `GET` | Exposes all Dubbo's `ReferenceBean` | `application/json` |
+| `dubboConfigs` | `true` | `/actuator/dubbo/configs` | `GET` | Exposes all Dubbo's `*Config` | `application/json` |
+| `dubboShutdown` | `false` | `/actuator/dubbo/shutdown` | `POST` | Shutdown Dubbo services | `application/json` |
@@ -184,7 +184,7 @@
{
"timestamp": 1516623290166,
"versions": {
- "dubbo-spring-boot": "0.2.0"
+ "dubbo-spring-boot": "0.2.0",
"dubbo": "2.6.2"
},
"urls": {
@@ -503,10 +503,10 @@
```properties
# Enables Dubbo All Endpoints
management.endpoint.dubbo.enabled = true
-management.endpoint.dubbo-shutdown.enabled = true
-management.endpoint.dubbo-configs.enabled = true
-management.endpoint.dubbo-services.enabled = true
-management.endpoint.dubbo-references.enabled = true
-management.endpoint.dubbo-properties.enabled = true
+management.endpoint.dubboshutdown.enabled = true
+management.endpoint.dubboconfigs.enabled = true
+management.endpoint.dubboservices.enabled = true
+management.endpoint.dubboreferences.enabled = true
+management.endpoint.dubboproperties.enabled = true
```
diff --git a/dubbo-spring-boot-actuator/README_CN.md b/dubbo-spring-boot-actuator/README_CN.md
index 395e3ef..14a4103 100644
--- a/dubbo-spring-boot-actuator/README_CN.md
+++ b/dubbo-spring-boot-actuator/README_CN.md
@@ -31,14 +31,14 @@
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
- <version>0.2.0</version>
+ <version>0.2.1</version>
</dependency>
<!-- Production-Ready 特性 -->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>0.2.0</version>
+ <version>0.2.1</version>
</dependency>
...
diff --git a/dubbo-spring-boot-actuator/pom.xml b/dubbo-spring-boot-actuator/pom.xml
index 70e8f20..644e5d2 100644
--- a/dubbo-spring-boot-actuator/pom.xml
+++ b/dubbo-spring-boot-actuator/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>dubbo-spring-boot-parent</artifactId>
<groupId>com.alibaba.boot</groupId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../dubbo-spring-boot-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -32,15 +32,6 @@
<dependencies>
- <!-- Compile -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointsAutoConfiguration.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointsAutoConfiguration.java
index 038e0bf..efa5b41 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointsAutoConfiguration.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointsAutoConfiguration.java
@@ -16,7 +16,13 @@
*/
package com.alibaba.boot.dubbo.actuate.autoconfigure;
-import com.alibaba.boot.dubbo.actuate.endpoint.*;
+import com.alibaba.boot.dubbo.actuate.endpoint.DubboConfigsMetadataEndpoint;
+import com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint;
+import com.alibaba.boot.dubbo.actuate.endpoint.DubboPropertiesEndpoint;
+import com.alibaba.boot.dubbo.actuate.endpoint.DubboReferencesMetadataEndpoint;
+import com.alibaba.boot.dubbo.actuate.endpoint.DubboServicesMetadataEndpoint;
+import com.alibaba.boot.dubbo.actuate.endpoint.DubboShutdownEndpoint;
+
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -27,7 +33,7 @@
/**
* Dubbo {@link Endpoint} Auto-{@link Configuration}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see Endpoint
* @see Configuration
* @since 0.2.0
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java
index c53c958..20d2cf1 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java
@@ -19,6 +19,7 @@
import com.alibaba.boot.dubbo.actuate.health.DubboHealthIndicator;
import com.alibaba.boot.dubbo.actuate.health.DubboHealthIndicatorProperties;
import com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration;
+
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.health.HealthIndicator;
@@ -33,7 +34,7 @@
/**
* Dubbo {@link DubboHealthIndicator} Auto Configuration
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see HealthIndicator
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/AbstractDubboEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/AbstractDubboEndpoint.java
index 95b8655..45a0cba 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/AbstractDubboEndpoint.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/AbstractDubboEndpoint.java
@@ -19,6 +19,7 @@
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.spring.ServiceBean;
import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor;
+
import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.context.ApplicationContext;
@@ -45,7 +46,7 @@
/**
* Abstract Dubbo {@link Endpoint @Endpoint}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @since 0.2.0
*/
public abstract class AbstractDubboEndpoint implements ApplicationContextAware, EnvironmentAware {
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java
index b5ae637..28b276a 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java
@@ -16,7 +16,18 @@
*/
package com.alibaba.boot.dubbo.actuate.endpoint;
-import com.alibaba.dubbo.config.*;
+import com.alibaba.dubbo.config.AbstractConfig;
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.ConsumerConfig;
+import com.alibaba.dubbo.config.MethodConfig;
+import com.alibaba.dubbo.config.ModuleConfig;
+import com.alibaba.dubbo.config.MonitorConfig;
+import com.alibaba.dubbo.config.ProtocolConfig;
+import com.alibaba.dubbo.config.ProviderConfig;
+import com.alibaba.dubbo.config.ReferenceConfig;
+import com.alibaba.dubbo.config.RegistryConfig;
+import com.alibaba.dubbo.config.ServiceConfig;
+
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
@@ -29,10 +40,10 @@
/**
* Dubbo Configs Metadata {@link Endpoint}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @since 0.2.0
*/
-@Endpoint(id = "dubbo-configs")
+@Endpoint(id = "dubboconfigs")
public class DubboConfigsMetadataEndpoint extends AbstractDubboEndpoint {
@ReadOperation
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java
index d5d503f..eba7b56 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java
@@ -18,37 +18,29 @@
import com.alibaba.boot.dubbo.util.DubboUtils;
import com.alibaba.dubbo.common.Version;
+
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import java.util.LinkedHashMap;
import java.util.Map;
-import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_ENDPOINT_ID;
-import static com.alibaba.boot.dubbo.util.DubboUtils.*;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_MAILING_LIST;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GIT_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_ISSUES_URL;
/**
* Actuator {@link Endpoint} to expose Dubbo Meta Data
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see Endpoint
* @since 1.0.0
*/
-@Endpoint(id = DUBBO_ENDPOINT_ID)
+@Endpoint(id = "dubbo")
public class DubboEndpoint {
- public static final String DUBBO_ENDPOINT_ID = "dubbo";
-
- public static final String DUBBO_SHUTDOWN_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-shutdown";
-
- public static final String DUBBO_CONFIGS_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-configs";
-
- public static final String DUBBO_SERVICES_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-services";
-
- public static final String DUBBO_REFERENCES_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-references";
-
- public static final String DUBBO_PROPERTIES_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-properties";
-
@ReadOperation
public Map<String, Object> invoke() {
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java
index eeec4c9..f9b9d1a 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java
@@ -21,16 +21,15 @@
import java.util.SortedMap;
-import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_PROPERTIES_ENDPOINT_ID;
import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties;
/**
* Dubbo Properties {@link Endpoint}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @since 1.0.0
*/
-@Endpoint(id = DUBBO_PROPERTIES_ENDPOINT_ID)
+@Endpoint(id = "dubboproperties")
public class DubboPropertiesEndpoint extends AbstractDubboEndpoint {
@ReadOperation
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java
index 649b066..3d4bbf6 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java
@@ -19,6 +19,7 @@
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.spring.ReferenceBean;
import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor;
+
import org.springframework.beans.factory.annotation.InjectionMetadata;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
@@ -29,10 +30,10 @@
/**
* Dubbo {@link Reference} Metadata {@link Endpoint}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @since 1.0.0
*/
-@Endpoint(id = "dubbo-references")
+@Endpoint(id = "dubboreferences")
public class DubboReferencesMetadataEndpoint extends AbstractDubboEndpoint {
@ReadOperation
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java
index 4b36484..0c4c788 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java
@@ -18,6 +18,7 @@
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.dubbo.config.spring.ServiceBean;
+
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
@@ -27,10 +28,10 @@
/**
* Dubbo {@link Service} Metadata {@link Endpoint}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @since 0.2.0
*/
-@Endpoint(id = "dubbo-services")
+@Endpoint(id = "dubboservices")
public class DubboServicesMetadataEndpoint extends AbstractDubboEndpoint {
@ReadOperation
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java
index 9ad9e83..1014800 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java
@@ -19,6 +19,7 @@
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.spring.ServiceBean;
import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor;
+
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
@@ -31,10 +32,9 @@
/**
* Dubbo Shutdown
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 0.2.0
*/
-@Endpoint(id = "dubbo-shutdown")
+@Endpoint(id = "dubboshutdown")
public class DubboShutdownEndpoint extends AbstractDubboEndpoint {
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicator.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicator.java
index 4de9022..e84a24e 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicator.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicator.java
@@ -20,6 +20,7 @@
import com.alibaba.dubbo.common.status.StatusChecker;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.ProviderConfig;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
@@ -37,7 +38,7 @@
/**
* Dubbo {@link HealthIndicator}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see HealthIndicator
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java
index bd35ed9..e6db928 100644
--- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java
+++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java
@@ -17,6 +17,7 @@
package com.alibaba.boot.dubbo.actuate.health;
import com.alibaba.dubbo.common.status.StatusChecker;
+
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -29,7 +30,7 @@
/**
* Dubbo {@link HealthIndicator} Properties
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see HealthIndicator
* @since 1.0.0
*/
@@ -53,7 +54,6 @@
/**
* The nested class for {@link StatusChecker}'s names
- * <p>
* <pre>
* registry=com.alibaba.dubbo.registry.status.RegistryStatusChecker
* spring=com.alibaba.dubbo.config.spring.status.SpringStatusChecker
diff --git a/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties b/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties
index 97a012f..ffcf188 100644
--- a/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties
+++ b/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties
@@ -4,19 +4,18 @@
# Set enabled for Dubbo Endpoints
management.endpoint.dubbo.enabled = true
-management.endpoint.dubbo-shutdown.enabled = false
-management.endpoint.dubbo-configs.enabled = true
-management.endpoint.dubbo-services.enabled = false
-management.endpoint.dubbo-references.enabled = false
-management.endpoint.dubbo-properties.enabled = true
+management.endpoint.dubboshutdown.enabled = false
+management.endpoint.dubboconfigs.enabled = true
+management.endpoint.dubboservices.enabled = false
+management.endpoint.dubboreferences.enabled = false
+management.endpoint.dubboproperties.enabled = true
# "management.endpoints.web.base-path" should not be configured in this file
# Re-defines path-mapping of Dubbo Web Endpoints
-management.endpoints.web.path-mapping.dubbo-shutdown = dubbo/shutdown
-management.endpoints.web.path-mapping.dubbo-configs = dubbo/configs
-management.endpoints.web.path-mapping.dubbo-services = dubbo/services
-management.endpoints.web.path-mapping.dubbo-references = dubbo/references
-management.endpoints.web.path-mapping.dubbo-properties = dubbo/properties
-
+management.endpoints.web.path-mapping.dubboshutdown = dubbo/shutdown
+management.endpoints.web.path-mapping.dubboconfigs = dubbo/configs
+management.endpoints.web.path-mapping.dubboservices = dubbo/services
+management.endpoints.web.path-mapping.dubboreferences = dubbo/references
+management.endpoints.web.path-mapping.dubboproperties = dubbo/properties
\ No newline at end of file
diff --git a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java
index 0135ec3..0cdfb21 100644
--- a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java
+++ b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java
@@ -17,12 +17,12 @@
package com.alibaba.boot.dubbo.actuate.endpoint;
import com.alibaba.boot.dubbo.util.DubboUtils;
+
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Map;
@@ -32,7 +32,7 @@
/**
* {@link DubboEndpoint} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see DubboEndpoint
* @since 1.0.0
*/
@@ -65,7 +65,7 @@
Assert.assertEquals(getVersion(), versions.get("dubbo"));
Assert.assertEquals("https://github.com/apache/incubator-dubbo", urls.get("dubbo"));
- Assert.assertEquals("dev@dubbo.incubator.apache.org", urls.get("mailing-list"));
+ Assert.assertEquals("dev@dubbo.apache.org", urls.get("mailing-list"));
Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project", urls.get("github"));
Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project/issues", urls.get("issues"));
Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project.git", urls.get("git"));
diff --git a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java
index 9bd190b..29e2af6 100644
--- a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java
+++ b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java
@@ -18,21 +18,26 @@
import com.alibaba.boot.dubbo.actuate.autoconfigure.DubboEndpointsAutoConfiguration;
import com.alibaba.dubbo.config.annotation.Service;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestTemplate;
import java.util.Map;
import java.util.SortedMap;
+import java.util.function.Supplier;
/**
* {@link DubboEndpointsAutoConfiguration} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 0.2.0
*/
@RunWith(SpringRunner.class)
@@ -57,11 +62,12 @@
"dubbo.provider.host=127.0.0.1",
"dubbo.scan.basePackages=com.alibaba.boot.dubbo.actuate.endpoint",
"management.endpoint.dubbo.enabled = true",
- "management.endpoint.dubbo-shutdown.enabled = true",
- "management.endpoint.dubbo-configs.enabled = true",
- "management.endpoint.dubbo-services.enabled = true",
- "management.endpoint.dubbo-references.enabled = true",
- "management.endpoint.dubbo-properties.enabled = true",
+ "management.endpoint.dubboshutdown.enabled = true",
+ "management.endpoint.dubboconfigs.enabled = true",
+ "management.endpoint.dubboservices.enabled = true",
+ "management.endpoint.dubboreferences.enabled = true",
+ "management.endpoint.dubboproperties.enabled = true",
+ "management.endpoints.web.exposure.include = *",
})
@EnableAutoConfiguration
public class DubboEndpointsAutoConfigurationTest {
@@ -84,6 +90,13 @@
@Autowired
private DubboShutdownEndpoint dubboShutdownEndpoint;
+ private RestTemplate restTemplate = new RestTemplate();
+
+ @Autowired
+ private ObjectMapper objectMapper;
+
+ @Value("http://127.0.0.1:${local.management.port}${management.endpoints.web.base-path:/actuator}")
+ private String actuatorBaseURL;
@Test
public void testShutdown() throws Exception {
@@ -143,7 +156,7 @@
Assert.assertEquals(1, services.size());
- Map<String, Object> demoServiceMeta = services.get("ServiceBean:dubboEndpointsAutoConfigurationTest.DefaultDemoService:com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpointsAutoConfigurationTest$DemoService:${dubbo.service.version}");
+ Map<String, Object> demoServiceMeta = services.get("ServiceBean:com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpointsAutoConfigurationTest$DemoService:1.0.0");
Assert.assertEquals("1.0.0", demoServiceMeta.get("version"));
@@ -177,20 +190,35 @@
Assert.assertEquals("com.alibaba.boot.dubbo.actuate.endpoint", properties.get("dubbo.scan.basePackages"));
}
-
-@Service(
- version = "${dubbo.service.version}",
- application = "${dubbo.application.id}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
-static class DefaultDemoService implements DemoService {
-
- public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
+ @Test
+ public void testHttpEndpoints() throws JsonProcessingException {
+// testHttpEndpoint("/dubbo", dubboEndpoint::invoke);
+ testHttpEndpoint("/dubbo/configs", dubboConfigsMetadataEndpoint::configs);
+ testHttpEndpoint("/dubbo/services", dubboServicesMetadataEndpoint::services);
+ testHttpEndpoint("/dubbo/references", dubboReferencesMetadataEndpoint::references);
+ testHttpEndpoint("/dubbo/properties", dubboPropertiesEndpoint::properties);
}
-}
+ private void testHttpEndpoint(String actuatorURI, Supplier<Map> resultsSupplier) throws JsonProcessingException {
+ String actuatorURL = actuatorBaseURL + actuatorURI;
+ String response = restTemplate.getForObject(actuatorURL, String.class);
+ Assert.assertEquals(objectMapper.writeValueAsString(resultsSupplier.get()), response);
+ }
+
+
+ @Service(
+ version = "${dubbo.service.version}",
+ application = "${dubbo.application.id}",
+ protocol = "${dubbo.protocol.id}",
+ registry = "${dubbo.registry.id}"
+ )
+ static class DefaultDemoService implements DemoService {
+
+ public String sayHello(String name) {
+ return "Hello, " + name + " (from Spring Boot)";
+ }
+
+ }
interface DemoService {
String sayHello(String name);
diff --git a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorTest.java b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorTest.java
index 6d736f0..41de0a8 100644
--- a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorTest.java
+++ b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorTest.java
@@ -17,6 +17,7 @@
package com.alibaba.boot.dubbo.actuate.health;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfig;
+
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,7 +34,7 @@
/**
* {@link DubboHealthIndicator} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see DubboHealthIndicator
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-autoconfigure/README.md b/dubbo-spring-boot-autoconfigure/README.md
index b5e9306..0b461ce 100644
--- a/dubbo-spring-boot-autoconfigure/README.md
+++ b/dubbo-spring-boot-autoconfigure/README.md
@@ -23,7 +23,7 @@
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-autoconfigure</artifactId>
- <version>0.2.0</version>
+ <version>0.2.1</version>
</dependency>
```
diff --git a/dubbo-spring-boot-autoconfigure/pom.xml b/dubbo-spring-boot-autoconfigure/pom.xml
index 1e892fa..f9e933a 100644
--- a/dubbo-spring-boot-autoconfigure/pom.xml
+++ b/dubbo-spring-boot-autoconfigure/pom.xml
@@ -20,15 +20,15 @@
<parent>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-parent</artifactId>
- <version>0.2.1-SNAPSHOT</version>
- <relativePath>../dubbo-spring-boot-parent</relativePath>
+ <version>${revision}</version>
+ <relativePath>../dubbo-spring-boot-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dubbo-spring-boot-autoconfigure</artifactId>
<packaging>jar</packaging>
- <name>Dubbo Spring Boot AutoConfigure</name>
- <description>Dubbo Spring Boot AutoConfigure</description>
+ <name>Dubbo Spring Boot Auto-Configure</name>
+ <description>Dubbo Spring Boot Auto-Configure</description>
<dependencies>
@@ -38,6 +38,7 @@
<artifactId>spring-boot-autoconfigure</artifactId>
<optional>true</optional>
</dependency>
+
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
@@ -58,11 +59,18 @@
<optional>true</optional>
</dependency>
+ <!-- Alibaba Spring Context extension -->
+ <dependency>
+ <groupId>com.alibaba.spring</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+
<!-- Test Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
+
</dependencies>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java
index 486c1b9..58029f4 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java
@@ -26,6 +26,7 @@
import com.alibaba.dubbo.config.spring.context.annotation.DubboConfigConfiguration;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfig;
+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -38,14 +39,15 @@
import java.util.Set;
-import static com.alibaba.boot.dubbo.util.DubboUtils.*;
+import static com.alibaba.boot.dubbo.util.DubboUtils.BASE_PACKAGES_PROPERTY_NAME;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_PREFIX;
+import static com.alibaba.boot.dubbo.util.DubboUtils.MULTIPLE_CONFIG_PROPERTY_NAME;
import static java.util.Collections.emptySet;
import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE;
/**
* Dubbo Auto {@link Configuration}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see ApplicationConfig
* @see Service
* @see Reference
@@ -60,27 +62,6 @@
public class DubboAutoConfiguration {
/**
- * Single Dubbo Config Configuration
- *
- * @see EnableDubboConfig
- * @see DubboConfigConfiguration.Single
- */
- @EnableDubboConfig
- protected static class SingleDubboConfigConfiguration {
- }
-
- /**
- * Multiple Dubbo Config Configuration , equals @EnableDubboConfig.multiple() == <code>true</code>
- *
- * @see EnableDubboConfig
- * @see DubboConfigConfiguration.Multiple
- */
- @ConditionalOnProperty(name = MULTIPLE_CONFIG_PROPERTY_NAME, havingValue = "true")
- @EnableDubboConfig(multiple = true)
- protected static class MultipleDubboConfigConfiguration {
- }
-
- /**
* Creates {@link ServiceAnnotationBeanPostProcessor} Bean
*
* @param environment {@link Environment} Bean
@@ -112,4 +93,25 @@
return new ReferenceAnnotationBeanPostProcessor();
}
+ /**
+ * Single Dubbo Config Configuration
+ *
+ * @see EnableDubboConfig
+ * @see DubboConfigConfiguration.Single
+ */
+ @EnableDubboConfig
+ protected static class SingleDubboConfigConfiguration {
+ }
+
+ /**
+ * Multiple Dubbo Config Configuration , equals @EnableDubboConfig.multiple() == <code>true</code>
+ *
+ * @see EnableDubboConfig
+ * @see DubboConfigConfiguration.Multiple
+ */
+ @ConditionalOnProperty(name = MULTIPLE_CONFIG_PROPERTY_NAME, havingValue = "true")
+ @EnableDubboConfig(multiple = true)
+ protected static class MultipleDubboConfigConfiguration {
+ }
+
}
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java
index def20f0..72a66e7 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java
@@ -19,13 +19,16 @@
import com.alibaba.dubbo.config.AbstractConfig;
import com.alibaba.dubbo.config.spring.context.properties.AbstractDubboConfigBinder;
import com.alibaba.dubbo.config.spring.context.properties.DubboConfigBinder;
+
import org.springframework.boot.context.properties.bind.BindHandler;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver;
import org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler;
import org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
import org.springframework.boot.context.properties.source.UnboundElementsSourceFilter;
+import org.springframework.core.env.PropertySource;
import static org.springframework.boot.context.properties.source.ConfigurationPropertySources.from;
@@ -33,7 +36,6 @@
* Spring Boot Relaxed {@link DubboConfigBinder} implementation
* see org.springframework.boot.context.properties.ConfigurationPropertiesBinder
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 0.1.1
*/
public class RelaxedDubboConfigBinder extends AbstractDubboConfigBinder {
@@ -41,13 +43,15 @@
@Override
public <C extends AbstractConfig> void bind(String prefix, C dubboConfig) {
+ Iterable<PropertySource<?>> propertySources = getPropertySources();
+
// Converts ConfigurationPropertySources
- Iterable<ConfigurationPropertySource> propertySources = from(getPropertySources());
+ Iterable<ConfigurationPropertySource> configurationPropertySources = from(propertySources);
// Wrap Bindable from DubboConfig instance
Bindable<C> bindable = Bindable.ofInstance(dubboConfig);
- Binder binder = new Binder(propertySources);
+ Binder binder = new Binder(configurationPropertySources, new PropertySourcesPlaceholdersResolver(propertySources));
// Get BindHandler
BindHandler bindHandler = getBindHandler();
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/AwaitingNonWebApplicationListener.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/AwaitingNonWebApplicationListener.java
index 55c3daa..b8a2234 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/AwaitingNonWebApplicationListener.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/AwaitingNonWebApplicationListener.java
@@ -21,30 +21,68 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.context.event.SmartApplicationListener;
+import org.springframework.util.ObjectUtils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
/**
* Awaiting Non-Web Spring Boot {@link ApplicationListener}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 0.1.1
*/
-public class AwaitingNonWebApplicationListener implements ApplicationListener<ApplicationReadyEvent> {
+public class AwaitingNonWebApplicationListener implements SmartApplicationListener {
private static final Logger logger = LoggerFactory.getLogger(AwaitingNonWebApplicationListener.class);
- private static final ExecutorService executorService = Executors.newSingleThreadExecutor();
-
- private static final AtomicBoolean shutdownHookRegistered = new AtomicBoolean(false);
+ private static final Class<? extends ApplicationEvent>[] SUPPORTED_APPLICATION_EVENTS =
+ of(ApplicationReadyEvent.class, ContextClosedEvent.class);
private static final AtomicBoolean awaited = new AtomicBoolean(false);
+ private final Lock lock = new ReentrantLock();
+
+ private final Condition condition = lock.newCondition();
+
+ private final ExecutorService executorService = Executors.newSingleThreadExecutor();
+
@Override
- public void onApplicationEvent(ApplicationReadyEvent event) {
+ public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
+ return ObjectUtils.containsElement(SUPPORTED_APPLICATION_EVENTS, eventType);
+ }
+
+ @Override
+ public boolean supportsSourceType(Class<?> sourceType) {
+ return true;
+ }
+
+ private static <T> T[] of(T... values) {
+ return values;
+ }
+
+ @Override
+ public void onApplicationEvent(ApplicationEvent event) {
+ if (event instanceof ApplicationReadyEvent) {
+ onApplicationReadyEvent((ApplicationReadyEvent) event);
+ } else if (event instanceof ContextClosedEvent) {
+ onContextClosedEvent((ContextClosedEvent) event);
+ }
+ }
+
+ @Override
+ public int getOrder() {
+ return LOWEST_PRECEDENCE;
+ }
+
+ protected void onApplicationReadyEvent(ApplicationReadyEvent event) {
final SpringApplication springApplication = event.getSpringApplication();
@@ -52,46 +90,64 @@
return;
}
- executorService.execute(new Runnable() {
- @Override
- public void run() {
+ await();
- synchronized (springApplication) {
- if (logger.isInfoEnabled()) {
- logger.info(" [Dubbo] Current Spring Boot Application is await...");
- }
- while (!awaited.get()) {
- try {
- springApplication.wait();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
+ }
+
+ protected void onContextClosedEvent(ContextClosedEvent event) {
+ release();
+ shutdown();
+ }
+
+ protected void await() {
+
+ // has been waited, return immediately
+ if (awaited.get()) {
+ return;
+ }
+
+ executorService.execute(() -> executeMutually(() -> {
+ while (!awaited.get()) {
+ if (logger.isInfoEnabled()) {
+ logger.info(" [Dubbo] Current Spring Boot Application is await...");
+ }
+ try {
+ condition.await();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
}
}
- });
+ }));
+ }
- // register ShutdownHook
- if (shutdownHookRegistered.compareAndSet(false, true)) {
- registerShutdownHook(new Thread(new Runnable() {
- @Override
- public void run() {
- synchronized (springApplication) {
- if (awaited.compareAndSet(false, true)) {
- springApplication.notifyAll();
- if (logger.isInfoEnabled()) {
- logger.info(" [Dubbo] Current Spring Boot Application is about to shutdown...");
- }
- // Shutdown executorService
- executorService.shutdown();
- }
- }
+ protected void release() {
+ executeMutually(() -> {
+ while (awaited.compareAndSet(false, true)) {
+ if (logger.isInfoEnabled()) {
+ logger.info(" [Dubbo] Current Spring Boot Application is about to shutdown...");
}
- }));
+ condition.signalAll();
+ }
+ });
+ }
+
+ private void shutdown() {
+ if (!executorService.isShutdown()) {
+ // Shutdown executorService
+ executorService.shutdown();
}
}
- private void registerShutdownHook(Thread thread) {
- Runtime.getRuntime().addShutdownHook(thread);
+ private void executeMutually(Runnable runnable) {
+ try {
+ lock.lock();
+ runnable.run();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ static AtomicBoolean getAwaited() {
+ return awaited;
}
}
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java
index 33ac29b..e2a2363 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java
@@ -18,6 +18,7 @@
import com.alibaba.dubbo.common.utils.ConfigUtils;
import com.alibaba.dubbo.config.AbstractConfig;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
@@ -28,7 +29,9 @@
import java.util.SortedMap;
-import static com.alibaba.boot.dubbo.util.DubboUtils.*;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE;
+import static com.alibaba.boot.dubbo.util.DubboUtils.OVERRIDE_CONFIG_PROPERTY_NAME;
+import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties;
/**
* {@link ApplicationListener} to override the dubbo properties from {@link Environment}into
@@ -36,7 +39,6 @@
* {@link AbstractConfig Dubbo Config} on {@link ApplicationEnvironmentPreparedEvent}.
* <p>
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see ConfigUtils
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java
index ae9682c..9802a3b 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java
@@ -17,6 +17,7 @@
package com.alibaba.boot.dubbo.context.event;
import com.alibaba.dubbo.common.Version;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
@@ -24,23 +25,32 @@
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
-import static com.alibaba.boot.dubbo.util.DubboUtils.*;
-import static com.alibaba.dubbo.qos.server.DubboLogo.dubbo;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_MAILING_LIST;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.LINE_SEPARATOR;
/**
* Dubbo Welcome Logo {@link ApplicationListener}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see ApplicationListener
* @since 1.0.0
*/
@Order(LoggingApplicationListener.DEFAULT_ORDER + 1)
public class WelcomeLogoApplicationListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {
+ private static AtomicBoolean processed = new AtomicBoolean(false);
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
+ // Skip if processed before, prevent duplicated execution in Hierarchical ApplicationContext
+ if (processed.get()) {
+ return;
+ }
+
/**
* Gets Logger After LoggingSystem configuration ready
* @see LoggingApplicationListener
@@ -55,9 +65,10 @@
System.out.print(bannerText);
}
+ // mark processed to be true
+ processed.compareAndSet(false, true);
}
-
String buildBannerText() {
StringBuilder bannerTextBuilder = new StringBuilder();
@@ -71,7 +82,7 @@
.append(" :: Dubbo (v").append(Version.getVersion()).append(") : ")
.append(DUBBO_GITHUB_URL)
.append(LINE_SEPARATOR)
- .append(" :: Google group : ")
+ .append(" :: Discuss group : ")
.append(DUBBO_MAILING_LIST)
.append(LINE_SEPARATOR)
;
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
new file mode 100644
index 0000000..3292bf9
--- /dev/null
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
@@ -0,0 +1,142 @@
+/*
+ * 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 com.alibaba.boot.dubbo.env;
+
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfig;
+import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfigBinding;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.context.ContextIdApplicationContextInitializer;
+import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * The lowest precedence {@link EnvironmentPostProcessor} processes
+ * {@link SpringApplication#setDefaultProperties(Properties) Spring Boot default properties} for Dubbo
+ * as late as possible before {@link ConfigurableApplicationContext#refresh() application context refresh}.
+ */
+public class DubboDefaultPropertiesEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
+
+ /**
+ * The name of default {@link PropertySource} defined in SpringApplication#configurePropertySources method.
+ */
+ private static final String PROPERTY_SOURCE_NAME = "defaultProperties";
+
+ /**
+ * The property name of Spring Application
+ *
+ * @see ContextIdApplicationContextInitializer
+ */
+ private static final String SPRING_APPLICATION_NAME_PROPERTY = "spring.application.name";
+
+ /**
+ * The property name of {@link ApplicationConfig}
+ *
+ * @see EnableDubboConfig
+ * @see EnableDubboConfigBinding
+ */
+ private static final String DUBBO_APPLICATION_NAME_PROPERTY = "dubbo.application.name";
+
+ /**
+ * The property name of {@link EnableDubboConfig#multiple() @EnableDubboConfig.multiple()}
+ */
+ private static final String DUBBO_CONFIG_MULTIPLE_PROPERTY = "dubbo.config.multiple";
+
+ /**
+ * The property name of {@link ApplicationConfig#getQosEnable() application's QOS enable}
+ */
+ private static final String DUBBO_APPLICATION_QOS_ENABLE_PROPERTY = "dubbo.application.qos-enable";
+
+ @Override
+ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
+ MutablePropertySources propertySources = environment.getPropertySources();
+ Map<String, Object> defaultProperties = createDefaultProperties(environment);
+ if (!CollectionUtils.isEmpty(defaultProperties)) {
+ addOrReplace(propertySources, defaultProperties);
+ }
+ }
+
+ @Override
+ public int getOrder() {
+ return LOWEST_PRECEDENCE;
+ }
+
+ private Map<String, Object> createDefaultProperties(ConfigurableEnvironment environment) {
+ Map<String, Object> defaultProperties = new HashMap<String, Object>();
+ setDubboApplicationNameProperty(environment, defaultProperties);
+ setDubboConfigMultipleProperty(defaultProperties);
+ setDubboApplicationQosEnableProperty(defaultProperties);
+ return defaultProperties;
+ }
+
+ private void setDubboApplicationNameProperty(Environment environment, Map<String, Object> defaultProperties) {
+ String springApplicationName = environment.getProperty(SPRING_APPLICATION_NAME_PROPERTY);
+ if (StringUtils.hasLength(springApplicationName)
+ && !environment.containsProperty(DUBBO_APPLICATION_NAME_PROPERTY)) {
+ defaultProperties.put(DUBBO_APPLICATION_NAME_PROPERTY, springApplicationName);
+ }
+ }
+
+ private void setDubboConfigMultipleProperty(Map<String, Object> defaultProperties) {
+ defaultProperties.put(DUBBO_CONFIG_MULTIPLE_PROPERTY, Boolean.TRUE.toString());
+ }
+
+ private void setDubboApplicationQosEnableProperty(Map<String, Object> defaultProperties) {
+ defaultProperties.put(DUBBO_APPLICATION_QOS_ENABLE_PROPERTY, Boolean.FALSE.toString());
+ }
+
+ /**
+ * Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)
+ *
+ * @param propertySources {@link MutablePropertySources}
+ * @param map Default Dubbo Properties
+ */
+ private void addOrReplace(MutablePropertySources propertySources,
+ Map<String, Object> map) {
+ MapPropertySource target = null;
+ if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
+ PropertySource<?> source = propertySources.get(PROPERTY_SOURCE_NAME);
+ if (source instanceof MapPropertySource) {
+ target = (MapPropertySource) source;
+ for (String key : map.keySet()) {
+ if (!target.containsProperty(key)) {
+ target.getSource().put(key, map.get(key));
+ }
+ }
+ }
+ }
+ if (target == null) {
+ target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
+ }
+ if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
+ propertySources.addLast(target);
+ }
+ }
+}
\ No newline at end of file
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java
index edf4ab2..59cde99 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java
@@ -16,16 +16,16 @@
*/
package com.alibaba.boot.dubbo.util;
+import org.springframework.core.env.ConfigurableEnvironment;
+
import java.util.Collections;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
-import org.springframework.core.env.ConfigurableEnvironment;
/**
* The utilities class for Dubbo
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 1.0.0
*/
public abstract class DubboUtils {
@@ -61,7 +61,7 @@
* <p>
* The default value is empty set.
*/
- public static final String BASE_PACKAGES_PROPERTY_NAME = DUBBO_SCAN_PREFIX + PROPERTY_NAME_SEPARATOR + "basePackages";
+ public static final String BASE_PACKAGES_PROPERTY_NAME = DUBBO_SCAN_PREFIX + PROPERTY_NAME_SEPARATOR + "base-packages";
/**
* The property name of multiple properties binding from externalized configuration
@@ -111,7 +111,7 @@
/**
* The google group URL of Dubbo
*/
- public static final String DUBBO_MAILING_LIST = "dev@dubbo.incubator.apache.org";
+ public static final String DUBBO_MAILING_LIST = "dev@dubbo.apache.org";
/**
* Filters Dubbo Properties from {@link ConfigurableEnvironment}
@@ -129,7 +129,7 @@
String propertyName = entry.getKey();
if (propertyName.startsWith(DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR)
- && entry.getValue() != null) {
+ && entry.getValue() != null) {
dubboProperties.put(propertyName, entry.getValue().toString());
}
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java
index 9349d81..9b20c58 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java
@@ -16,7 +16,12 @@
*/
package com.alibaba.boot.dubbo.util;
-import org.springframework.core.env.*;
+import org.springframework.core.env.CompositePropertySource;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.EnumerablePropertySource;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
import org.springframework.util.ObjectUtils;
import java.util.Collections;
@@ -26,7 +31,6 @@
/**
* The utilities class for {@link Environment}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see Environment
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json
index 078dae9..7ce2cee 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json
+++ b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json
@@ -1090,8 +1090,8 @@
},
{
"sourceType": "com.alibaba.boot.dubbo.autoconfigure.DubboScanProperties",
- "name": "dubbo.scan.basePackages",
- "description": "The basePackages to scan , the multiple-value is delimited by comma\n\n @see EnableDubbo#scanBasePackages()",
+ "name": "dubbo.scan.base-packages",
+ "description": "The base-packages to scan , the multiple-value is delimited by comma\n\n @see EnableDubbo#scanBasePackages()",
"type": "java.util.Set<java.lang.String>"
}
]
diff --git a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
index 52fe93c..4ea2a1a 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
+++ b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
@@ -5,4 +5,7 @@
org.springframework.context.ApplicationListener=\
com.alibaba.boot.dubbo.context.event.OverrideDubboConfigApplicationListener,\
com.alibaba.boot.dubbo.context.event.WelcomeLogoApplicationListener,\
-com.alibaba.boot.dubbo.context.event.AwaitingNonWebApplicationListener
\ No newline at end of file
+com.alibaba.boot.dubbo.context.event.AwaitingNonWebApplicationListener
+
+org.springframework.boot.env.EnvironmentPostProcessor=\
+com.alibaba.boot.dubbo.env.DubboDefaultPropertiesEnvironmentPostProcessor
\ No newline at end of file
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java
index ee93509..4163ac0 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java
@@ -16,10 +16,15 @@
*/
package com.alibaba.boot.dubbo.autoconfigure;
-import com.alibaba.dubbo.config.*;
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.ConsumerConfig;
+import com.alibaba.dubbo.config.ModuleConfig;
+import com.alibaba.dubbo.config.MonitorConfig;
+import com.alibaba.dubbo.config.ProtocolConfig;
+import com.alibaba.dubbo.config.ProviderConfig;
+import com.alibaba.dubbo.config.RegistryConfig;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,7 +43,7 @@
/**
* {@link DubboAutoConfiguration} Test On multiple Dubbo Configuration
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @since 1.0.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@@ -148,7 +153,7 @@
public void testMultipleDubboConfigBindingProperties() {
- Assert.assertEquals(2, applications.size());
+ Assert.assertEquals(3, applications.size());
Assert.assertEquals(1, modules.size());
@@ -172,7 +177,7 @@
*/
Map<String, ApplicationConfig> applications = beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class);
- Assert.assertEquals(2, applications.size());
+ Assert.assertEquals(3, applications.size());
/**
* Multiple {@link ModuleConfig}
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java
index c8092d3..7f4cd5e 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java
@@ -16,9 +16,16 @@
*/
package com.alibaba.boot.dubbo.autoconfigure;
-import com.alibaba.dubbo.config.*;
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.ConsumerConfig;
+import com.alibaba.dubbo.config.ModuleConfig;
+import com.alibaba.dubbo.config.MonitorConfig;
+import com.alibaba.dubbo.config.ProtocolConfig;
+import com.alibaba.dubbo.config.ProviderConfig;
+import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor;
import com.alibaba.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor;
+
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,7 +39,6 @@
/**
* {@link DubboAutoConfiguration} Test On single Dubbo Configuration
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 1.0.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@@ -144,7 +150,7 @@
@Test
public void testMultipleDubboConfigConfiguration() {
- Assert.assertNull(multipleDubboConfigConfiguration);
+ Assert.assertNotNull(multipleDubboConfigConfiguration);
}
@Test
@@ -154,7 +160,7 @@
@Test
public void testServiceAnnotationBeanPostProcessor() {
- Assert.assertNull(multipleDubboConfigConfiguration);
+ Assert.assertNotNull(multipleDubboConfigConfiguration);
}
}
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinderTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinderTest.java
index 8e08086..0a151ba 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinderTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinderTest.java
@@ -19,6 +19,7 @@
import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.RegistryConfig;
+
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,7 +31,7 @@
/**
* {@link RelaxedDubboConfigBinder} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @since 0.1.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/AwaitingNonWebApplicationListenerTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/AwaitingNonWebApplicationListenerTest.java
new file mode 100644
index 0000000..42710cd
--- /dev/null
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/AwaitingNonWebApplicationListenerTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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 com.alibaba.boot.dubbo.context.event;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * {@link AwaitingNonWebApplicationListener} Test
+ */
+public class AwaitingNonWebApplicationListenerTest {
+
+ @Test
+ public void init() {
+ AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
+ awaited.set(false);
+
+ }
+
+ @Test
+ public void testSingleContextNonWebApplication() {
+ new SpringApplicationBuilder(Object.class)
+ .web(WebApplicationType.NONE)
+ .run().close();
+ AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
+ Assert.assertTrue(awaited.get());
+ }
+
+ @Test
+ public void testMultipleContextNonWebApplication() {
+ new SpringApplicationBuilder(Object.class)
+ .parent(Object.class)
+ .web(WebApplicationType.NONE)
+ .run().close();
+ AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
+ Assert.assertTrue(awaited.get());
+ }
+
+}
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerDisableTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerDisableTest.java
index c425b83..c69e5f5 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerDisableTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerDisableTest.java
@@ -17,6 +17,7 @@
package com.alibaba.boot.dubbo.context.event;
import com.alibaba.dubbo.common.utils.ConfigUtils;
+
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -30,7 +31,7 @@
/**
* {@link OverrideDubboConfigApplicationListener} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see OverrideDubboConfigApplicationListener
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerTest.java
index c7d98d0..2fd7cd1 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListenerTest.java
@@ -17,6 +17,7 @@
package com.alibaba.boot.dubbo.context.event;
import com.alibaba.dubbo.common.utils.ConfigUtils;
+
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -30,7 +31,7 @@
/**
* {@link OverrideDubboConfigApplicationListener} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see OverrideDubboConfigApplicationListener
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListenerTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListenerTest.java
index b603264..34bb971 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListenerTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListenerTest.java
@@ -26,7 +26,7 @@
/**
* {@link WelcomeLogoApplicationListener} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see WelcomeLogoApplicationListener
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
new file mode 100644
index 0000000..d941a4f
--- /dev/null
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 com.alibaba.boot.dubbo.env;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.boot.SpringApplication;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
+import org.springframework.mock.env.MockEnvironment;
+
+import java.util.HashMap;
+
+/**
+ * {@link DubboDefaultPropertiesEnvironmentPostProcessor} Test
+ */
+public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
+
+ private DubboDefaultPropertiesEnvironmentPostProcessor instance =
+ new DubboDefaultPropertiesEnvironmentPostProcessor();
+
+ private SpringApplication springApplication = new SpringApplication();
+
+ @Test
+ public void testOrder() {
+ Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder());
+ }
+
+ @Test
+ public void testPostProcessEnvironment() {
+ MockEnvironment environment = new MockEnvironment();
+ // Case 1 : Not Any property
+ instance.postProcessEnvironment(environment, springApplication);
+ // Get PropertySources
+ MutablePropertySources propertySources = environment.getPropertySources();
+ // Nothing to change
+ PropertySource defaultPropertySource = propertySources.get("defaultProperties");
+ Assert.assertNotNull(defaultPropertySource);
+ Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple"));
+ Assert.assertEquals("false", defaultPropertySource.getProperty("dubbo.application.qos-enable"));
+
+ // Case 2 : Only set property "spring.application.name"
+ environment.setProperty("spring.application.name", "demo-dubbo-application");
+ instance.postProcessEnvironment(environment, springApplication);
+ defaultPropertySource = propertySources.get("defaultProperties");
+ Object dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
+ Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+
+ // Case 3 : Only set property "dubbo.application.name"
+ // Rest environment
+ environment = new MockEnvironment();
+ propertySources = environment.getPropertySources();
+ environment.setProperty("dubbo.application.name", "demo-dubbo-application");
+ instance.postProcessEnvironment(environment, springApplication);
+ defaultPropertySource = propertySources.get("defaultProperties");
+ Assert.assertNotNull(defaultPropertySource);
+ dubboApplicationName = environment.getProperty("dubbo.application.name");
+ Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+
+ // Case 4 : If "defaultProperties" PropertySource is present in PropertySources
+ // Rest environment
+ environment = new MockEnvironment();
+ propertySources = environment.getPropertySources();
+ propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap<String, Object>()));
+ environment.setProperty("spring.application.name", "demo-dubbo-application");
+ instance.postProcessEnvironment(environment, springApplication);
+ defaultPropertySource = propertySources.get("defaultProperties");
+ dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
+ Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+
+ // Case 5 : Rest dubbo.config.multiple and dubbo.application.qos-enable
+ environment = new MockEnvironment();
+ propertySources = environment.getPropertySources();
+ propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap<String, Object>()));
+ environment.setProperty("dubbo.config.multiple", "false");
+ environment.setProperty("dubbo.application.qos-enable", "true");
+ instance.postProcessEnvironment(environment, springApplication);
+ Assert.assertEquals("false", environment.getProperty("dubbo.config.multiple"));
+ Assert.assertEquals("true", environment.getProperty("dubbo.application.qos-enable"));
+ }
+}
\ No newline at end of file
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java
index 94df5d0..c972dc8 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java
@@ -22,12 +22,25 @@
import java.util.SortedMap;
-import static com.alibaba.boot.dubbo.util.DubboUtils.*;
+import static com.alibaba.boot.dubbo.util.DubboUtils.BASE_PACKAGES_PROPERTY_NAME;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_CONFIG_PREFIX;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_MAILING_LIST;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_PREFIX;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SCAN_PREFIX;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GIT_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_ISSUES_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.MULTIPLE_CONFIG_PROPERTY_NAME;
+import static com.alibaba.boot.dubbo.util.DubboUtils.OVERRIDE_CONFIG_PROPERTY_NAME;
+import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties;
/**
* {@link DubboUtils} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see DubboUtils
* @since 1.0.0
*/
@@ -40,7 +53,7 @@
Assert.assertEquals("dubbo.scan", DUBBO_SCAN_PREFIX);
- Assert.assertEquals("dubbo.scan.basePackages", BASE_PACKAGES_PROPERTY_NAME);
+ Assert.assertEquals("dubbo.scan.base-packages", BASE_PACKAGES_PROPERTY_NAME);
Assert.assertEquals("dubbo.config", DUBBO_CONFIG_PREFIX);
@@ -54,7 +67,7 @@
Assert.assertEquals("https://github.com/apache/incubator-dubbo", DUBBO_GITHUB_URL);
- Assert.assertEquals("dev@dubbo.incubator.apache.org", DUBBO_MAILING_LIST);
+ Assert.assertEquals("dev@dubbo.apache.org", DUBBO_MAILING_LIST);
Assert.assertFalse(DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE);
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/EnvironmentUtilsTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/EnvironmentUtilsTest.java
index d22ba49..9155471 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/EnvironmentUtilsTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/EnvironmentUtilsTest.java
@@ -29,7 +29,7 @@
/**
* {@link EnvironmentUtils} Test
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
+ *
* @see EnvironmentUtils
* @since 1.0.0
*/
diff --git a/dubbo-spring-boot-distribution/assembly/bin-release.xml b/dubbo-spring-boot-distribution/assembly/bin-release.xml
new file mode 100644
index 0000000..1a94381
--- /dev/null
+++ b/dubbo-spring-boot-distribution/assembly/bin-release.xml
@@ -0,0 +1,50 @@
+<!--
+ 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.
+ -->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <id>bin-release</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>${project.build.finalName}-bin-release</baseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>../</directory>
+ <includes>
+ <include>DISCLAIMER</include>
+ <include>NOTICE</include>
+ <include>LICENSE</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>true</useProjectArtifact>
+ <unpack>false</unpack>
+ <outputDirectory>/libs</outputDirectory>
+ <scope>runtime</scope>
+ <includes>
+ <include>com.alibaba.boot:*</include>
+ </includes>
+ <excludes>
+ <exclude>com.alibaba:fastjson</exclude>
+ </excludes>
+ </dependencySet>
+ </dependencySets>
+</assembly>
diff --git a/dubbo-spring-boot-distribution/assembly/source-release.xml b/dubbo-spring-boot-distribution/assembly/source-release.xml
new file mode 100644
index 0000000..bbbec61
--- /dev/null
+++ b/dubbo-spring-boot-distribution/assembly/source-release.xml
@@ -0,0 +1,55 @@
+<!--
+ 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.
+ -->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <id>source-release</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>${project.build.finalName}-source-release</baseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>../</directory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>**/target/**</exclude>
+ <exclude>**/build/**</exclude>
+ <exclude>**/eclipse-classes/**</exclude>
+ <exclude>*.enc</exclude>
+ <exclude>*.gpg</exclude>
+ <exclude>**/surefire*</exclude>
+ <exclude>**/svn-commit*</exclude>
+ <exclude>**/.idea/**</exclude>
+ <exclude>**/*.iml</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iws</exclude>
+ <exclude>**/cobertura.ser</exclude>
+ <exclude>**/*.log</exclude>
+ <exclude>release.properties</exclude>
+ <exclude>**/*.xml.*</exclude>
+ <exclude>**/.mvn/**</exclude>
+ <exclude>**/*.jar</exclude>
+ <exclude>**/mvnw*</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/dubbo-spring-boot-distribution/pom.xml b/dubbo-spring-boot-distribution/pom.xml
new file mode 100644
index 0000000..377375b
--- /dev/null
+++ b/dubbo-spring-boot-distribution/pom.xml
@@ -0,0 +1,113 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>com.alibaba.boot</groupId>
+ <artifactId>dubbo-spring-boot-parent</artifactId>
+ <version>${revision}</version>
+ <relativePath>../dubbo-spring-boot-parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-spring-boot-distribution</artifactId>
+ <packaging>pom</packaging>
+ <name>Dubbo Spring Boot Distribution</name>
+ <description>Dubbo Spring Boot Distribution</description>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>dubbo-spring-boot-actuator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>dubbo-spring-boot-autoconfigure</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+ <build>
+ <finalName>apache-dubbo-spring-boot-project-incubating-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>bin-release</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>assembly/bin-release.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>source-release</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>assembly/source-release.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8.2</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+
+</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-parent/pom.xml b/dubbo-spring-boot-parent/pom.xml
index b22a36d..c583e0f 100644
--- a/dubbo-spring-boot-parent/pom.xml
+++ b/dubbo-spring-boot-parent/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-project</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -37,11 +37,10 @@
<java.target.version>1.8</java.target.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <spring-boot.version>2.0.3.RELEASE</spring-boot.version>
- <dubbo.version>2.6.2</dubbo.version>
- <zkclient.version>0.2</zkclient.version>
- <zookeeper.version>3.4.9</zookeeper.version>
- <curator-framework.version>2.12.0</curator-framework.version>
+ <spring-boot.version>2.1.1.RELEASE</spring-boot.version>
+ <dubbo.version>2.6.5</dubbo.version>
+ <dubbo-registry-nacos.version>0.0.2</dubbo-registry-nacos.version>
+ <nacos-client.version>0.6.2</nacos-client.version>
<!-- Build args -->
<argline>-server -Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8
-Djava.net.preferIPv4Stack=true
@@ -52,16 +51,16 @@
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
- <maven-jacoco-plugin.version>0.8.1</maven-jacoco-plugin.version>
+ <maven-jacoco-plugin.version>0.8.2</maven-jacoco-plugin.version>
<maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
<apache-rat-plugin.version>0.12</apache-rat-plugin.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
+ <alibaba-spring-context-support.version>1.0.2</alibaba-spring-context-support.version>
</properties>
<dependencyManagement>
<dependencies>
-
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -71,6 +70,15 @@
<scope>import</scope>
</dependency>
+ <!-- Dubbo dependencies -->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-dependencies-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
<!-- Dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
@@ -92,47 +100,18 @@
</exclusions>
</dependency>
- <!-- ZK -->
+ <!-- Dubbo Nacos registry dependency -->
<dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zookeeper.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ <version>${dubbo-registry-nacos.version}</version>
</dependency>
+ <!-- Keep latest Nacos client version -->
<dependency>
- <groupId>com.101tec</groupId>
- <artifactId>zkclient</artifactId>
- <version>${zkclient.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>slf4j-api</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>log4j</artifactId>
- <groupId>log4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>slf4j-log4j12</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator-framework.version}</version>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos-client.version}</version>
</dependency>
</dependencies>
@@ -416,6 +395,8 @@
<exclude>**/*.fc</exclude>
<exclude>**/*.javascript</exclude>
<exclude>**/*.properties</exclude>
+ <exclude>**/*.yml</exclude>
+ <exclude>**/*.yaml</exclude>
<exclude>**/*.thrift</exclude>
<exclude>**/*.sh</exclude>
<exclude>**/*.bat</exclude>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/pom.xml
similarity index 75%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/pom.xml
index 1dc600b..1c1920f 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/pom.xml
@@ -14,20 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
-
+ <artifactId>dubbo-spring-boot-auto-configure-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Auto-Configure :: Consumer Sample</name>
<dependencies>
<!-- Spring Boot dependencies -->
@@ -37,20 +36,14 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
@@ -78,5 +71,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java
new file mode 100644
index 0000000..d84b96e
--- /dev/null
+++ b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java
@@ -0,0 +1,52 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Auto Configuration Consumer Bootstrap
+ *
+ * @since 1.0.0
+ */
+@EnableAutoConfiguration
+public class DubboAutoConfigurationConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "1.0.0", url = "dubbo://localhost:12345")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return args -> {
+ logger.info(demoService.sayHello("mercyblitz"));
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboAutoConfigurationConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..cb7b133
--- /dev/null
+++ b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,3 @@
+spring:
+ application:
+ name: dubbo-auto-configure-consumer-sample
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/auto-configure-samples/pom.xml
similarity index 66%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/auto-configure-samples/pom.xml
index bac2c4c..c994694 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/auto-configure-samples/pom.xml
@@ -14,18 +14,25 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Auto-Configure</name>
+ <description>Dubbo Spring Boot Auto-Configure Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/pom.xml
similarity index 75%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/auto-configure-samples/provider-sample/pom.xml
index 1dc600b..8d8e322 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/pom.xml
@@ -14,19 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
+ <artifactId>dubbo-spring-boot-auto-configure-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Auto-Configure :: Provider Sample</name>
<dependencies>
@@ -37,20 +37,14 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboAutoConfigurationProviderBootstrap.java
similarity index 80%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
rename to dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboAutoConfigurationProviderBootstrap.java
index a252032..012746b 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboAutoConfigurationProviderBootstrap.java
@@ -17,26 +17,23 @@
package com.alibaba.boot.dubbo.demo.provider.bootstrap;
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
+
import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
/**
- * Dubbo Provider Demo
+ * Dubbo Auto-Configuration Provider Bootstrap
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see DefaultDemoService
* @since 1.0.0
*/
-@SpringBootApplication
-public class DubboProviderDemo {
+@EnableAutoConfiguration
+public class DubboAutoConfigurationProviderBootstrap {
public static void main(String[] args) {
-
- new SpringApplicationBuilder(DubboProviderDemo.class)
+ new SpringApplicationBuilder(DubboAutoConfigurationProviderBootstrap.class)
.web(WebApplicationType.NONE)
.run(args);
-
}
-
}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 77%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
rename to dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index 48bfc22..01dfccc 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -19,23 +19,24 @@
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Default {@link DemoService}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see DemoService
* @since 1.0.0
*/
-@Service(
- version = "${demo.service.version}",
- application = "${dubbo.application.id}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
+@Service(version = "1.0.0")
public class DefaultDemoService implements DemoService {
- public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
- }
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+ public String sayHello(String name) {
+ return String.format("[%s] : Hello, %s", serviceName, name);
+ }
}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..85e8400
--- /dev/null
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,12 @@
+# Spring boot application
+spring.application.name=dubbo-auto-configuration-provider-demo
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=12345
+## Dubbo Registry
+dubbo.registry.address=N/A
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/pom.xml
similarity index 68%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/pom.xml
index 1dc600b..2f11091 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/pom.xml
@@ -14,22 +14,21 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-nacos-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
+ <artifactId>dubbo-spring-boot-registry-nacos-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Nacos :: Consumer Sample</name>
<dependencies>
-
<!-- Spring Boot dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -37,20 +36,15 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
+ <!-- Dubbo -->
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
@@ -59,6 +53,24 @@
<version>${project.version}</version>
</dependency>
+ <!-- Netty -->
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
+
+ <!-- Dubbo Nacos registry dependency -->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ </dependency>
+
+ <!-- Keep latest Nacos client version -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ </dependency>
+
</dependencies>
<build>
@@ -78,5 +90,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryNacosConsumerBootstrap.java b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryNacosConsumerBootstrap.java
new file mode 100644
index 0000000..408fe5e
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryNacosConsumerBootstrap.java
@@ -0,0 +1,50 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Registry Nacos Consumer Bootstrap
+ */
+@EnableAutoConfiguration
+public class DubboRegistryNacosConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "${demo.service.version}")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return args -> {
+ logger.info(demoService.sayHello("mercyblitz"));
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboRegistryNacosConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..7889cf7
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,11 @@
+spring:
+ application:
+ name: dubbo-registry-nacos-consumer-sample
+
+demo:
+ service:
+ version: 1.0.0
+
+dubbo:
+ registry:
+ address: nacos://127.0.0.1:8848
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/pom.xml
similarity index 66%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/pom.xml
index bac2c4c..32e2816 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/pom.xml
@@ -14,18 +14,25 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-registry-nacos-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Nacos</name>
+ <description>Dubbo Spring Boot Registry Nacos Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/pom.xml
similarity index 68%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml
rename to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/pom.xml
index dec0ef0..93740db 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/pom.xml
@@ -14,19 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-nacos-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-consumer</artifactId>
- <name>Dubbo Spring Boot Sample : Consumer</name>
+ <artifactId>dubbo-spring-boot-registry-nacos-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Nacos :: Provider Sample</name>
<dependencies>
@@ -37,20 +37,15 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
+ <!-- Dubbo -->
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
@@ -59,6 +54,23 @@
<version>${project.version}</version>
</dependency>
+ <!-- Netty -->
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
+
+ <!-- Dubbo Nacos registry dependency -->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ </dependency>
+
+ <!-- Keep latest Nacos client version -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ </dependency>
</dependencies>
<build>
@@ -78,4 +90,5 @@
</plugins>
</build>
+
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryNacosProviderBootstrap.java
similarity index 79%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
copy to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryNacosProviderBootstrap.java
index a252032..361a392 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryNacosProviderBootstrap.java
@@ -17,26 +17,23 @@
package com.alibaba.boot.dubbo.demo.provider.bootstrap;
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
+
import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
/**
- * Dubbo Provider Demo
+ * Dubbo Registry ZooKeeper Provider Bootstrap
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see DefaultDemoService
* @since 1.0.0
*/
-@SpringBootApplication
-public class DubboProviderDemo {
+@EnableAutoConfiguration
+public class DubboRegistryNacosProviderBootstrap {
public static void main(String[] args) {
-
- new SpringApplicationBuilder(DubboProviderDemo.class)
+ new SpringApplicationBuilder(DubboRegistryNacosProviderBootstrap.class)
.web(WebApplicationType.NONE)
- .run(args);
-
+ .run();
}
-
}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 76%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
copy to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index 48bfc22..f1d9ae1 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -19,23 +19,24 @@
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Default {@link DemoService}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see DemoService
* @since 1.0.0
*/
-@Service(
- version = "${demo.service.version}",
- application = "${dubbo.application.id}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
+@Service(version = "${demo.service.version}")
public class DefaultDemoService implements DemoService {
- public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
- }
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+ public String sayHello(String name) {
+ return String.format("[%s] : Hello, %s", serviceName, name);
+ }
}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..91635fb
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+# Spring boot application
+spring.application.name=dubbo-registry-nacos-provider-sample
+
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+## Random port
+dubbo.protocol.port=-1
+
+## Dubbo Registry
+dubbo.registry.address=nacos://127.0.0.1:8848
+
+## DemoService version
+demo.service.version=1.0.0
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/pom.xml
similarity index 77%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
rename to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/pom.xml
index 1dc600b..375c279 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/pom.xml
@@ -14,20 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
-
+ <artifactId>dubbo-spring-boot-registry-zookeeper-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Zookeeper :: Consumer Sample</name>
<dependencies>
<!-- Spring Boot dependencies -->
@@ -37,20 +36,14 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
@@ -59,6 +52,11 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ </dependency>
+
</dependencies>
<build>
@@ -78,5 +76,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryZooKeeperConsumerBootstrap.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryZooKeeperConsumerBootstrap.java
new file mode 100644
index 0000000..1b7935b
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryZooKeeperConsumerBootstrap.java
@@ -0,0 +1,50 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Registry ZooKeeper Consumer Bootstrap
+ */
+@EnableAutoConfiguration
+public class DubboRegistryZooKeeperConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "${demo.service.version}")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return args -> {
+ logger.info(demoService.sayHello("mercyblitz"));
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboRegistryZooKeeperConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..88846fb
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,15 @@
+spring:
+ application:
+ name: dubbo-registry-zookeeper-consumer-sample
+
+demo:
+ service:
+ version: 1.0.0
+
+embedded:
+ zookeeper:
+ port: 2181
+
+dubbo:
+ registry:
+ address: zookeeper://127.0.0.1:${embedded.zookeeper.port}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml
similarity index 65%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml
index bac2c4c..f27101a 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml
@@ -14,18 +14,25 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Zookeeper</name>
+ <description>Dubbo Spring Boot Registry Zookeeper Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/pom.xml
similarity index 73%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/pom.xml
index 1dc600b..fb46909 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/pom.xml
@@ -14,19 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Zookeeper :: Provider Sample</name>
<dependencies>
@@ -37,20 +37,15 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
+ <!-- Dubbo -->
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
@@ -59,6 +54,17 @@
<version>${project.version}</version>
</dependency>
+ <!-- Zookeeper -->
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ </dependency>
+
</dependencies>
<build>
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryZooKeeperProviderBootstrap.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryZooKeeperProviderBootstrap.java
new file mode 100644
index 0000000..bcc9407
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryZooKeeperProviderBootstrap.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.provider.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
+
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.core.env.Environment;
+
+/**
+ * Dubbo Registry ZooKeeper Provider Bootstrap
+ *
+ * @see DefaultDemoService
+ * @since 1.0.0
+ */
+@EnableAutoConfiguration
+public class DubboRegistryZooKeeperProviderBootstrap {
+
+ public static void main(String[] args) {
+ new SpringApplicationBuilder(DubboRegistryZooKeeperProviderBootstrap.class)
+ .web(WebApplicationType.NONE)
+ .listeners((ApplicationListener<ApplicationEnvironmentPreparedEvent>) event -> {
+ Environment environment = event.getEnvironment();
+ int port = environment.getProperty("embedded.zookeeper.port", int.class);
+ new EmbeddedZooKeeper(port, false).start();
+ })
+ .run(args);
+ }
+}
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/EmbeddedZooKeeper.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/EmbeddedZooKeeper.java
new file mode 100644
index 0000000..ced6344
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/EmbeddedZooKeeper.java
@@ -0,0 +1,252 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.provider.bootstrap;
+
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.SmartLifecycle;
+import org.springframework.util.ErrorHandler;
+import org.springframework.util.SocketUtils;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
+ * <p>
+ * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
+ * <p>
+ * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
+ * org.springframework.xd.dirt.server.singlenode.SingleNodeApplication
+ *
+ * @author Patrick Peralta
+ * @author Mark Fisher
+ * @author David Turanski
+ */
+public class EmbeddedZooKeeper implements SmartLifecycle {
+
+ /**
+ * Logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class);
+
+ /**
+ * ZooKeeper client port. This will be determined dynamically upon startup.
+ */
+ private final int clientPort;
+
+ /**
+ * Whether to auto-start. Default is true.
+ */
+ private boolean autoStartup = true;
+
+ /**
+ * Lifecycle phase. Default is 0.
+ */
+ private int phase = 0;
+
+ /**
+ * Thread for running the ZooKeeper server.
+ */
+ private volatile Thread zkServerThread;
+
+ /**
+ * ZooKeeper server.
+ */
+ private volatile ZooKeeperServerMain zkServer;
+
+ /**
+ * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread.
+ */
+ private ErrorHandler errorHandler;
+
+ private boolean daemon = true;
+
+ /**
+ * Construct an EmbeddedZooKeeper with a random port.
+ */
+ public EmbeddedZooKeeper() {
+ clientPort = SocketUtils.findAvailableTcpPort();
+ }
+
+ /**
+ * Construct an EmbeddedZooKeeper with the provided port.
+ *
+ * @param clientPort port for ZooKeeper server to bind to
+ */
+ public EmbeddedZooKeeper(int clientPort, boolean daemon) {
+ this.clientPort = clientPort;
+ this.daemon = daemon;
+ }
+
+ /**
+ * Returns the port that clients should use to connect to this embedded server.
+ *
+ * @return dynamically determined client port
+ */
+ public int getClientPort() {
+ return this.clientPort;
+ }
+
+ /**
+ * Specify whether to start automatically. Default is true.
+ *
+ * @param autoStartup whether to start automatically
+ */
+ public void setAutoStartup(boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAutoStartup() {
+ return this.autoStartup;
+ }
+
+ /**
+ * Specify the lifecycle phase for the embedded server.
+ *
+ * @param phase the lifecycle phase
+ */
+ public void setPhase(int phase) {
+ this.phase = phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPhase() {
+ return this.phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRunning() {
+ return (zkServerThread != null);
+ }
+
+ /**
+ * Start the ZooKeeper server in a background thread.
+ * <p>
+ * Register an error handler via {@link #setErrorHandler} in order to handle
+ * any exceptions thrown during startup or execution.
+ */
+ @Override
+ public synchronized void start() {
+ if (zkServerThread == null) {
+ zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter");
+ zkServerThread.setDaemon(daemon);
+ zkServerThread.start();
+ }
+ }
+
+ /**
+ * Shutdown the ZooKeeper server.
+ */
+ @Override
+ public synchronized void stop() {
+ if (zkServerThread != null) {
+ // The shutdown method is protected...thus this hack to invoke it.
+ // This will log an exception on shutdown; see
+ // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details.
+ try {
+ Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
+ shutdown.setAccessible(true);
+ shutdown.invoke(zkServer);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ // It is expected that the thread will exit after
+ // the server is shutdown; this will block until
+ // the shutdown is complete.
+ try {
+ zkServerThread.join(5000);
+ zkServerThread = null;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
+ // abandoning zk thread
+ zkServerThread = null;
+ }
+ }
+ }
+
+ /**
+ * Stop the server if running and invoke the callback when complete.
+ */
+ @Override
+ public void stop(Runnable callback) {
+ stop();
+ callback.run();
+ }
+
+ /**
+ * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
+ * is provided, only error-level logging will occur.
+ *
+ * @param errorHandler the {@link ErrorHandler} to be invoked
+ */
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * Runnable implementation that starts the ZooKeeper server.
+ */
+ private class ServerRunnable implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ Properties properties = new Properties();
+ File file = new File(System.getProperty("java.io.tmpdir")
+ + File.separator + UUID.randomUUID());
+ file.deleteOnExit();
+ properties.setProperty("dataDir", file.getAbsolutePath());
+ properties.setProperty("clientPort", String.valueOf(clientPort));
+
+ QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
+ quorumPeerConfig.parseProperties(properties);
+
+ zkServer = new ZooKeeperServerMain();
+ ServerConfig configuration = new ServerConfig();
+ configuration.readFrom(quorumPeerConfig);
+
+ zkServer.runFromConfig(configuration);
+ } catch (Exception e) {
+ if (errorHandler != null) {
+ errorHandler.handleError(e);
+ } else {
+ logger.error("Exception running embedded ZooKeeper", e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 76%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
copy to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index 48bfc22..f1d9ae1 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -19,23 +19,24 @@
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Default {@link DemoService}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see DemoService
* @since 1.0.0
*/
-@Service(
- version = "${demo.service.version}",
- application = "${dubbo.application.id}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
+@Service(version = "${demo.service.version}")
public class DefaultDemoService implements DemoService {
- public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
- }
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+ public String sayHello(String name) {
+ return String.format("[%s] : Hello, %s", serviceName, name);
+ }
}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..30aa324
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,22 @@
+# Spring boot application
+spring.application.name=dubbo-registry-zookeeper-provider-sample
+
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+
+embedded.zookeeper.port = 2181
+
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+## Random port
+dubbo.protocol.port=-1
+
+## Dubbo Registry
+dubbo.registry.address=zookeeper://127.0.0.1:${embedded.zookeeper.port}
+
+## DemoService version
+demo.service.version=1.0.0
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java
deleted file mode 100644
index 705101a..0000000
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 com.alibaba.boot.dubbo.demo.consumer.bootstrap;
-
-import com.alibaba.boot.dubbo.demo.consumer.controller.DemoConsumerController;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-/**
- * Dubbo Consumer Demo
- *
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
- * @see DemoConsumerController
- * @since 1.0.0
- */
-@SpringBootApplication(scanBasePackages = "com.alibaba.boot.dubbo.demo.consumer.controller")
-public class DubboConsumerDemo {
-
- public static void main(String[] args) {
-
- SpringApplication.run(DubboConsumerDemo.class,args);
-
- }
-
-}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java
deleted file mode 100644
index 1897979..0000000
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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 com.alibaba.boot.dubbo.demo.consumer.controller;
-import com.alibaba.boot.dubbo.demo.consumer.DemoService;
-import com.alibaba.dubbo.config.annotation.Reference;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Demo Consumer Controller (REST)
- *
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
- * @see RestController
- * @since 1.0.0
- */
-@RestController
-public class DemoConsumerController {
-
- @Reference(version = "${demo.service.version}",
- application = "${dubbo.application.id}",
- url = "dubbo://localhost:12345")
- private DemoService demoService;
-
- @RequestMapping("/sayHello")
- public String sayHello(@RequestParam String name) {
- return demoService.sayHello(name);
- }
-
-}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.properties
deleted file mode 100644
index df91988..0000000
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-# Spring boot application
-spring.application.name = dubbo-consumer-demo
-server.port = 8080
-management.server.port = 8081
-
-# DemoService service version
-demo.service.version = 1.0.0
-
-# Dubbo Config properties
-## ApplicationConfig Bean
-dubbo.application.id = dubbo-consumer-demo
-dubbo.application.name = dubbo-consumer-demo
-
-## Legacy QOS Config
-dubbo.qos.port = 22223
-
-## ProtocolConfig Bean
-dubbo.protocol.id = dubbo
-dubbo.protocol.name = dubbo
-dubbo.protocol.port = 12345
-
-# Dubbo Endpoint (default status is disable)
-endpoints.dubbo.enabled = true
-
-# Dubbo Health
-## StatusChecker Name defaults (default : "memory", "load" )
-management.health.dubbo.status.defaults = memory
-
-# Enables Dubbo All Endpoints
-management.endpoint.dubbo.enabled = true
-management.endpoint.dubbo-shutdown.enabled = true
-management.endpoint.dubbo-configs.enabled = true
-management.endpoint.dubbo-services.enabled = true
-management.endpoint.dubbo-references.enabled = true
-management.endpoint.dubbo-properties.enabled = true
-
-# Exposes all web endpoints
-management.endpoints.web.exposure.include = *
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application.properties
deleted file mode 100644
index 323f72e..0000000
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application.properties
+++ /dev/null
@@ -1,42 +0,0 @@
-# Spring boot application
-spring.application.name = dubbo-provider-demo
-server.port = 9090
-
-
-# DemoService service version
-demo.service.version = 1.0.0
-
-# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
-dubbo.scan.basePackages = com.alibaba.boot.dubbo.demo.provider.service
-
-
-# Dubbo Config properties
-## ApplicationConfig Bean
-dubbo.application.id = dubbo-provider-demo
-dubbo.application.name = dubbo-provider-demo
-dubbo.application.qos.port=22222
-dubbo.application.qos.enable=true
-
-## ProtocolConfig Bean
-dubbo.protocol.id = dubbo
-dubbo.protocol.name = dubbo
-dubbo.protocol.port = 12345
-dubbo.protocol.status = server
-
-## RegistryConfig Bean
-dubbo.registry.id = my-registry
-dubbo.registry.address = N/A
-
-# Enables Dubbo All Endpoints
-management.endpoint.dubbo.enabled = true
-management.endpoint.dubbo-shutdown.enabled = true
-management.endpoint.dubbo-configs.enabled = true
-management.endpoint.dubbo-services.enabled = true
-management.endpoint.dubbo-references.enabled = true
-management.endpoint.dubbo-properties.enabled = true
-
-# Dubbo Health
-## StatusChecker Name defaults (default : "memory", "load" )
-management.health.dubbo.status.defaults = memory
-## StatusChecker Name extras (default : empty )
-management.health.dubbo.status.extras = load,threadpool
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/pom.xml
similarity index 75%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/pom.xml
index 1dc600b..413eb9b 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/pom.xml
@@ -14,20 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-externalized-configuration-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
-
+ <artifactId>dubbo-spring-boot-externalized-configuration-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Externalized Configuration :: Consumer Sample</name>
<dependencies>
<!-- Spring Boot dependencies -->
@@ -37,20 +36,14 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
@@ -78,5 +71,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java
new file mode 100644
index 0000000..2eb78b4
--- /dev/null
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java
@@ -0,0 +1,50 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Externalized Configuration Consumer Bootstrap
+ */
+@EnableAutoConfiguration
+public class DubboExternalizedConfigurationConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "${demo.service.version}", url = "${demo.service.url}")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return args -> {
+ logger.info(demoService.sayHello("mercyblitz"));
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboExternalizedConfigurationConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..e3aef42
--- /dev/null
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,8 @@
+spring:
+ application:
+ name: dubbo-externalized-configuration-consumer-sample
+
+demo:
+ service:
+ version: 1.0.0
+ url: dubbo://localhost:12345
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml
similarity index 71%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml
index bac2c4c..9bf23e9 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml
@@ -18,14 +18,22 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-externalized-configuration-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Externalized Configuration</name>
+ <description>Dubbo Spring Boot Externalized Configuration Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
+
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/pom.xml
similarity index 75%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/pom.xml
index 1dc600b..4f90d8c 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/pom.xml
@@ -14,19 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-externalized-configuration-samples</artifactId>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
+ <artifactId>dubbo-spring-boot-externalized-configuration-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Externalized Configuration :: Provider Sample</name>
<dependencies>
@@ -37,20 +37,14 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-actuator</artifactId>
- <version>${project.version}</version>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
</dependency>
<dependency>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboExternalizedConfigurationProviderBootstrap.java
similarity index 79%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
copy to dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboExternalizedConfigurationProviderBootstrap.java
index a252032..6264c17 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboExternalizedConfigurationProviderBootstrap.java
@@ -17,26 +17,23 @@
package com.alibaba.boot.dubbo.demo.provider.bootstrap;
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
+
import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
/**
- * Dubbo Provider Demo
+ * Dubbo Externalized Configuration Provider Bootstrap
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see DefaultDemoService
* @since 1.0.0
*/
-@SpringBootApplication
-public class DubboProviderDemo {
+@EnableAutoConfiguration
+public class DubboExternalizedConfigurationProviderBootstrap {
public static void main(String[] args) {
-
- new SpringApplicationBuilder(DubboProviderDemo.class)
+ new SpringApplicationBuilder(DubboExternalizedConfigurationProviderBootstrap.class)
.web(WebApplicationType.NONE)
.run(args);
-
}
-
}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 76%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
copy to dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index 48bfc22..f1d9ae1 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -19,23 +19,24 @@
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Default {@link DemoService}
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see DemoService
* @since 1.0.0
*/
-@Service(
- version = "${demo.service.version}",
- application = "${dubbo.application.id}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
+@Service(version = "${demo.service.version}")
public class DefaultDemoService implements DemoService {
- public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
- }
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+ public String sayHello(String name) {
+ return String.format("[%s] : Hello, %s", serviceName, name);
+ }
}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..398e996
--- /dev/null
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,19 @@
+# Spring boot application
+spring.application.name=dubbo-externalized-configuration-provider-sample
+
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=12345
+
+## Dubbo Registry
+dubbo.registry.address=N/A
+
+## DemoService version
+demo.service.version=1.0.0
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/pom.xml b/dubbo-spring-boot-samples/pom.xml
index a1917a0..991c839 100644
--- a/dubbo-spring-boot-samples/pom.xml
+++ b/dubbo-spring-boot-samples/pom.xml
@@ -20,32 +20,25 @@
<parent>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-parent</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../dubbo-spring-boot-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
<packaging>pom</packaging>
<name>Dubbo Spring Boot Samples</name>
<description>Dubbo Spring Boot Samples</description>
+
<modules>
- <module>dubbo-spring-boot-sample-provider</module>
- <module>dubbo-spring-boot-sample-consumer</module>
- <module>dubbo-spring-boot-sample-api</module>
+ <module>sample-api</module>
+ <module>auto-configure-samples</module>
+ <module>externalized-configuration-samples</module>
+ <module>dubbo-registry-nacos-samples</module>
+ <module>dubbo-registry-zookeeper-samples</module>
</modules>
- <dependencies>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
<build>
<plugins>
<plugin>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/sample-api/pom.xml
similarity index 89%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
rename to dubbo-spring-boot-samples/sample-api/pom.xml
index bac2c4c..e6a6746 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/sample-api/pom.xml
@@ -18,14 +18,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <name>Dubbo Spring Boot Samples : API</name>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java b/dubbo-spring-boot-samples/sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java
similarity index 89%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java
rename to dubbo-spring-boot-samples/sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java
index f57c8e4..bff1309 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java
+++ b/dubbo-spring-boot-samples/sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java
@@ -1,4 +1,4 @@
-package com.alibaba.boot.dubbo.demo.consumer;/*
+/*
* 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.
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package com.alibaba.boot.dubbo.demo.consumer;
/**
* Demo Service interface
*
- * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 1.0.0
*/
public interface DemoService {
diff --git a/dubbo-spring-boot-starter/pom.xml b/dubbo-spring-boot-starter/pom.xml
index 9933660..2bd319a 100644
--- a/dubbo-spring-boot-starter/pom.xml
+++ b/dubbo-spring-boot-starter/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-parent</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<relativePath>../dubbo-spring-boot-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -36,24 +36,20 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!-- Dubbo -->
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
+ <optional>true</optional>
</dependency>
<!-- ZK -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
diff --git a/pom.xml b/pom.xml
index a590d80..0f1dd4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,13 +23,10 @@
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
- <properties>
- <maven_javadoc_version>3.0.1</maven_javadoc_version>
- <maven_surefire_version>2.19.1</maven_surefire_version>
- </properties>
+
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-project</artifactId>
- <version>0.2.1-SNAPSHOT</version>
+ <version>${revision}</version>
<packaging>pom</packaging>
@@ -37,8 +34,15 @@
<description>Dubbo Spring Boot Project</description>
<url>https://github.com/apache/incubator-dubbo-spring-boot-project</url>
+ <properties>
+ <maven_javadoc_version>3.0.1</maven_javadoc_version>
+ <maven_surefire_version>2.19.1</maven_surefire_version>
+ <revision>0.2.1</revision>
+ </properties>
+
<modules>
<module>dubbo-spring-boot-parent</module>
+ <module>dubbo-spring-boot-distribution</module>
<module>dubbo-spring-boot-autoconfigure</module>
<module>dubbo-spring-boot-starter</module>
<module>dubbo-spring-boot-samples</module>