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

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

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

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

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

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

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

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

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

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

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

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.gateway; package com.alibaba.cloud.dubbo.gateway;
import com.alibaba.cloud.dubbo.util.DubboCloudConstants; 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> * @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"; + ".gateway";
} }

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.gateway; package com.alibaba.cloud.dubbo.gateway;
import java.net.URI; import java.net.URI;
@ -30,7 +30,6 @@ import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactor
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory; import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.dubbo.rpc.service.GenericException; import org.apache.dubbo.rpc.service.GenericException;
import org.apache.dubbo.rpc.service.GenericService; 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 * 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> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* *
*/ */
public class DubboCloudGatewayExecutor { 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} * @param request {@link HttpRequest}
* @return * @return
*/ */

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.gateway; package com.alibaba.cloud.dubbo.gateway;
import org.springframework.boot.context.properties.ConfigurationProperties; 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; 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> * @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 { public class DubboCloudGatewayProperties {
/** /**
* Enabled or not * Enabled or not.
*/ */
private boolean enabled = true; private boolean enabled = true;
/** /**
* The context path for the gateway request mapping * The context path for the gateway request mapping.
*/ */
private String contextPath = ""; private String contextPath = "";
@ -53,4 +53,5 @@ public class DubboCloudGatewayProperties {
public void setContextPath(String contextPath) { public void setContextPath(String contextPath) {
this.contextPath = contextPath; this.contextPath = contextPath;
} }
} }

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.gateway.autoconfigure; package com.alibaba.cloud.dubbo.gateway.autoconfigure;
import com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration; import com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration;
@ -34,7 +34,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
@Configuration(proxyBeanMethods = false) @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, @AutoConfigureAfter({ DubboServiceAutoConfiguration.class,
DubboMetadataAutoConfiguration.class }) DubboMetadataAutoConfiguration.class })
@EnableConfigurationProperties(DubboCloudGatewayProperties.class) @EnableConfigurationProperties(DubboCloudGatewayProperties.class)
@ -51,4 +52,5 @@ public class DubboCloudGatewayAutoConfiguration {
return new DubboCloudGatewayExecutor(repository, serviceFactory, contextFactory, return new DubboCloudGatewayExecutor(repository, serviceFactory, contextFactory,
dubboCloudGatewayProperties, conversionServices); dubboCloudGatewayProperties, conversionServices);
} }
} }

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.gateway.autoconfigure; package com.alibaba.cloud.dubbo.gateway.autoconfigure;
import com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration; import com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration;
import com.alibaba.cloud.dubbo.autoconfigure.DubboServiceAutoConfiguration; import com.alibaba.cloud.dubbo.autoconfigure.DubboServiceAutoConfiguration;
import com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayExecutor; import com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayExecutor;
import com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayProperties; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -38,13 +38,14 @@ import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.codec.support.DefaultServerCodecConfigurer; 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> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass(GlobalFilter.class) @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, @AutoConfigureAfter({ DubboServiceAutoConfiguration.class,
DubboMetadataAutoConfiguration.class, DubboCloudGatewayAutoConfiguration.class }) DubboMetadataAutoConfiguration.class, DubboCloudGatewayAutoConfiguration.class })
@EnableConfigurationProperties(DubboCloudGatewayProperties.class) @EnableConfigurationProperties(DubboCloudGatewayProperties.class)

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * 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 com.alibaba.cloud.dubbo.gateway.DubboCloudGatewayExecutor;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -29,7 +29,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange; 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> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * 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.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 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> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */
@SpringBootApplication @EnableAutoConfiguration
@EnableDiscoveryClient @EnableDiscoveryClient
public class DubboSpringCloudGatewayBootstrap { public final class DubboSpringCloudGatewayBootstrap {
private DubboSpringCloudGatewayBootstrap() {
}
public static void main(String[] args) { public static void main(String[] args) {
new SpringApplicationBuilder(DubboSpringCloudGatewayBootstrap.class) new SpringApplicationBuilder(DubboSpringCloudGatewayBootstrap.class)

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <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.DubboMetadataUtils;
import com.alibaba.cloud.dubbo.util.JSONUtils; import com.alibaba.cloud.dubbo.util.JSONUtils;
import feign.Contract; import feign.Contract;
import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.spring.ServiceBean; import org.apache.dubbo.config.spring.ServiceBean;
import org.apache.dubbo.config.spring.context.event.ServiceBeanExportedEvent; import org.apache.dubbo.config.spring.context.event.ServiceBeanExportedEvent;

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

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

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

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.metadata.repository; package com.alibaba.cloud.dubbo.metadata.repository;
import java.util.List; import java.util.List;
@ -26,7 +26,7 @@ import static java.util.Optional.of;
import static org.springframework.util.CollectionUtils.isEmpty; import static org.springframework.util.CollectionUtils.isEmpty;
/** /**
* Random {@link ServiceInstanceSelector} * Random {@link ServiceInstanceSelector}.
* *
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */
@ -40,4 +40,5 @@ public class RandomServiceInstanceSelector implements ServiceInstanceSelector {
ThreadLocalRandom random = ThreadLocalRandom.current(); ThreadLocalRandom random = ThreadLocalRandom.current();
return of(serviceInstances.get(random.nextInt(serviceInstances.size()))); return of(serviceInstances.get(random.nextInt(serviceInstances.size())));
} }
} }

@ -1,12 +1,11 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.registry; package com.alibaba.cloud.dubbo.registry;
import java.util.Collection; 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.service.DubboMetadataServiceProxy;
import com.alibaba.cloud.dubbo.util.DubboMetadataUtils; import com.alibaba.cloud.dubbo.util.DubboMetadataUtils;
import com.alibaba.cloud.dubbo.util.JSONUtils; import com.alibaba.cloud.dubbo.util.JSONUtils;
import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder; import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.metadata.MetadataService;
import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.support.FailbackRegistry; import org.apache.dubbo.registry.support.FailbackRegistry;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -69,7 +66,8 @@ import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataU
import static org.springframework.util.StringUtils.hasText; 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> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */
public class DubboCloudRegistry extends FailbackRegistry { 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 subscribedURL the URL to be subscribed
* @param serviceInstances the list of {@link ServiceInstance service instances} * @param serviceInstances the list of {@link ServiceInstance service instances}
* @return non-null * @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.DubboGenericServiceFactory;
import com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy; import com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy;
import com.alibaba.cloud.dubbo.util.JSONUtils; import com.alibaba.cloud.dubbo.util.JSONUtils;
import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URL;
import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.RegistryFactory; import org.apache.dubbo.registry.RegistryFactory;
@ -31,7 +30,6 @@ import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import static com.alibaba.cloud.dubbo.util.DubboCloudConstants.SPRING_CLOUD_REGISTRY_PROPERTY_VALUE; 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 * 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 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 static ConfigurableApplicationContext applicationContext;
private DiscoveryClient discoveryClient; private DiscoveryClient discoveryClient;

@ -30,13 +30,11 @@ import javax.annotation.PreDestroy;
import com.alibaba.cloud.dubbo.metadata.DubboRestServiceMetadata; import com.alibaba.cloud.dubbo.metadata.DubboRestServiceMetadata;
import com.alibaba.cloud.dubbo.metadata.ServiceRestMetadata; import com.alibaba.cloud.dubbo.metadata.ServiceRestMetadata;
import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.ReferenceBean; import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.rpc.service.GenericService; import org.apache.dubbo.rpc.service.GenericService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.DubboServiceMetadataRepository;
import com.alibaba.cloud.dubbo.metadata.repository.ServiceInstanceSelector; import com.alibaba.cloud.dubbo.metadata.repository.ServiceInstanceSelector;
import com.alibaba.cloud.dubbo.util.DubboMetadataUtils; import com.alibaba.cloud.dubbo.util.DubboMetadataUtils;
import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URL;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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} * @param serviceInstances the instances of {@link DubboMetadataService}
* @return <code>null</code> if initialization can't be done * @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 * @param serviceName the service name
* @return <code>true</code> if initialized , or return <code>false</code> * @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 { public final class DubboCloudConstants {
private DubboCloudConstants() {
throw new AssertionError("Must not instantiate constant utility class");
}
/** /**
* The property prefix of Configuration. * The property prefix of Configuration.
*/ */
public static final String CONFIG_PROPERTY_PREFIX = "dubbo.cloud"; 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 * Copyright 2013-2018 the original author or authors.
* 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 * 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 * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * 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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.dubbo.util; package com.alibaba.cloud.dubbo.util;
import java.util.List; import java.util.List;
@ -22,7 +22,6 @@ import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.cloud.dubbo.service.DubboMetadataService; import com.alibaba.cloud.dubbo.service.DubboMetadataService;
import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URL;
import org.springframework.cloud.client.ServiceInstance; 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; 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> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */
public class DubboMetadataUtils { public class DubboMetadataUtils {
@ -59,7 +58,7 @@ public class DubboMetadataUtils {
} }
/** /**
* Get the current application name * Get the current application name.
* @return non-null * @return non-null
*/ */
public String getCurrentApplicationName() { public String getCurrentApplicationName() {
@ -115,4 +114,5 @@ public class DubboMetadataUtils {
String protocolPort = metadata.get(protocolProperty); String protocolPort = metadata.get(protocolProperty);
return hasText(protocolPort) ? Integer.valueOf(protocolPort) : null; return hasText(protocolPort) ? Integer.valueOf(protocolPort) : null;
} }
} }

@ -1,7 +1,6 @@
# Dubbo Endpoints Default Properties is loaded by @PropertySource with low order, # Dubbo Endpoints Default Properties is loaded by @PropertySource with low order,
# Set enabled for Dubbo Endpoints # 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 # "management.endpoints.web.base-path" should not be configured in this file
# Re-defines path-mapping of Dubbo Web Endpoints # 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.DubboLoadBalancedRestTemplateAutoConfiguration,\
com.alibaba.cloud.dubbo.autoconfigure.DubboServiceAutoConfiguration,\ com.alibaba.cloud.dubbo.autoconfigure.DubboServiceAutoConfiguration,\
com.alibaba.cloud.dubbo.autoconfigure.DubboServiceDiscoveryAutoConfiguration com.alibaba.cloud.dubbo.autoconfigure.DubboServiceDiscoveryAutoConfiguration
org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=\ org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=\
com.alibaba.cloud.dubbo.actuate.DubboMetadataEndpointAutoConfiguration com.alibaba.cloud.dubbo.actuate.DubboMetadataEndpointAutoConfiguration
org.springframework.context.ApplicationContextInitializer=\ org.springframework.context.ApplicationContextInitializer=\
com.alibaba.cloud.dubbo.context.DubboServiceRegistrationApplicationContextInitializer com.alibaba.cloud.dubbo.context.DubboServiceRegistrationApplicationContextInitializer
org.springframework.boot.env.EnvironmentPostProcessor=\ org.springframework.boot.env.EnvironmentPostProcessor=\
com.alibaba.cloud.dubbo.env.DubboNonWebApplicationEnvironmentPostProcessor com.alibaba.cloud.dubbo.env.DubboNonWebApplicationEnvironmentPostProcessor

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

Loading…
Cancel
Save