Skip to content

Commit

Permalink
0.2.1 (#352)
Browse files Browse the repository at this point in the history
* 0.2.1 (#345)

* Fix #169

* Polish : #324 & #325

* Polish : #315

* Polish : #321

* Polish : #321

* Polish : #321 for test case

* Polish : Update Demos

* Polish : Update version to be 0.2.1

* Polish : #319

* Polish : #226

* Polish : #309

* Fix the test case's bugs

* Fix the test case's bugs

* Fix a JavaDoc issue

* Update SNAPSHOT and add exclude list

* Update SNAPSHOT to be 0.2.1-SNAPSHOT

* Update JDK versions

* Update JDK versions

* Reactor & remove author info

* Refactor : to save a shutdown hook thread

* 0.2.1 (#346)

* Fix #169

* Polish : #324 & #325

* Polish : #315

* Polish : #321

* Polish : #321

* Polish : #321 for test case

* Polish : Update Demos

* Polish : Update version to be 0.2.1

* Polish : #319

* Polish : #226

* Polish : #309

* Fix the test case's bugs

* Fix the test case's bugs

* Fix a JavaDoc issue

* Update SNAPSHOT and add exclude list

* Update SNAPSHOT to be 0.2.1-SNAPSHOT

* Update JDK versions

* Update JDK versions

* Reactor & remove author info

* Refactor : to save a shutdown hook thread

* Remove javax.servlet:javax.servlet-api:3.1.0 that may cause class conflict, and use indirectly dependencies from spring-boot-starter-*

* Polish #341
  • Loading branch information
mercyblitz committed Jan 2, 2019
1 parent f65bec5 commit 9a6d197
Show file tree
Hide file tree
Showing 33 changed files with 303 additions and 144 deletions.
12 changes: 6 additions & 6 deletions dubbo-spring-boot-actuator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For now, `dubbo-spring-boot-actuator` will separate two versions for Spring Boot

* `0.1.x` is a legacy version for maintaining Spring Boot 1.x




## Integrate with Maven
Expand Down Expand Up @@ -503,10 +503,10 @@ Dubbo Spring Boot providers actuator endpoints , however some of them are disabl
```properties
# Enables Dubbo All Endpoints
management.endpoint.dubbo.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.endpoint.dubboshutdown.enabled = true
management.endpoint.dubboconfigs.enabled = true
management.endpoint.dubboservices.enabled = true
management.endpoint.dubboreferences.enabled = true
management.endpoint.dubboproperties.enabled = true
```

9 changes: 0 additions & 9 deletions dubbo-spring-boot-actuator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +33,7 @@
/**
* Dubbo {@link Endpoint} Auto-{@link Configuration}
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @see Endpoint
* @see Configuration
* @since 0.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +34,7 @@
/**
* Dubbo {@link DubboHealthIndicator} Auto Configuration
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @see HealthIndicator
* @since 1.0.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,7 +46,7 @@
/**
* Abstract Dubbo {@link Endpoint @Endpoint}
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @since 0.2.0
*/
public abstract class AbstractDubboEndpoint implements ApplicationContextAware, EnvironmentAware {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
/**
* Dubbo Configs Metadata {@link Endpoint}
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @since 0.2.0
*/
@Endpoint(id = "dubboConfigs")
@Endpoint(id = "dubboconfigs")
public class DubboConfigsMetadataEndpoint extends AbstractDubboEndpoint {

@ReadOperation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* Actuator {@link Endpoint} to expose Dubbo Meta Data
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @see Endpoint
* @since 1.0.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
/**
* Dubbo Properties {@link Endpoint}
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @since 1.0.0
*/
@Endpoint(id = "dubboProperties")
@Endpoint(id = "dubboproperties")
public class DubboPropertiesEndpoint extends AbstractDubboEndpoint {

@ReadOperation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
/**
* Dubbo {@link Reference} Metadata {@link Endpoint}
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @since 1.0.0
*/
@Endpoint(id = "dubboReferences")
@Endpoint(id = "dubboreferences")
public class DubboReferencesMetadataEndpoint extends AbstractDubboEndpoint {

@ReadOperation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
/**
* Dubbo {@link Service} Metadata {@link Endpoint}
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @since 0.2.0
*/
@Endpoint(id = "dubboServices")
@Endpoint(id = "dubboservices")
public class DubboServicesMetadataEndpoint extends AbstractDubboEndpoint {

@ReadOperation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
/**
* Dubbo Shutdown
*
* @author <a href="mailto:[email protected]">Mercy</a>
* @since 0.2.0
*/
@Endpoint(id = "dubboShutdown")
@Endpoint(id = "dubboshutdown")
public class DubboShutdownEndpoint extends AbstractDubboEndpoint {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,7 +38,7 @@
/**
* Dubbo {@link HealthIndicator}
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @see HealthIndicator
* @since 1.0.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Dubbo {@link HealthIndicator} Properties
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @see HealthIndicator
* @since 1.0.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

# Set enabled for Dubbo Endpoints
management.endpoint.dubbo.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.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.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


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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* {@link DubboEndpoint} Test
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @see DubboEndpoint
* @since 1.0.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@
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:[email protected]">Mercy</a>
* @since 0.2.0
*/
@RunWith(SpringRunner.class)
Expand All @@ -58,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.dubboShutdown.enabled = true",
"management.endpoint.dubboConfigs.enabled = true",
"management.endpoint.dubboServices.enabled = true",
"management.endpoint.dubboReferences.enabled = true",
"management.endpoint.dubboProperties.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 {
Expand All @@ -85,6 +90,13 @@ public class DubboEndpointsAutoConfigurationTest {
@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 {
Expand Down Expand Up @@ -178,20 +190,35 @@ public void testProperties() {
Assert.assertEquals("com.alibaba.boot.dubbo.actuate.endpoint", properties.get("dubbo.scan.basePackages"));
}

@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);
}

@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)";
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +34,7 @@
/**
* {@link DubboHealthIndicator} Test
*
* @author <a href="mailto:[email protected]">Mercy</a>
*
* @see DubboHealthIndicator
* @since 1.0.0
*/
Expand Down
Loading

0 comments on commit 9a6d197

Please sign in to comment.