mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
sync dubbo in finchley
This commit is contained in:
parent
ade58496fc
commit
c98fa4e1f7
@ -15,7 +15,6 @@
|
||||
|
||||
<properties>
|
||||
<dubbo.version>2.7.1</dubbo.version>
|
||||
<dubbo-spring-boot.version>2.7.0</dubbo-spring-boot.version>
|
||||
<spring-cloud-zookeeper.version>2.0.1.RELEASE</spring-cloud-zookeeper.version>
|
||||
<spring-cloud-consul.version>2.0.2.RELEASE</spring-cloud-consul.version>
|
||||
<curator.version>4.0.1</curator.version>
|
||||
@ -182,6 +181,13 @@
|
||||
<version>${dubbo.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dubbo Spring Boot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-actuator</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Netty -->
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.alibaba.dubbo.actuate;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cloud.alibaba.dubbo.actuate.endpoint.DubboRestMetadataEndpoint;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* Dubbo Metadata Endpoints Auto-{@link Configuration}
|
||||
*/
|
||||
@ConditionalOnClass(name = "org.springframework.boot.actuate.endpoint.annotation.Endpoint")
|
||||
@PropertySource(value = "classpath:/META-INF/dubbo/default/actuator-endpoints.properties")
|
||||
@ManagementContextConfiguration
|
||||
public class DubboMetadataEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
public DubboRestMetadataEndpoint dubboRestMetadataEndpoint() {
|
||||
return new DubboRestMetadataEndpoint();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.alibaba.dubbo.actuate.endpoint;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataService;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;
|
||||
|
||||
/**
|
||||
* Dubbo Rest Metadata {@link Endpoint}
|
||||
*/
|
||||
@Endpoint(id = "dubborestmetadata")
|
||||
public class DubboRestMetadataEndpoint {
|
||||
|
||||
@Autowired
|
||||
private DubboMetadataService dubboMetadataService;
|
||||
|
||||
@ReadOperation(produces = APPLICATION_JSON_UTF8_VALUE)
|
||||
public String get() {
|
||||
return dubboMetadataService.getServiceRestMetadata();
|
||||
}
|
||||
}
|
@ -35,6 +35,7 @@ import org.springframework.cloud.alibaba.dubbo.service.DubboGenericServiceFactor
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor;
|
||||
import org.springframework.cloud.client.loadbalancer.RestTemplateCustomizer;
|
||||
import org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.core.env.Environment;
|
||||
@ -56,7 +57,7 @@ import java.util.Map;
|
||||
@Configuration
|
||||
@ConditionalOnClass(name = {"org.springframework.web.client.RestTemplate"})
|
||||
@AutoConfigureAfter(name = {"org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration"})
|
||||
public class DubboLoadBalancedRestTemplateAutoConfiguration implements BeanClassLoaderAware {
|
||||
public class DubboLoadBalancedRestTemplateAutoConfiguration implements BeanClassLoaderAware, SmartInitializingSingleton {
|
||||
|
||||
private static final Class<DubboTransported> DUBBO_TRANSPORTED_CLASS = DubboTransported.class;
|
||||
|
||||
@ -65,9 +66,12 @@ public class DubboLoadBalancedRestTemplateAutoConfiguration implements BeanClass
|
||||
@Autowired
|
||||
private DubboServiceMetadataRepository repository;
|
||||
|
||||
@Autowired
|
||||
@Autowired(required = false)
|
||||
private LoadBalancerInterceptor loadBalancerInterceptor;
|
||||
|
||||
@Autowired(required = false)
|
||||
private RetryLoadBalancerInterceptor retryLoadBalancerInterceptor;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
@ -86,6 +90,17 @@ public class DubboLoadBalancedRestTemplateAutoConfiguration implements BeanClass
|
||||
|
||||
private ClassLoader classLoader;
|
||||
|
||||
/**
|
||||
* The {@link ClientHttpRequestInterceptor} bean that may be {@link LoadBalancerInterceptor} or {@link RetryLoadBalancerInterceptor}
|
||||
*/
|
||||
private ClientHttpRequestInterceptor loadBalancerInterceptorBean;
|
||||
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
loadBalancerInterceptorBean = retryLoadBalancerInterceptor != null ?
|
||||
retryLoadBalancerInterceptor :
|
||||
loadBalancerInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt the {@link RestTemplate} beans that are annotated {@link LoadBalanced @LoadBalanced} and
|
||||
@ -140,7 +155,7 @@ public class DubboLoadBalancedRestTemplateAutoConfiguration implements BeanClass
|
||||
|
||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(restTemplate.getInterceptors());
|
||||
|
||||
int index = interceptors.indexOf(loadBalancerInterceptor);
|
||||
int index = loadBalancerInterceptorBean == null ? -1 : interceptors.indexOf(loadBalancerInterceptorBean);
|
||||
|
||||
index = index < 0 ? 0 : index;
|
||||
|
||||
@ -157,4 +172,5 @@ public class DubboLoadBalancedRestTemplateAutoConfiguration implements BeanClass
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import org.springframework.cloud.alibaba.dubbo.metadata.repository.DubboServiceM
|
||||
import org.springframework.cloud.alibaba.dubbo.metadata.resolver.DubboServiceBeanMetadataResolver;
|
||||
import org.springframework.cloud.alibaba.dubbo.metadata.resolver.MetadataResolver;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboGenericServiceFactory;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigServiceExporter;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigServiceProxy;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.PublishingDubboMetadataConfigService;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataServiceExporter;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataServiceProxy;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.PublishingDubboMetadataService;
|
||||
import org.springframework.cloud.alibaba.dubbo.util.JSONUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -50,19 +50,19 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
@Configuration
|
||||
@Import({DubboServiceMetadataRepository.class,
|
||||
PublishingDubboMetadataConfigService.class,
|
||||
DubboMetadataConfigServiceExporter.class,
|
||||
PublishingDubboMetadataService.class,
|
||||
DubboMetadataServiceExporter.class,
|
||||
JSONUtils.class})
|
||||
public class DubboMetadataAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private PublishingDubboMetadataConfigService dubboMetadataConfigService;
|
||||
private PublishingDubboMetadataService dubboMetadataService;
|
||||
|
||||
@Autowired
|
||||
private MetadataResolver metadataResolver;
|
||||
|
||||
@Autowired
|
||||
private DubboMetadataConfigServiceExporter dubboMetadataConfigServiceExporter;
|
||||
private DubboMetadataServiceExporter dubboMetadataConfigServiceExporter;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ -77,8 +77,8 @@ public class DubboMetadataAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public DubboMetadataConfigServiceProxy dubboMetadataConfigServiceProxy(DubboGenericServiceFactory factory) {
|
||||
return new DubboMetadataConfigServiceProxy(factory);
|
||||
public DubboMetadataServiceProxy dubboMetadataConfigServiceProxy(DubboGenericServiceFactory factory) {
|
||||
return new DubboMetadataServiceProxy(factory);
|
||||
}
|
||||
|
||||
// Event-Handling
|
||||
@ -101,7 +101,7 @@ public class DubboMetadataAutoConfiguration {
|
||||
}
|
||||
|
||||
private void publishServiceRestMetadata(ServiceBean serviceBean) {
|
||||
dubboMetadataConfigService.publishServiceRestMetadata(metadataResolver.resolveServiceRestMetadata(serviceBean));
|
||||
dubboMetadataService.publishServiceRestMetadata(metadataResolver.resolveServiceRestMetadata(serviceBean));
|
||||
}
|
||||
|
||||
private void exportDubboMetadataConfigService() {
|
||||
|
@ -18,7 +18,6 @@ package org.springframework.cloud.alibaba.dubbo.autoconfigure;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.config.spring.ServiceBean;
|
||||
import org.apache.dubbo.config.spring.context.event.ServiceBeanExportedEvent;
|
||||
|
||||
import com.ecwid.consul.v1.agent.model.NewService;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
@ -30,6 +29,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
import org.springframework.cloud.alibaba.dubbo.metadata.repository.DubboServiceMetadataRepository;
|
||||
import org.springframework.cloud.alibaba.dubbo.registry.event.ServiceInstancePreRegisteredEvent;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
@ -40,7 +41,7 @@ import org.springframework.cloud.zookeeper.serviceregistry.ServiceInstanceRegist
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationAutoConfiguration.CONSUL_AUTO_CONFIGURATION_CLASS_NAME;
|
||||
import static org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationAutoConfiguration.ZOOKEEPER_AUTO_CONFIGURATION_CLASS_NAME;
|
||||
@ -65,18 +66,21 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration {
|
||||
@Autowired
|
||||
private Registration registration;
|
||||
|
||||
private volatile Integer webPort = null;
|
||||
private volatile Integer serverPort = null;
|
||||
|
||||
private volatile boolean registered = false;
|
||||
|
||||
@Autowired
|
||||
private DubboServiceMetadataRepository repository;
|
||||
|
||||
@Around("execution(* org.springframework.cloud.client.serviceregistry.Registration.getPort())")
|
||||
public Object getPort(ProceedingJoinPoint pjp) throws Throwable {
|
||||
return webPort != null ? webPort : pjp.proceed();
|
||||
return serverPort != null ? serverPort : pjp.proceed();
|
||||
}
|
||||
|
||||
@EventListener(ServiceBeanExportedEvent.class)
|
||||
public void onServiceBeanExported(ServiceBeanExportedEvent event) {
|
||||
setWebPort(event.getServiceBean());
|
||||
@EventListener(ApplicationStartedEvent.class)
|
||||
public void onApplicationStarted() {
|
||||
setServerPort();
|
||||
register();
|
||||
}
|
||||
|
||||
@ -90,18 +94,24 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration {
|
||||
|
||||
/**
|
||||
* Set web port from {@link ServiceBean#getExportedUrls() exported URLs} if "rest" protocol is present.
|
||||
*
|
||||
* @param serviceBean {@link ServiceBean}
|
||||
*/
|
||||
private void setWebPort(ServiceBean serviceBean) {
|
||||
if (webPort == null) {
|
||||
List<URL> urls = serviceBean.getExportedUrls();
|
||||
private void setServerPort() {
|
||||
if (serverPort == null) {
|
||||
Collection<URL> urls = repository.getRegisteredUrls();
|
||||
urls.stream()
|
||||
.filter(url -> REST_PROTOCOL.equalsIgnoreCase(url.getProtocol()))
|
||||
.findFirst()
|
||||
.ifPresent(url -> {
|
||||
webPort = url.getPort();
|
||||
serverPort = url.getPort();
|
||||
});
|
||||
|
||||
// If REST protocol is not present, use any applied port.
|
||||
if (serverPort == null) {
|
||||
urls.stream()
|
||||
.findAny().ifPresent(url -> {
|
||||
serverPort = url.getPort();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +124,7 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration {
|
||||
|
||||
@EventListener(ServiceInstancePreRegisteredEvent.class)
|
||||
public void onServiceInstancePreRegistered(ServiceInstancePreRegisteredEvent event) {
|
||||
registration.setPort(webPort);
|
||||
registration.setPort(serverPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,14 +29,15 @@ import org.springframework.cloud.alibaba.dubbo.http.matcher.RequestMetadataMatch
|
||||
import org.springframework.cloud.alibaba.dubbo.metadata.DubboRestServiceMetadata;
|
||||
import org.springframework.cloud.alibaba.dubbo.metadata.RequestMetadata;
|
||||
import org.springframework.cloud.alibaba.dubbo.metadata.ServiceRestMetadata;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigService;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigServiceProxy;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataService;
|
||||
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataServiceProxy;
|
||||
import org.springframework.cloud.alibaba.dubbo.util.JSONUtils;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collection;
|
||||
@ -88,7 +89,7 @@ public class DubboServiceMetadataRepository {
|
||||
private DubboCloudProperties dubboCloudProperties;
|
||||
|
||||
@Autowired
|
||||
private DubboMetadataConfigServiceProxy dubboMetadataConfigServiceProxy;
|
||||
private DubboMetadataServiceProxy dubboMetadataConfigServiceProxy;
|
||||
|
||||
@Autowired
|
||||
private DiscoveryClient discoveryClient;
|
||||
@ -255,13 +256,15 @@ public class DubboServiceMetadataRepository {
|
||||
}
|
||||
|
||||
private Set<ServiceRestMetadata> getServiceRestMetadataSet(String serviceName) {
|
||||
DubboMetadataConfigService dubboMetadataConfigService = dubboMetadataConfigServiceProxy.newProxy(serviceName);
|
||||
DubboMetadataService dubboMetadataService = dubboMetadataConfigServiceProxy.newProxy(serviceName);
|
||||
|
||||
Set<ServiceRestMetadata> metadata = Collections.emptySet();
|
||||
try {
|
||||
String serviceRestMetadataJsonConfig = dubboMetadataConfigService.getServiceRestMetadata();
|
||||
metadata = objectMapper.readValue(serviceRestMetadataJsonConfig,
|
||||
TypeFactory.defaultInstance().constructCollectionType(LinkedHashSet.class, ServiceRestMetadata.class));
|
||||
String serviceRestMetadataJsonConfig = dubboMetadataService.getServiceRestMetadata();
|
||||
if(StringUtils.hasText(serviceRestMetadataJsonConfig)) {
|
||||
metadata = objectMapper.readValue(serviceRestMetadataJsonConfig,
|
||||
TypeFactory.defaultInstance().constructCollectionType(LinkedHashSet.class, ServiceRestMetadata.class));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
@ -21,16 +21,16 @@ import org.springframework.cloud.alibaba.dubbo.metadata.ServiceRestMetadata;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Dubbo Metadata Configuration Service
|
||||
* Dubbo Metadata Service
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
public interface DubboMetadataConfigService {
|
||||
public interface DubboMetadataService {
|
||||
|
||||
/**
|
||||
* Get The json content of {@link ServiceRestMetadata} {@link Set}
|
||||
*
|
||||
* @return the non-null String
|
||||
* @return <code>null</code> if present
|
||||
*/
|
||||
String getServiceRestMetadata();
|
||||
}
|
@ -25,17 +25,16 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* {@link DubboMetadataConfigService} exporter
|
||||
* {@link DubboMetadataService} exporter
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@Component
|
||||
public class DubboMetadataConfigServiceExporter {
|
||||
public class DubboMetadataServiceExporter {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@ -43,7 +42,7 @@ public class DubboMetadataConfigServiceExporter {
|
||||
private ApplicationConfig applicationConfig;
|
||||
|
||||
@Autowired
|
||||
private PublishingDubboMetadataConfigService dubboMetadataConfigService;
|
||||
private DubboMetadataService dubboMetadataService;
|
||||
|
||||
@Autowired
|
||||
private Supplier<ProtocolConfig> protocolConfigSupplier;
|
||||
@ -54,10 +53,10 @@ public class DubboMetadataConfigServiceExporter {
|
||||
/**
|
||||
* The ServiceConfig of DubboMetadataConfigService to be exported, can be nullable.
|
||||
*/
|
||||
private ServiceConfig<DubboMetadataConfigService> serviceConfig;
|
||||
private ServiceConfig<DubboMetadataService> serviceConfig;
|
||||
|
||||
/**
|
||||
* export {@link DubboMetadataConfigService} as Dubbo service
|
||||
* export {@link DubboMetadataService} as Dubbo service
|
||||
*/
|
||||
public void export() {
|
||||
|
||||
@ -65,21 +64,12 @@ public class DubboMetadataConfigServiceExporter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dubboMetadataConfigService.getServiceRestMetadata())) {
|
||||
// If there is no REST metadata, DubboMetadataConfigService will not be exported.
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("There is no REST metadata, the Dubbo service[{}] will not be exported.",
|
||||
dubboMetadataConfigService.getClass().getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
|
||||
serviceConfig.setInterface(DubboMetadataConfigService.class);
|
||||
serviceConfig.setInterface(DubboMetadataService.class);
|
||||
// Use current Spring application name as the Dubbo Service version
|
||||
serviceConfig.setVersion(currentApplicationName);
|
||||
serviceConfig.setRef(dubboMetadataConfigService);
|
||||
serviceConfig.setRef(dubboMetadataService);
|
||||
serviceConfig.setApplication(applicationConfig);
|
||||
serviceConfig.setProtocol(protocolConfigSupplier.get());
|
||||
|
||||
@ -92,7 +82,7 @@ public class DubboMetadataConfigServiceExporter {
|
||||
|
||||
|
||||
/**
|
||||
* unexport {@link DubboMetadataConfigService}
|
||||
* unexport {@link DubboMetadataService}
|
||||
*/
|
||||
public void unexport() {
|
||||
|
@ -22,14 +22,14 @@ import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* {@link DubboMetadataConfigService} {@link InvocationHandler}
|
||||
* {@link DubboMetadataService} {@link InvocationHandler}
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
class DubboMetadataConfigServiceInvocationHandler implements InvocationHandler {
|
||||
class DubboMetadataServiceInvocationHandler implements InvocationHandler {
|
||||
|
||||
/**
|
||||
* The method name of {@link DubboMetadataConfigService#getServiceRestMetadata()}
|
||||
* The method name of {@link DubboMetadataService#getServiceRestMetadata()}
|
||||
*/
|
||||
private static final String METHOD_NAME = "getServiceRestMetadata";
|
||||
|
||||
@ -39,8 +39,8 @@ class DubboMetadataConfigServiceInvocationHandler implements InvocationHandler {
|
||||
|
||||
private final GenericService genericService;
|
||||
|
||||
public DubboMetadataConfigServiceInvocationHandler(String serviceName, DubboGenericServiceFactory dubboGenericServiceFactory) {
|
||||
this.genericService = dubboGenericServiceFactory.create(serviceName, DubboMetadataConfigService.class);
|
||||
public DubboMetadataServiceInvocationHandler(String serviceName, DubboGenericServiceFactory dubboGenericServiceFactory) {
|
||||
this.genericService = dubboGenericServiceFactory.create(serviceName, DubboMetadataService.class);
|
||||
}
|
||||
|
||||
@Override
|
@ -21,27 +21,27 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import static java.lang.reflect.Proxy.newProxyInstance;
|
||||
|
||||
/**
|
||||
* The proxy of {@link DubboMetadataConfigService}
|
||||
* The proxy of {@link DubboMetadataService}
|
||||
*/
|
||||
public class DubboMetadataConfigServiceProxy implements BeanClassLoaderAware {
|
||||
public class DubboMetadataServiceProxy implements BeanClassLoaderAware {
|
||||
|
||||
private final DubboGenericServiceFactory dubboGenericServiceFactory;
|
||||
|
||||
private ClassLoader classLoader;
|
||||
|
||||
public DubboMetadataConfigServiceProxy(DubboGenericServiceFactory dubboGenericServiceFactory) {
|
||||
public DubboMetadataServiceProxy(DubboGenericServiceFactory dubboGenericServiceFactory) {
|
||||
this.dubboGenericServiceFactory = dubboGenericServiceFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* New proxy instance of {@link DubboMetadataConfigService} via the specified service name
|
||||
* New proxy instance of {@link DubboMetadataService} via the specified service name
|
||||
*
|
||||
* @param serviceName the service name
|
||||
* @return a {@link DubboMetadataConfigService} proxy
|
||||
* @return a {@link DubboMetadataService} proxy
|
||||
*/
|
||||
public DubboMetadataConfigService newProxy(String serviceName) {
|
||||
return (DubboMetadataConfigService) newProxyInstance(classLoader, new Class[]{DubboMetadataConfigService.class},
|
||||
new DubboMetadataConfigServiceInvocationHandler(serviceName, dubboGenericServiceFactory));
|
||||
public DubboMetadataService newProxy(String serviceName) {
|
||||
return (DubboMetadataService) newProxyInstance(classLoader, new Class[]{DubboMetadataService.class},
|
||||
new DubboMetadataServiceInvocationHandler(serviceName, dubboGenericServiceFactory));
|
||||
}
|
||||
|
||||
@Override
|
@ -27,11 +27,11 @@ import java.util.Set;
|
||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||
|
||||
/**
|
||||
* Publishing {@link DubboMetadataConfigService} implementation
|
||||
* Publishing {@link DubboMetadataService} implementation
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
public class PublishingDubboMetadataConfigService implements DubboMetadataConfigService {
|
||||
public class PublishingDubboMetadataService implements DubboMetadataService {
|
||||
|
||||
/**
|
||||
* A Map to store REST metadata temporary, its' key is the special service name for a Dubbo service,
|
@ -0,0 +1,7 @@
|
||||
# Dubbo Endpoints Default Properties is loaded by @PropertySource with low order,
|
||||
# Set enabled for Dubbo Endpoints
|
||||
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
|
@ -6,10 +6,11 @@ org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationNo
|
||||
org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboLoadBalancedRestTemplateAutoConfiguration,\
|
||||
org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceAutoConfiguration
|
||||
|
||||
org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=\
|
||||
org.springframework.cloud.alibaba.dubbo.actuate.DubboMetadataEndpointAutoConfiguration
|
||||
|
||||
org.springframework.context.ApplicationContextInitializer=\
|
||||
org.springframework.cloud.alibaba.dubbo.context.DubboServiceRegistrationApplicationContextInitializer
|
||||
|
||||
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||
org.springframework.cloud.alibaba.dubbo.env.DubboNonWebApplicationEnvironmentPostProcessor
|
Loading…
x
Reference in New Issue
Block a user