Fix the code style issues

pull/1684/head
mercyblitz 4 years ago
parent a61f523d78
commit 5cd6c0f1e7

@ -17,7 +17,6 @@
package com.alibaba.cloud.dubbo.bootstrap;
import com.alibaba.cloud.dubbo.service.EchoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.boot.SpringApplication;
@ -28,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController;
/**
* Dubbo Spring Cloud Client Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

@ -23,7 +23,6 @@ import com.alibaba.cloud.dubbo.annotation.DubboTransported;
import com.alibaba.cloud.dubbo.service.RestService;
import com.alibaba.cloud.dubbo.service.User;
import com.alibaba.cloud.dubbo.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
@ -53,6 +52,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/**
* Dubbo Spring Cloud Consumer Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

@ -23,6 +23,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* Dubbo Spring Cloud Provider Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

@ -31,7 +31,6 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -22,6 +22,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* Dubbo Spring Cloud Provider Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

@ -20,7 +20,6 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -17,7 +17,6 @@
package com.alibaba.cloud.dubbo.bootstrap;
import com.alibaba.cloud.dubbo.service.EchoService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.boot.SpringApplication;
@ -26,6 +25,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* Dubbo Spring Cloud Server Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

@ -24,6 +24,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Dubbo Spring Cloud Servlet Gateway Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

@ -28,71 +28,71 @@ import org.springframework.util.StringUtils;
*/
public class ConsulDataSourceProperties extends AbstractDataSourceProperties {
public ConsulDataSourceProperties(){
super(ConsulDataSourceFactoryBean.class.getName());
}
/**
* consul server host.
*/
private String host;
/**
* consul server port.
*/
private int port=8500;
/**
* data key in Redis.
*/
private String ruleKey;
/**
* Request of query will hang until timeout (in second) or get updated value.
*/
private int waitTimeoutInSecond = 1;
@Override
public void preCheck(String dataSourceName) {
if(StringUtils.isEmpty(host)){
throw new IllegalArgumentException(
"ConsulDataSource server-host is empty");
}
if(StringUtils.isEmpty(ruleKey)){
throw new IllegalArgumentException(
"ConsulDataSource ruleKey can not be empty");
}
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getRuleKey() {
return ruleKey;
}
public void setRuleKey(String ruleKey) {
this.ruleKey = ruleKey;
}
public int getWaitTimeoutInSecond() {
return waitTimeoutInSecond;
}
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
this.waitTimeoutInSecond = waitTimeoutInSecond;
}
public ConsulDataSourceProperties() {
super(ConsulDataSourceFactoryBean.class.getName());
}
/**
* consul server host.
*/
private String host;
/**
* consul server port.
*/
private int port = 8500;
/**
* data key in Redis.
*/
private String ruleKey;
/**
* Request of query will hang until timeout (in second) or get updated value.
*/
private int waitTimeoutInSecond = 1;
@Override
public void preCheck(String dataSourceName) {
if (StringUtils.isEmpty(host)) {
throw new IllegalArgumentException("ConsulDataSource server-host is empty");
}
if (StringUtils.isEmpty(ruleKey)) {
throw new IllegalArgumentException(
"ConsulDataSource ruleKey can not be empty");
}
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getRuleKey() {
return ruleKey;
}
public void setRuleKey(String ruleKey) {
this.ruleKey = ruleKey;
}
public int getWaitTimeoutInSecond() {
return waitTimeoutInSecond;
}
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
this.waitTimeoutInSecond = waitTimeoutInSecond;
}
}

