Skip to content

Commit

Permalink
0.1.x (#333)
Browse files Browse the repository at this point in the history
* Bug fix on test case

* Polish #327 & #325

* Polish #321

* Polish #220 no program

* Switch Yaml file

* Update version to be 0.2.0

* Polish #218

* Update Documents

* Fix the test case's bugs

* Fix plugins' issues

* Fix test-cases

* Fix test cases

* Fixes an issue on DubboMvcEndpoint

* Polish: Fix a relaxed property name issue
  • Loading branch information
mercyblitz authored Dec 18, 2018
1 parent fa7405a commit c58053d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
import java.util.Set;

import static com.alibaba.boot.dubbo.util.DubboUtils.BASE_PACKAGES_PROPERTY_NAME;
import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_CONFIG_PREFIX;
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.MULTIPLE_CONFIG_PROPERTY_NAME;
import static java.util.Collections.emptySet;
import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE;
Expand Down Expand Up @@ -78,7 +80,7 @@ protected static class SingleDubboConfigConfiguration {
* @see EnableDubboConfig
* @see DubboConfigConfiguration.Multiple
*/
@ConditionalOnProperty(name = MULTIPLE_CONFIG_PROPERTY_NAME, havingValue = "true")
@ConditionalOnProperty(prefix = DUBBO_CONFIG_PREFIX, name = MULTIPLE_CONFIG_PROPERTY_NAME, havingValue = "true")
@EnableDubboConfig(multiple = true)
protected static class MultipleDubboConfigConfiguration {
}
Expand All @@ -89,11 +91,11 @@ protected static class MultipleDubboConfigConfiguration {
* @param environment {@link Environment} Bean
* @return {@link ServiceAnnotationBeanPostProcessor}
*/
@ConditionalOnProperty(name = BASE_PACKAGES_PROPERTY_NAME)
@ConditionalOnProperty(prefix = DUBBO_SCAN_PREFIX, name = BASE_PACKAGES_PROPERTY_NAME)
@ConditionalOnClass(RelaxedPropertyResolver.class)
@Bean
public ServiceAnnotationBeanPostProcessor serviceAnnotationBeanPostProcessor(Environment environment) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment);
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, DUBBO_SCAN_PREFIX);
Set<String> packagesToScan = resolver.getProperty(BASE_PACKAGES_PROPERTY_NAME, Set.class, emptySet());
return new ServiceAnnotationBeanPostProcessor(packagesToScan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.alibaba.boot.dubbo.context.event;

import com.alibaba.dubbo.common.utils.ConfigUtils;

import com.alibaba.dubbo.config.AbstractConfig;

import org.slf4j.Logger;
Expand All @@ -31,6 +30,7 @@
import java.util.SortedMap;

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.OVERRIDE_CONFIG_PROPERTY_NAME;
import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties;

Expand All @@ -57,8 +57,8 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {

ConfigurableEnvironment environment = event.getEnvironment();

boolean override = environment.getProperty(OVERRIDE_CONFIG_PROPERTY_NAME, boolean.class,
DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE);
boolean override = environment.getProperty(DUBBO_CONFIG_PREFIX + OVERRIDE_CONFIG_PROPERTY_NAME,
boolean.class, DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE);

if (override) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,31 @@ public abstract class DubboUtils {
/**
* The prefix of property name of Dubbo
*/
public static final String DUBBO_PREFIX = "dubbo";
public static final String DUBBO_PREFIX = "dubbo" + PROPERTY_NAME_SEPARATOR;

/**
* The prefix of property name for Dubbo scan
*/
public static final String DUBBO_SCAN_PREFIX = DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR + "scan";
public static final String DUBBO_SCAN_PREFIX = DUBBO_PREFIX + "scan" + PROPERTY_NAME_SEPARATOR;

/**
* The prefix of property name for Dubbo Config.ØØ
*/
public static final String DUBBO_CONFIG_PREFIX = DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR + "config";
public static final String DUBBO_CONFIG_PREFIX = DUBBO_PREFIX + "config" + PROPERTY_NAME_SEPARATOR;

/**
* The property name of base packages to scan
* <p>
* The default value is empty set.
*/
public static final String BASE_PACKAGES_PROPERTY_NAME = DUBBO_SCAN_PREFIX + PROPERTY_NAME_SEPARATOR + "base-packages";
public static final String BASE_PACKAGES_PROPERTY_NAME = "base-packages";

/**
* The property name of multiple properties binding from externalized configuration
* <p>
* The default value is {@link #DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE}
*/
public static final String MULTIPLE_CONFIG_PROPERTY_NAME = DUBBO_CONFIG_PREFIX + PROPERTY_NAME_SEPARATOR + "multiple";
public static final String MULTIPLE_CONFIG_PROPERTY_NAME = "multiple";

/**
* The default value of multiple properties binding from externalized configuration
Expand All @@ -81,7 +81,7 @@ public abstract class DubboUtils {
* <p>
* The default value is {@link #DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE}
*/
public static final String OVERRIDE_CONFIG_PROPERTY_NAME = DUBBO_CONFIG_PREFIX + PROPERTY_NAME_SEPARATOR + "override";
public static final String OVERRIDE_CONFIG_PROPERTY_NAME = "override";

/**
* The default property value of override Dubbo config
Expand Down Expand Up @@ -129,7 +129,7 @@ public static SortedMap<String, Object> filterDubboProperties(ConfigurableEnviro
for (Map.Entry<String, Object> entry : properties.entrySet()) {
String propertyName = entry.getKey();

if (propertyName.startsWith(DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR)) {
if (propertyName.startsWith(DUBBO_PREFIX)) {
dubboProperties.put(propertyName, entry.getValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

/**
* {@link DubboUtils} Test
* @author <a href="mailto:[email protected]">Mercy</a>
* @see DubboUtils
* @since 1.0.0
Expand All @@ -49,17 +48,17 @@ public class DubboUtilsTest {
@Test
public void testConstants() {

Assert.assertEquals("dubbo", DUBBO_PREFIX);
Assert.assertEquals("dubbo.", DUBBO_PREFIX);

Assert.assertEquals("dubbo.scan", DUBBO_SCAN_PREFIX);
Assert.assertEquals("dubbo.scan.", DUBBO_SCAN_PREFIX);

Assert.assertEquals("dubbo.scan.base-packages", BASE_PACKAGES_PROPERTY_NAME);
Assert.assertEquals("dubbo.scan.base-packages", DUBBO_SCAN_PREFIX + BASE_PACKAGES_PROPERTY_NAME);

Assert.assertEquals("dubbo.config", DUBBO_CONFIG_PREFIX);
Assert.assertEquals("dubbo.config.", DUBBO_CONFIG_PREFIX);

Assert.assertEquals("dubbo.config.multiple", MULTIPLE_CONFIG_PROPERTY_NAME);
Assert.assertEquals("dubbo.config.multiple", DUBBO_CONFIG_PREFIX + MULTIPLE_CONFIG_PROPERTY_NAME);

Assert.assertEquals("dubbo.config.override", OVERRIDE_CONFIG_PROPERTY_NAME);
Assert.assertEquals("dubbo.config.override", DUBBO_CONFIG_PREFIX + OVERRIDE_CONFIG_PROPERTY_NAME);

Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project", DUBBO_SPRING_BOOT_GITHUB_URL);
Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project.git", DUBBO_SPRING_BOOT_GIT_URL);
Expand All @@ -81,13 +80,13 @@ public void testFilterDubboProperties() {

MockEnvironment environment = new MockEnvironment();
environment.setProperty("message", "Hello,World");
environment.setProperty(MULTIPLE_CONFIG_PROPERTY_NAME, "true");
environment.setProperty(OVERRIDE_CONFIG_PROPERTY_NAME, "true");
environment.setProperty(DUBBO_CONFIG_PREFIX + MULTIPLE_CONFIG_PROPERTY_NAME, "true");
environment.setProperty(DUBBO_CONFIG_PREFIX + OVERRIDE_CONFIG_PROPERTY_NAME, "true");

SortedMap<String, Object> dubboProperties = filterDubboProperties(environment);

Assert.assertEquals("true",dubboProperties.get(MULTIPLE_CONFIG_PROPERTY_NAME));
Assert.assertEquals("true",dubboProperties.get(OVERRIDE_CONFIG_PROPERTY_NAME));
Assert.assertEquals("true", dubboProperties.get(DUBBO_CONFIG_PREFIX + MULTIPLE_CONFIG_PROPERTY_NAME));
Assert.assertEquals("true", dubboProperties.get(DUBBO_CONFIG_PREFIX + OVERRIDE_CONFIG_PROPERTY_NAME));

}

Expand Down

0 comments on commit c58053d

Please sign in to comment.