Skip to content

Commit

Permalink
1.0.0 (#429) (#430)
Browse files Browse the repository at this point in the history
* Polish #395

* Polish #395 fixed issues

* Polish #395 Update documents

* Update the root POM's parent

* Replace ${project.version} to ${revision} in the "pom.xml" files

* Update <projectId>

* Remove Netty Project

* Polish : #427

* Polish : #427

* Polish : #427
  • Loading branch information
mercyblitz authored Feb 1, 2019
1 parent 2e5f935 commit f08d1ec
Show file tree
Hide file tree
Showing 88 changed files with 2,346 additions and 687 deletions.
11 changes: 1 addition & 10 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,4 @@ 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
The Apache Software Foundation (http://www.apache.org/).
10 changes: 9 additions & 1 deletion dubbo-spring-boot-actuator/pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -27,11 +28,18 @@

<artifactId>dubbo-spring-boot-actuator</artifactId>
<packaging>jar</packaging>
<name>Apache Dubbo Spring Boot Actuator</name>
<name>Apache Dubbo Spring Boot :: Actuator</name>
<description>Apache Dubbo Spring Boot Actuator</description>

<dependencies>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-actuator-compatible</artifactId>
<version>${revision}</version>
</dependency>

<!-- Spring Boot -->
<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 @@ -17,12 +17,11 @@
package org.apache.dubbo.spring.boot.actuate.autoconfigure;

import org.apache.dubbo.spring.boot.actuate.endpoint.DubboConfigsMetadataEndpoint;
import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint;
import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesEndpoint;
import org.apache.dubbo.spring.boot.actuate.endpoint.DubboMetadataEndpoint;
import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesMetadataEndpoint;
import org.apache.dubbo.spring.boot.actuate.endpoint.DubboReferencesMetadataEndpoint;
import org.apache.dubbo.spring.boot.actuate.endpoint.DubboServicesMetadataEndpoint;
import org.apache.dubbo.spring.boot.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 @@ -31,23 +30,23 @@
import org.springframework.context.annotation.PropertySource;

/**
* Dubbo {@link Endpoint} Auto-{@link Configuration}
* Dubbo {@link Endpoint @Endpoint} Auto-{@link Configuration} for Spring Boot Actuator 2.0
*
* @see Endpoint
* @see Configuration
* @since 0.2.0
* @since 2.7.0
*/
@Configuration
@PropertySource(
name = "Dubbo Endpoints Default Properties",
value = "classpath:/META-INF/dubbo-endpoins-default.properties")
public class DubboEndpointsAutoConfiguration {
public class DubboEndpointAnnotationAutoConfiguration {

@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint
public DubboEndpoint dubboEndpoint() {
return new DubboEndpoint();
public DubboMetadataEndpoint dubboEndpoint() {
return new DubboMetadataEndpoint();
}

@Bean
Expand All @@ -60,8 +59,8 @@ public DubboConfigsMetadataEndpoint dubboConfigsMetadataEndpoint() {
@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint
public DubboPropertiesEndpoint dubboPropertiesEndpoint() {
return new DubboPropertiesEndpoint();
public DubboPropertiesMetadataEndpoint dubboPropertiesEndpoint() {
return new DubboPropertiesMetadataEndpoint();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,74 +16,27 @@
*/
package org.apache.dubbo.spring.boot.actuate.endpoint;

import org.apache.dubbo.config.AbstractConfig;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ConsumerConfig;
import org.apache.dubbo.config.MethodConfig;
import org.apache.dubbo.config.ModuleConfig;
import org.apache.dubbo.config.MonitorConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;

import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata;
import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboConfigsMetadata;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.TreeMap;

import static org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors;

/**
* Dubbo Configs Metadata {@link Endpoint}
*
* @since 0.2.0
* @since 2.7.0
*/
@Endpoint(id = "dubboconfigs")
public class DubboConfigsMetadataEndpoint extends AbstractDubboEndpoint {
public class DubboConfigsMetadataEndpoint extends AbstractDubboMetadata {

@Autowired
private DubboConfigsMetadata dubboConfigsMetadata;

@ReadOperation
public Map<String, Map<String, Map<String, Object>>> configs() {

Map<String, Map<String, Map<String, Object>>> configsMap = new LinkedHashMap<>();

addDubboConfigBeans(ApplicationConfig.class, configsMap);
addDubboConfigBeans(ConsumerConfig.class, configsMap);
addDubboConfigBeans(MethodConfig.class, configsMap);
addDubboConfigBeans(ModuleConfig.class, configsMap);
addDubboConfigBeans(MonitorConfig.class, configsMap);
addDubboConfigBeans(ProtocolConfig.class, configsMap);
addDubboConfigBeans(ProviderConfig.class, configsMap);
addDubboConfigBeans(ReferenceConfig.class, configsMap);
addDubboConfigBeans(RegistryConfig.class, configsMap);
addDubboConfigBeans(ServiceConfig.class, configsMap);

return configsMap;

}

private void addDubboConfigBeans(Class<? extends AbstractConfig> dubboConfigClass,
Map<String, Map<String, Map<String, Object>>> configsMap) {

Map<String, ? extends AbstractConfig> dubboConfigBeans = beansOfTypeIncludingAncestors(applicationContext, dubboConfigClass);

String name = dubboConfigClass.getSimpleName();

Map<String, Map<String, Object>> beansMetadata = new TreeMap<>();

for (Map.Entry<String, ? extends AbstractConfig> entry : dubboConfigBeans.entrySet()) {

String beanName = entry.getKey();
AbstractConfig configBean = entry.getValue();
Map<String, Object> configBeanMeta = resolveBeanMetadata(configBean);
beansMetadata.put(beanName, configBeanMeta);

}

configsMap.put(name, beansMetadata);

return dubboConfigsMetadata.configs();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.spring.boot.actuate.endpoint;

import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboMetadata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;

import java.util.Map;

/**
* Actuator {@link Endpoint} to expose Dubbo Meta Data
*
* @see Endpoint
* @since 2.7.0
*/
@Endpoint(id = "dubbo")
public class DubboMetadataEndpoint {

@Autowired
private DubboMetadata dubboMetadata;

@ReadOperation
public Map<String, Object> invoke() {
return dubboMetadata.invoke();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.spring.boot.actuate.endpoint;

import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata;
import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboPropertiesMetadata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;

import java.util.SortedMap;

/**
* Dubbo Properties {@link Endpoint}
*
* @since 2.7.0
*/
@Endpoint(id = "dubboproperties")
public class DubboPropertiesMetadataEndpoint extends AbstractDubboMetadata {

@Autowired
private DubboPropertiesMetadata dubboPropertiesMetadata;

@ReadOperation
public SortedMap<String, Object> properties() {
return dubboPropertiesMetadata.properties();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,27 @@
package org.apache.dubbo.spring.boot.actuate.endpoint;

import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor;

import org.springframework.beans.factory.annotation.InjectionMetadata;
import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata;
import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboReferencesMetadata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;

import java.util.LinkedHashMap;
import java.util.Map;

/**
* Dubbo {@link Reference} Metadata {@link Endpoint}
*
* @since 1.0.0
* @since 2.7.0
*/
@Endpoint(id = "dubboreferences")
public class DubboReferencesMetadataEndpoint extends AbstractDubboEndpoint {
public class DubboReferencesMetadataEndpoint extends AbstractDubboMetadata {

@Autowired
private DubboReferencesMetadata dubboReferencesMetadata;

@ReadOperation
public Map<String, Map<String, Object>> references() {

Map<String, Map<String, Object>> referencesMetadata = new LinkedHashMap<>();

ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor();

referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedFieldReferenceBeanMap()));
referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedMethodReferenceBeanMap()));

return referencesMetadata;

return dubboReferencesMetadata.references();
}

private Map<String, Map<String, Object>> buildReferencesMetadata(
Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> injectedElementReferenceBeanMap) {
Map<String, Map<String, Object>> referencesMetadata = new LinkedHashMap<>();

for (Map.Entry<InjectionMetadata.InjectedElement, ReferenceBean<?>> entry :
injectedElementReferenceBeanMap.entrySet()) {

InjectionMetadata.InjectedElement injectedElement = entry.getKey();

ReferenceBean<?> referenceBean = entry.getValue();

Map<String, Object> beanMetadata = resolveBeanMetadata(referenceBean);
beanMetadata.put("invoker", resolveBeanMetadata(referenceBean.get()));

referencesMetadata.put(String.valueOf(injectedElement.getMember()), beanMetadata);

}

return referencesMetadata;
}

}
Loading

0 comments on commit f08d1ec

Please sign in to comment.