@ -29,68 +29,64 @@ import org.springframework.beans.factory.FactoryBean;
*/
public class ConsulDataSourceFactoryBean implements FactoryBean<ConsulDataSource> {
private String host;
private String host;
private int port;
private int port;
private String ruleKey;
private String ruleKey;
private int waitTimeoutInSecond;
private int waitTimeoutInSecond;
private Converter converter;
private Converter converter;
@Override
public ConsulDataSource getObject() throws Exception {
return new ConsulDataSource(
host,
port,
ruleKey,
waitTimeoutInSecond,
converter);
}
@Override
public ConsulDataSource getObject() throws Exception {
return new ConsulDataSource(host, port, ruleKey, waitTimeoutInSecond, converter);
}
@Override
public Class<?> getObjectType() {
return ConsulDataSource.class;
}
@Override
public Class<?> getObjectType() {
return ConsulDataSource.class;
}
public String getHost() {
return host;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public void setPort(int port) {
this.port = port;
}
public String getRuleKey() {
return ruleKey;
}
public String getRuleKey() {
return ruleKey;
}
public void setRuleKey(String ruleKey) {
this.ruleKey = ruleKey;
}
public void setRuleKey(String ruleKey) {
this.ruleKey = ruleKey;
}
public int getWaitTimeoutInSecond() {
return waitTimeoutInSecond;
}
public int getWaitTimeoutInSecond() {
return waitTimeoutInSecond;
}
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
this.waitTimeoutInSecond = waitTimeoutInSecond;
}
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
this.waitTimeoutInSecond = waitTimeoutInSecond;
}
public Converter getConverter() {
return converter;
}
public Converter getConverter() {
return converter;
}
public void setConverter(Converter converter) {
this.converter = converter;
}
public void setConverter(Converter converter) {
this.converter = converter;
}
}

