1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Polish spring-cloud-incubator/spring-cloud-alibaba#542 : Rename DubboMetadataConfigService to DubboMetadataService

This commit is contained in:
mercyblitz 2019-04-10 23:54:13 +08:00
parent f2fa0addf8
commit 9caa0f9742
8 changed files with 45 additions and 45 deletions

View File

@ -19,7 +19,7 @@ package org.springframework.cloud.alibaba.dubbo.actuate.endpoint;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigService; import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataService;
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE; import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;
@ -30,10 +30,10 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;
public class DubboRestMetadataEndpoint { public class DubboRestMetadataEndpoint {
@Autowired @Autowired
private DubboMetadataConfigService dubboMetadataConfigService; private DubboMetadataService dubboMetadataService;
@ReadOperation(produces = APPLICATION_JSON_UTF8_VALUE) @ReadOperation(produces = APPLICATION_JSON_UTF8_VALUE)
public String get() { public String get() {
return dubboMetadataConfigService.getServiceRestMetadata(); return dubboMetadataService.getServiceRestMetadata();
} }
} }

View File

@ -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.DubboServiceBeanMetadataResolver;
import org.springframework.cloud.alibaba.dubbo.metadata.resolver.MetadataResolver; import org.springframework.cloud.alibaba.dubbo.metadata.resolver.MetadataResolver;
import org.springframework.cloud.alibaba.dubbo.service.DubboGenericServiceFactory; import org.springframework.cloud.alibaba.dubbo.service.DubboGenericServiceFactory;
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigServiceExporter; import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataServiceExporter;
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigServiceProxy; import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataServiceProxy;
import org.springframework.cloud.alibaba.dubbo.service.PublishingDubboMetadataConfigService; import org.springframework.cloud.alibaba.dubbo.service.PublishingDubboMetadataService;
import org.springframework.cloud.alibaba.dubbo.util.JSONUtils; import org.springframework.cloud.alibaba.dubbo.util.JSONUtils;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -50,19 +50,19 @@ import java.util.function.Supplier;
*/ */
@Configuration @Configuration
@Import({DubboServiceMetadataRepository.class, @Import({DubboServiceMetadataRepository.class,
PublishingDubboMetadataConfigService.class, PublishingDubboMetadataService.class,
DubboMetadataConfigServiceExporter.class, DubboMetadataServiceExporter.class,
JSONUtils.class}) JSONUtils.class})
public class DubboMetadataAutoConfiguration { public class DubboMetadataAutoConfiguration {
@Autowired @Autowired
private PublishingDubboMetadataConfigService dubboMetadataConfigService; private PublishingDubboMetadataService dubboMetadataService;
@Autowired @Autowired
private MetadataResolver metadataResolver; private MetadataResolver metadataResolver;
@Autowired @Autowired
private DubboMetadataConfigServiceExporter dubboMetadataConfigServiceExporter; private DubboMetadataServiceExporter dubboMetadataConfigServiceExporter;
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@ -77,8 +77,8 @@ public class DubboMetadataAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public DubboMetadataConfigServiceProxy dubboMetadataConfigServiceProxy(DubboGenericServiceFactory factory) { public DubboMetadataServiceProxy dubboMetadataConfigServiceProxy(DubboGenericServiceFactory factory) {
return new DubboMetadataConfigServiceProxy(factory); return new DubboMetadataServiceProxy(factory);
} }
// Event-Handling // Event-Handling
@ -101,7 +101,7 @@ public class DubboMetadataAutoConfiguration {
} }
private void publishServiceRestMetadata(ServiceBean serviceBean) { private void publishServiceRestMetadata(ServiceBean serviceBean) {
dubboMetadataConfigService.publishServiceRestMetadata(metadataResolver.resolveServiceRestMetadata(serviceBean)); dubboMetadataService.publishServiceRestMetadata(metadataResolver.resolveServiceRestMetadata(serviceBean));
} }
private void exportDubboMetadataConfigService() { private void exportDubboMetadataConfigService() {

View File

@ -29,8 +29,8 @@ import org.springframework.cloud.alibaba.dubbo.http.matcher.RequestMetadataMatch
import org.springframework.cloud.alibaba.dubbo.metadata.DubboRestServiceMetadata; import org.springframework.cloud.alibaba.dubbo.metadata.DubboRestServiceMetadata;
import org.springframework.cloud.alibaba.dubbo.metadata.RequestMetadata; import org.springframework.cloud.alibaba.dubbo.metadata.RequestMetadata;
import org.springframework.cloud.alibaba.dubbo.metadata.ServiceRestMetadata; import org.springframework.cloud.alibaba.dubbo.metadata.ServiceRestMetadata;
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigService; import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataService;
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigServiceProxy; import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataServiceProxy;
import org.springframework.cloud.alibaba.dubbo.util.JSONUtils; import org.springframework.cloud.alibaba.dubbo.util.JSONUtils;
import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.DiscoveryClient;
@ -88,7 +88,7 @@ public class DubboServiceMetadataRepository {
private DubboCloudProperties dubboCloudProperties; private DubboCloudProperties dubboCloudProperties;
@Autowired @Autowired
private DubboMetadataConfigServiceProxy dubboMetadataConfigServiceProxy; private DubboMetadataServiceProxy dubboMetadataConfigServiceProxy;
@Autowired @Autowired
private DiscoveryClient discoveryClient; private DiscoveryClient discoveryClient;
@ -255,11 +255,11 @@ public class DubboServiceMetadataRepository {
} }
private Set<ServiceRestMetadata> getServiceRestMetadataSet(String serviceName) { private Set<ServiceRestMetadata> getServiceRestMetadataSet(String serviceName) {
DubboMetadataConfigService dubboMetadataConfigService = dubboMetadataConfigServiceProxy.newProxy(serviceName); DubboMetadataService dubboMetadataService = dubboMetadataConfigServiceProxy.newProxy(serviceName);
Set<ServiceRestMetadata> metadata = Collections.emptySet(); Set<ServiceRestMetadata> metadata = Collections.emptySet();
try { try {
String serviceRestMetadataJsonConfig = dubboMetadataConfigService.getServiceRestMetadata(); String serviceRestMetadataJsonConfig = dubboMetadataService.getServiceRestMetadata();
metadata = objectMapper.readValue(serviceRestMetadataJsonConfig, metadata = objectMapper.readValue(serviceRestMetadataJsonConfig,
TypeFactory.defaultInstance().constructCollectionType(LinkedHashSet.class, ServiceRestMetadata.class)); TypeFactory.defaultInstance().constructCollectionType(LinkedHashSet.class, ServiceRestMetadata.class));
} catch (Exception e) { } catch (Exception e) {

View File

@ -21,11 +21,11 @@ import org.springframework.cloud.alibaba.dubbo.metadata.ServiceRestMetadata;
import java.util.Set; import java.util.Set;
/** /**
* Dubbo Metadata Configuration Service * Dubbo Metadata Service
* *
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */
public interface DubboMetadataConfigService { public interface DubboMetadataService {
/** /**
* Get The json content of {@link ServiceRestMetadata} {@link Set} * Get The json content of {@link ServiceRestMetadata} {@link Set}

View File

@ -30,12 +30,12 @@ import org.springframework.util.StringUtils;
import java.util.function.Supplier; import java.util.function.Supplier;
/** /**
* {@link DubboMetadataConfigService} exporter * {@link DubboMetadataService} exporter
* *
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/ */
@Component @Component
public class DubboMetadataConfigServiceExporter { public class DubboMetadataServiceExporter {
private final Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
@ -43,7 +43,7 @@ public class DubboMetadataConfigServiceExporter {
private ApplicationConfig applicationConfig; private ApplicationConfig applicationConfig;
@Autowired @Autowired
private PublishingDubboMetadataConfigService dubboMetadataConfigService; private PublishingDubboMetadataService dubboMetadataService;
@Autowired @Autowired
private Supplier<ProtocolConfig> protocolConfigSupplier; private Supplier<ProtocolConfig> protocolConfigSupplier;
@ -54,10 +54,10 @@ public class DubboMetadataConfigServiceExporter {
/** /**
* The ServiceConfig of DubboMetadataConfigService to be exported, can be nullable. * 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() { public void export() {
@ -65,21 +65,21 @@ public class DubboMetadataConfigServiceExporter {
return; return;
} }
if (StringUtils.isEmpty(dubboMetadataConfigService.getServiceRestMetadata())) { if (StringUtils.isEmpty(dubboMetadataService.getServiceRestMetadata())) {
// If there is no REST metadata, DubboMetadataConfigService will not be exported. // If there is no REST metadata, DubboMetadataConfigService will not be exported.
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {
logger.info("There is no REST metadata, the Dubbo service[{}] will not be exported.", logger.info("There is no REST metadata, the Dubbo service[{}] will not be exported.",
dubboMetadataConfigService.getClass().getName()); dubboMetadataService.getClass().getName());
} }
return; return;
} }
serviceConfig = new ServiceConfig<>(); serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(DubboMetadataConfigService.class); serviceConfig.setInterface(DubboMetadataService.class);
// Use current Spring application name as the Dubbo Service version // Use current Spring application name as the Dubbo Service version
serviceConfig.setVersion(currentApplicationName); serviceConfig.setVersion(currentApplicationName);
serviceConfig.setRef(dubboMetadataConfigService); serviceConfig.setRef(dubboMetadataService);
serviceConfig.setApplication(applicationConfig); serviceConfig.setApplication(applicationConfig);
serviceConfig.setProtocol(protocolConfigSupplier.get()); serviceConfig.setProtocol(protocolConfigSupplier.get());
@ -92,7 +92,7 @@ public class DubboMetadataConfigServiceExporter {
/** /**
* unexport {@link DubboMetadataConfigService} * unexport {@link DubboMetadataService}
*/ */
public void unexport() { public void unexport() {

View File

@ -22,14 +22,14 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
/** /**
* {@link DubboMetadataConfigService} {@link InvocationHandler} * {@link DubboMetadataService} {@link InvocationHandler}
* *
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> * @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"; private static final String METHOD_NAME = "getServiceRestMetadata";
@ -39,8 +39,8 @@ class DubboMetadataConfigServiceInvocationHandler implements InvocationHandler {
private final GenericService genericService; private final GenericService genericService;
public DubboMetadataConfigServiceInvocationHandler(String serviceName, DubboGenericServiceFactory dubboGenericServiceFactory) { public DubboMetadataServiceInvocationHandler(String serviceName, DubboGenericServiceFactory dubboGenericServiceFactory) {
this.genericService = dubboGenericServiceFactory.create(serviceName, DubboMetadataConfigService.class); this.genericService = dubboGenericServiceFactory.create(serviceName, DubboMetadataService.class);
} }
@Override @Override

View File

@ -21,27 +21,27 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
import static java.lang.reflect.Proxy.newProxyInstance; 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 final DubboGenericServiceFactory dubboGenericServiceFactory;
private ClassLoader classLoader; private ClassLoader classLoader;
public DubboMetadataConfigServiceProxy(DubboGenericServiceFactory dubboGenericServiceFactory) { public DubboMetadataServiceProxy(DubboGenericServiceFactory dubboGenericServiceFactory) {
this.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 * @param serviceName the service name
* @return a {@link DubboMetadataConfigService} proxy * @return a {@link DubboMetadataService} proxy
*/ */
public DubboMetadataConfigService newProxy(String serviceName) { public DubboMetadataService newProxy(String serviceName) {
return (DubboMetadataConfigService) newProxyInstance(classLoader, new Class[]{DubboMetadataConfigService.class}, return (DubboMetadataService) newProxyInstance(classLoader, new Class[]{DubboMetadataService.class},
new DubboMetadataConfigServiceInvocationHandler(serviceName, dubboGenericServiceFactory)); new DubboMetadataServiceInvocationHandler(serviceName, dubboGenericServiceFactory));
} }
@Override @Override

View File

@ -27,11 +27,11 @@ import java.util.Set;
import static org.springframework.util.ObjectUtils.isEmpty; import static org.springframework.util.ObjectUtils.isEmpty;
/** /**
* Publishing {@link DubboMetadataConfigService} implementation * Publishing {@link DubboMetadataService} implementation
* *
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> * @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, * A Map to store REST metadata temporary, its' key is the special service name for a Dubbo service,