@ -91,7 +91,8 @@ public class SentinelSCGAutoConfiguration {
}
private void initAppType() {
System.setProperty(SentinelConfig.APP_TYPE_PROP_KEY, ConfigConstants.APP_TYPE_SCG_GATEWAY);
System.setProperty(SentinelConfig.APP_TYPE_PROP_KEY,
ConfigConstants.APP_TYPE_SCG_GATEWAY);
}
private void initFallback() {

@ -131,15 +131,17 @@ public class ReactiveSentinelCircuitBreakerIntegrationTest {
@Bean
public Customizer<ReactiveSentinelCircuitBreakerFactory> slowCustomizer() {
return factory -> {
factory.configure(builder -> builder
.rules(Collections.singletonList(new DegradeRule("slow_mono")
.setCount(50).setSlowRatioThreshold(0.7).setMinRequestAmount(5)
.setStatIntervalMs(30000).setTimeWindow(5))),
factory.configure(
builder -> builder.rules(Collections
.singletonList(new DegradeRule("slow_mono").setCount(50)
.setSlowRatioThreshold(0.7).setMinRequestAmount(5)
.setStatIntervalMs(30000).setTimeWindow(5))),
"slow_mono");
factory.configure(builder -> builder
.rules(Collections.singletonList(new DegradeRule("slow_mono")
.setCount(50).setSlowRatioThreshold(0.7).setMinRequestAmount(5)
.setStatIntervalMs(30000).setTimeWindow(5))),
factory.configure(
builder -> builder.rules(Collections
.singletonList(new DegradeRule("slow_mono").setCount(50)
.setSlowRatioThreshold(0.7).setMinRequestAmount(5)
.setStatIntervalMs(30000).setTimeWindow(5))),
"slow_flux");
factory.configureDefault(id -> new SentinelConfigBuilder()
.resourceName(id)

@ -101,7 +101,8 @@ public class SentinelCircuitBreakerIntegrationTest {
protected static class Application {
@GetMapping("/slow")
public String slow(@RequestParam(required = false) Boolean slow) throws InterruptedException {
public String slow(@RequestParam(required = false) Boolean slow)
throws InterruptedException {
if (slow == null || slow) {
Thread.sleep(80);
}
@ -116,10 +117,10 @@ public class SentinelCircuitBreakerIntegrationTest {
@Bean
public Customizer<SentinelCircuitBreakerFactory> slowCustomizer() {
String slowId = "slow";
List<DegradeRule> rules = Collections.singletonList(
new DegradeRule(slowId).setGrade(RuleConstant.DEGRADE_GRADE_RT)
.setCount(50).setSlowRatioThreshold(0.7).setMinRequestAmount(5)
.setStatIntervalMs(30000).setTimeWindow(5));
List<DegradeRule> rules = Collections.singletonList(new DegradeRule(slowId)
.setGrade(RuleConstant.DEGRADE_GRADE_RT).setCount(50)
.setSlowRatioThreshold(0.7).setMinRequestAmount(5)
.setStatIntervalMs(30000).setTimeWindow(5));
return factory -> {
factory.configure(builder -> builder.rules(rules), slowId);
factory.configureDefault(id -> new SentinelConfigBuilder()
@ -146,7 +147,8 @@ public class SentinelCircuitBreakerIntegrationTest {
public String slow(boolean slow) {
return cbFactory.create("slow").run(
() -> rest.getForObject("/slow?slow=" + slow, String.class), t -> "fallback");
() -> rest.getForObject("/slow?slow=" + slow, String.class),
t -> "fallback");
}
public String normal() {

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,21 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.gateway;
import com.alibaba.cloud.dubbo.util.DubboCloudConstants;
/**
* The constants of Dubbo Cloud Gateway
* The constants of Dubbo Cloud Gateway.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
public interface DubboCloudGatewayConstants {
public abstract class DubboCloudGatewayConstants {
/**
* The property prefix of Configuration
* The property prefix of Configuration.
*/
String CONFIG_PROPERTY_PREFIX = DubboCloudConstants.CONFIG_PROPERTY_PREFIX
public static final String CONFIG_PROPERTY_PREFIX = DubboCloudConstants.CONFIG_PROPERTY_PREFIX
+ ".gateway";
}

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.gateway;
import java.net.URI;
@ -30,7 +30,6 @@ import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactor
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.dubbo.rpc.service.GenericException;
import org.apache.dubbo.rpc.service.GenericService;
@ -46,10 +45,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
/**
* The executor of Dubbo Cloud Gateway that handles the HTTP request and responses the
* result of execution of the generic invocation to the Dubbo service providers
* result of execution of the generic invocation to the Dubbo service providers.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*
*
*/
public class DubboCloudGatewayExecutor {
@ -145,8 +144,7 @@ public class DubboCloudGatewayExecutor {
}
/**
* TODO : Get the Request Body from HttpRequest
*
* TODO : Get the Request Body from HttpRequest.
* @param request {@link HttpRequest}
* @return
*/

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.gateway;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -21,7 +21,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import static com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayConstants.CONFIG_PROPERTY_PREFIX;
/**
* The Configuration Properties for Dubbo Cloud Gateway
* The Configuration Properties for Dubbo Cloud Gateway.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@ -29,12 +29,12 @@ import static com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayConstants.CONFIG_
public class DubboCloudGatewayProperties {
/**
* Enabled or not
* Enabled or not.
*/
private boolean enabled = true;
/**
* The context path for the gateway request mapping
* The context path for the gateway request mapping.
*/
private String contextPath = "";
@ -53,4 +53,5 @@ public class DubboCloudGatewayProperties {
public void setContextPath(String contextPath) {
this.contextPath = contextPath;
}
}

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.gateway.autoconfigure;
import com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration;
@ -34,7 +34,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService;
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "dubbo.cloud.gateway", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "dubbo.cloud.gateway", name = "enabled",
havingValue = "true", matchIfMissing = true)
@AutoConfigureAfter({ DubboServiceAutoConfiguration.class,
DubboMetadataAutoConfiguration.class })
@EnableConfigurationProperties(DubboCloudGatewayProperties.class)
@ -51,4 +52,5 @@ public class DubboCloudGatewayAutoConfiguration {
return new DubboCloudGatewayExecutor(repository, serviceFactory, contextFactory,
dubboCloudGatewayProperties, conversionServices);
}
}

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.gateway.autoconfigure;
import com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration;
import com.alibaba.cloud.dubbo.autoconfigure.DubboServiceAutoConfiguration;
import com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayExecutor;
import com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayProperties;
import com.alibaba.cloud.dubbo.gateway.standard.DubboSpringCloudGatewayFilter;
import com.alibaba.cloud.dubbo.gateway.bootstrap.DubboSpringCloudGatewayFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -38,13 +38,14 @@ import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.codec.support.DefaultServerCodecConfigurer;
/**
* The Auto-{@link Configuration} of Dubbo Spring Cloud Gateway
* The Auto-{@link Configuration} of Dubbo Spring Cloud Gateway.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(GlobalFilter.class)
@ConditionalOnProperty(prefix = "dubbo.cloud.gateway", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "dubbo.cloud.gateway", name = "enabled",
havingValue = "true", matchIfMissing = true)
@AutoConfigureAfter({ DubboServiceAutoConfiguration.class,
DubboMetadataAutoConfiguration.class, DubboCloudGatewayAutoConfiguration.class })
@EnableConfigurationProperties(DubboCloudGatewayProperties.class)

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.gateway.standard;
package com.alibaba.cloud.dubbo.gateway.bootstrap;
import com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayExecutor;
import org.apache.commons.logging.Log;
@ -29,7 +29,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;
/**
* The Spring Cloud {@link GatewayFilter Gateway Filter} for Dubbo
* The Spring Cloud {@link GatewayFilter Gateway Filter} for Dubbo.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,20 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.gateway.standard;
import org.springframework.boot.autoconfigure.SpringBootApplication;
package com.alibaba.cloud.dubbo.gateway.bootstrap;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* The bootstrap class of Dubbo Spring Cloud Gateway
* The bootstrap class of Dubbo Spring Cloud Gateway.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@SpringBootApplication
@EnableAutoConfiguration
@EnableDiscoveryClient
public class DubboSpringCloudGatewayBootstrap {
public final class DubboSpringCloudGatewayBootstrap {
private DubboSpringCloudGatewayBootstrap() {
}
public static void main(String[] args) {
new SpringApplicationBuilder(DubboSpringCloudGatewayBootstrap.class)

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>

@ -31,7 +31,6 @@ import com.alibaba.cloud.dubbo.service.IntrospectiveDubboMetadataService;
import com.alibaba.cloud.dubbo.util.DubboMetadataUtils;
import com.alibaba.cloud.dubbo.util.JSONUtils;
import feign.Contract;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.spring.ServiceBean;
import org.apache.dubbo.config.spring.context.event.ServiceBeanExportedEvent;

@ -98,11 +98,12 @@ import static org.springframework.util.StringUtils.hasText;
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(name = "org.springframework.cloud.client.discovery.DiscoveryClient")
@ConditionalOnProperty(name = "spring.cloud.discovery.enabled", matchIfMissing = true)
@AutoConfigureAfter(name = { EUREKA_CLIENT_AUTO_CONFIGURATION_CLASS_NAME,
ZOOKEEPER_DISCOVERY_AUTO_CONFIGURATION_CLASS_NAME,
CONSUL_DISCOVERY_AUTO_CONFIGURATION_CLASS_NAME,
NACOS_DISCOVERY_AUTO_CONFIGURATION_CLASS_NAME }, value = {
DubboServiceRegistrationAutoConfiguration.class })
@AutoConfigureAfter(
name = { EUREKA_CLIENT_AUTO_CONFIGURATION_CLASS_NAME,
ZOOKEEPER_DISCOVERY_AUTO_CONFIGURATION_CLASS_NAME,
CONSUL_DISCOVERY_AUTO_CONFIGURATION_CLASS_NAME,
NACOS_DISCOVERY_AUTO_CONFIGURATION_CLASS_NAME },
value = { DubboServiceRegistrationAutoConfiguration.class })
public class DubboServiceDiscoveryAutoConfiguration {
/**

@ -90,4 +90,5 @@ public class DubboCloudProperties {
public void setRegistryType(String registryType) {
this.registryType = registryType;
}
}

@ -40,9 +40,7 @@ import com.alibaba.cloud.dubbo.util.DubboMetadataUtils;
import com.alibaba.cloud.dubbo.util.JSONUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.apache.dubbo.common.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.metadata.repository;
import java.util.List;
@ -26,7 +26,7 @@ import static java.util.Optional.of;
import static org.springframework.util.CollectionUtils.isEmpty;
/**
* Random {@link ServiceInstanceSelector}
* Random {@link ServiceInstanceSelector}.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@ -40,4 +40,5 @@ public class RandomServiceInstanceSelector implements ServiceInstanceSelector {
ThreadLocalRandom random = ThreadLocalRandom.current();
return of(serviceInstances.get(random.nextInt(serviceInstances.size())));
}
}

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.registry;
import java.util.Collection;
@ -33,13 +33,10 @@ import com.alibaba.cloud.dubbo.service.DubboMetadataService;
import com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy;
import com.alibaba.cloud.dubbo.util.DubboMetadataUtils;
import com.alibaba.cloud.dubbo.util.JSONUtils;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.metadata.MetadataService;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.support.FailbackRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -69,7 +66,8 @@ import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataU
import static org.springframework.util.StringUtils.hasText;
/**
* Dubbo Cloud {@link FailbackRegistry} is based on Spring Cloud {@link DiscoveryClient}
* Dubbo Cloud {@link FailbackRegistry} is based on Spring Cloud {@link DiscoveryClient}.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
public class DubboCloudRegistry extends FailbackRegistry {
@ -273,7 +271,7 @@ public class DubboCloudRegistry extends FailbackRegistry {
}
/**
* Clone the subscribed URLs based on the template URLs
* Clone the subscribed URLs based on the template URLs.
* @param subscribedURL the URL to be subscribed
* @param serviceInstances the list of {@link ServiceInstance service instances}
* @return non-null

@ -21,7 +21,6 @@ import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepositor
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
import com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy;
import com.alibaba.cloud.dubbo.util.JSONUtils;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.RegistryFactory;
@ -31,7 +30,6 @@ import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import static com.alibaba.cloud.dubbo.util.DubboCloudConstants.SPRING_CLOUD_REGISTRY_PROPERTY_VALUE;
import static java.lang.System.getProperty;
/**
* Dubbo {@link RegistryFactory} uses Spring Cloud Service Registration abstraction, whose
@ -53,12 +51,6 @@ public class SpringCloudRegistryFactory extends AbstractRegistryFactory {
*/
public static String ADDRESS = "localhost";
public static String MODE = "dubbo.cloud.";
private static String SERVICES_LOOKUP_SCHEDULER_THREAD_NAME_PREFIX = getProperty(
"dubbo.services.lookup.scheduler.thread.name.prefix ",
"dubbo-services-lookup-");
private static ConfigurableApplicationContext applicationContext;
private DiscoveryClient discoveryClient;

@ -30,13 +30,11 @@ import javax.annotation.PreDestroy;
import com.alibaba.cloud.dubbo.metadata.DubboRestServiceMetadata;
import com.alibaba.cloud.dubbo.metadata.ServiceRestMetadata;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.rpc.service.GenericService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -24,9 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository;
import com.alibaba.cloud.dubbo.metadata.repository.ServiceInstanceSelector;
import com.alibaba.cloud.dubbo.util.DubboMetadataUtils;
import org.apache.dubbo.common.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -82,7 +80,7 @@ public class DubboMetadataServiceProxy implements BeanClassLoaderAware, Disposab
}
/**
* Get the proxy of {@link DubboMetadataService} if possible
* Get the proxy of {@link DubboMetadataService} if possible.
* @param serviceInstances the instances of {@link DubboMetadataService}
* @return <code>null</code> if initialization can't be done
*/
@ -114,7 +112,7 @@ public class DubboMetadataServiceProxy implements BeanClassLoaderAware, Disposab
}
/**
* Is the {@link DubboMetadataService}'s Proxy initialized or not
* Is the {@link DubboMetadataService}'s Proxy initialized or not.
* @param serviceName the service name
* @return <code>true</code> if initialized , or return <code>false</code>
*/

@ -23,28 +23,29 @@ package com.alibaba.cloud.dubbo.util;
*/
public final class DubboCloudConstants {
private DubboCloudConstants() {
throw new AssertionError("Must not instantiate constant utility class");
}
/**
* The property prefix of Configuration.
*/
public static final String CONFIG_PROPERTY_PREFIX = "dubbo.cloud";
/**
* The property name of Registry type
* The property name of Registry type.
*/
String REGISTRY_TYPE_PROPERTY_NAME = CONFIG_PROPERTY_PREFIX + ".registry-type";
public static final String REGISTRY_TYPE_PROPERTY_NAME = CONFIG_PROPERTY_PREFIX
+ ".registry-type";
/**
* The property value of Spring Cloud Registry
* The property value of Spring Cloud Registry.
*/
String SPRING_CLOUD_REGISTRY_PROPERTY_VALUE = "spring-cloud";
public static final String SPRING_CLOUD_REGISTRY_PROPERTY_VALUE = "spring-cloud";
/**
* The property value of Dubbo Cloud Registry
* The property value of Dubbo Cloud Registry.
*/
String DUBBO_CLOUD_REGISTRY_PROPERTY_VALUE = "dubbo-cloud";
public static final String DUBBO_CLOUD_REGISTRY_PROPERTY_VALUE = "dubbo-cloud";
private DubboCloudConstants() {
throw new AssertionError("Must not instantiate constant utility class");
}
}

@ -1,12 +1,11 @@
/*
* 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
* Copyright 2013-2018 the original author or authors.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed 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
*
* https://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,
@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.util;
import java.util.List;
@ -22,7 +22,6 @@ import java.util.Objects;
import java.util.stream.Collectors;
import com.alibaba.cloud.dubbo.service.DubboMetadataService;
import org.apache.dubbo.common.URL;
import org.springframework.cloud.client.ServiceInstance;
@ -34,8 +33,8 @@ import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataU
import static org.springframework.util.StringUtils.hasText;
/**
* The utilities class of Dubbo Metadata
*
* The utilities class of Dubbo Metadata.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
public class DubboMetadataUtils {
@ -59,7 +58,7 @@ public class DubboMetadataUtils {
}
/**
* Get the current application name
* Get the current application name.
* @return non-null
*/
public String getCurrentApplicationName() {
@ -115,4 +114,5 @@ public class DubboMetadataUtils {
String protocolPort = metadata.get(protocolProperty);
return hasText(protocolPort) ? Integer.valueOf(protocolPort) : null;
}
}

@ -1,7 +1,6 @@
# Dubbo Endpoints Default Properties is loaded by @PropertySource with low order,
# Set enabled for Dubbo Endpoints
management.endpoint.dubborestmetadata.enabled = true
management.endpoint.dubborestmetadata.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.dubborestmetadata = dubbo/rest/metadata
management.endpoints.web.path-mapping.dubborestmetadata=dubbo/rest/metadata

@ -6,12 +6,9 @@ com.alibaba.cloud.dubbo.autoconfigure.DubboServiceRegistrationNonWebApplicationA
com.alibaba.cloud.dubbo.autoconfigure.DubboLoadBalancedRestTemplateAutoConfiguration,\
com.alibaba.cloud.dubbo.autoconfigure.DubboServiceAutoConfiguration,\
com.alibaba.cloud.dubbo.autoconfigure.DubboServiceDiscoveryAutoConfiguration
org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=\
com.alibaba.cloud.dubbo.actuate.DubboMetadataEndpointAutoConfiguration
org.springframework.context.ApplicationContextInitializer=\
com.alibaba.cloud.dubbo.context.DubboServiceRegistrationApplicationContextInitializer
org.springframework.boot.env.EnvironmentPostProcessor=\
com.alibaba.cloud.dubbo.env.DubboNonWebApplicationEnvironmentPostProcessor

@ -169,8 +169,8 @@ public class RocketMQMessageChannelBinder extends
rocketMQTemplate, destination.getName(), producerGroup,
producerProperties.getExtension().getTransactional(),
instrumentationManager, producerProperties,
((AbstractMessageChannel) channel).getInterceptors().stream()
.filter(channelInterceptor -> channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor)
((AbstractMessageChannel) channel).getInterceptors().stream().filter(
channelInterceptor -> channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor)
.map(channelInterceptor -> ((MessageConverterConfigurer.PartitioningInterceptor) channelInterceptor))
.findFirst().orElse(null));
messageHandler.setBeanFactory(this.getApplicationContext().getBeanFactory());

Loading…
Cancel
Save