Java Code Examples for com.alibaba.dubbo.config.annotation.Service#registry()
The following examples show how to use
com.alibaba.dubbo.config.annotation.Service#registry() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DubboProviderAutoConfiguration.java From dubbo-spring-boot-starter with Apache License 2.0 | 5 votes |
private void initProviderBean(String beanName, Object bean) throws Exception { Service service = this.applicationContext.findAnnotationOnBean(beanName, Service.class); ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); if ((service.interfaceClass() == null || service.interfaceClass() == void.class) && (service.interfaceName() == null || "".equals(service.interfaceName()))) { Class<?>[] interfaces = bean.getClass().getInterfaces(); if (interfaces.length > 0) { serviceConfig.setInterface(interfaces[0]); } } Environment environment = this.applicationContext.getEnvironment(); String application = service.application(); serviceConfig.setApplication(this.parseApplication(application, this.properties, environment, beanName, "application", application)); String module = service.module(); serviceConfig.setModule( this.parseModule(module, this.properties, environment, beanName, "module", module)); String[] registries = service.registry(); serviceConfig.setRegistries( this.parseRegistries(registries, this.properties, environment, beanName, "registry")); String[] protocols = service.protocol(); serviceConfig.setProtocols( this.parseProtocols(protocols, this.properties, environment, beanName, "registry")); String monitor = service.monitor(); serviceConfig.setMonitor( this.parseMonitor(monitor, this.properties, environment, beanName, "monitor", monitor)); String provider = service.provider(); serviceConfig.setProvider( this.parseProvider(provider, this.properties, environment, beanName, "provider", provider)); serviceConfig.setApplicationContext(this.applicationContext); serviceConfig.afterPropertiesSet(); serviceConfig.setRef(bean); serviceConfig.export(); }
Example 2
Source File: ServiceAnnotationBeanPostProcessor.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class<?> interfaceClass, String annotatedServiceBeanName) { BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class); AbstractBeanDefinition beanDefinition = builder.getBeanDefinition(); MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); // @Service注解可以有这些属性值 String[] ignoreAttributeNames = of("provider", "monitor", "application", "module", "registry", "protocol", "interface"); propertyValues.addPropertyValues(new AnnotationPropertyValuesAdapter(service, environment, ignoreAttributeNames)); // References "ref" property to annotated-@Service Bean addPropertyReference(builder, "ref", annotatedServiceBeanName); // Set interface 设置interface对象的引用关系 builder.addPropertyValue("interface", interfaceClass.getName()); /** * Add {@link com.alibaba.dubbo.config.ProviderConfig} Bean reference */ // 设置provider对象的引用关系 String providerConfigBeanName = service.provider(); if (StringUtils.hasText(providerConfigBeanName)) { addPropertyReference(builder, "provider", providerConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.MonitorConfig} Bean reference */ // 设置monitor对象的引用关系 String monitorConfigBeanName = service.monitor(); if (StringUtils.hasText(monitorConfigBeanName)) { addPropertyReference(builder, "monitor", monitorConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ApplicationConfig} Bean reference */ // 设置application对象的引用关系 String applicationConfigBeanName = service.application(); if (StringUtils.hasText(applicationConfigBeanName)) { addPropertyReference(builder, "application", applicationConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ModuleConfig} Bean reference */ // 设置module对象的引用关系 String moduleConfigBeanName = service.module(); if (StringUtils.hasText(moduleConfigBeanName)) { addPropertyReference(builder, "module", moduleConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.RegistryConfig} Bean reference */ // 设置registries对象的引用关系 String[] registryConfigBeanNames = service.registry(); List<RuntimeBeanReference> registryRuntimeBeanReferences = toRuntimeBeanReferences(registryConfigBeanNames); if (!registryRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("registries", registryRuntimeBeanReferences); } /** * Add {@link com.alibaba.dubbo.config.ProtocolConfig} Bean reference */ // 设置protocols对象的引用关系 String[] protocolConfigBeanNames = service.protocol(); List<RuntimeBeanReference> protocolRuntimeBeanReferences = toRuntimeBeanReferences(protocolConfigBeanNames); if (!protocolRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("protocols", protocolRuntimeBeanReferences); } return builder.getBeanDefinition(); }
Example 3
Source File: FeignClientToDubboProviderBeanPostProcessor.java From spring-cloud-alibaba-dubbo with Apache License 2.0 | 4 votes |
private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class<?> interfaceClass, String annotatedServiceBeanName) { BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class); AbstractBeanDefinition beanDefinition = builder.getBeanDefinition(); MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); String[] ignoreAttributeNames = of("provider", "monitor", "application", "module", "registry", "protocol", "interface"); propertyValues.addPropertyValues(new AnnotationPropertyValuesAdapter(service, environment, ignoreAttributeNames)); // References "ref" property to annotated-@Service Bean addPropertyReference(builder, "ref", annotatedServiceBeanName); // Set interface builder.addPropertyValue("interface", interfaceClass.getName()); /** * Add {@link com.alibaba.dubbo.config.ProviderConfig} Bean reference */ String providerConfigBeanName = service.provider(); if (StringUtils.hasText(providerConfigBeanName)) { addPropertyReference(builder, "provider", providerConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.MonitorConfig} Bean reference */ String monitorConfigBeanName = service.monitor(); if (StringUtils.hasText(monitorConfigBeanName)) { addPropertyReference(builder, "monitor", monitorConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ApplicationConfig} Bean reference */ String applicationConfigBeanName = service.application(); if (StringUtils.hasText(applicationConfigBeanName)) { addPropertyReference(builder, "application", applicationConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ModuleConfig} Bean reference */ String moduleConfigBeanName = service.module(); if (StringUtils.hasText(moduleConfigBeanName)) { addPropertyReference(builder, "module", moduleConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.RegistryConfig} Bean reference */ String[] registryConfigBeanNames = service.registry(); List<RuntimeBeanReference> registryRuntimeBeanReferences = toRuntimeBeanReferences(registryConfigBeanNames); if (!registryRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("registries", registryRuntimeBeanReferences); } /** * Add {@link com.alibaba.dubbo.config.ProtocolConfig} Bean reference */ String[] protocolConfigBeanNames = service.protocol(); List<RuntimeBeanReference> protocolRuntimeBeanReferences = toRuntimeBeanReferences(protocolConfigBeanNames); if (!protocolRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("protocols", protocolRuntimeBeanReferences); } return builder.getBeanDefinition(); }
Example 4
Source File: FeignClientToDubboProviderBeanPostProcessor.java From spring-cloud-dubbo with Apache License 2.0 | 4 votes |
private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class<?> interfaceClass, String annotatedServiceBeanName) { BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class); AbstractBeanDefinition beanDefinition = builder.getBeanDefinition(); MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); String[] ignoreAttributeNames = of("provider", "monitor", "application", "module", "registry", "protocol", "interface"); propertyValues.addPropertyValues(new AnnotationPropertyValuesAdapter(service, environment, ignoreAttributeNames)); // References "ref" property to annotated-@Service Bean addPropertyReference(builder, "ref", annotatedServiceBeanName); // Set interface builder.addPropertyValue("interface", interfaceClass.getName()); /** * Add {@link com.alibaba.dubbo.config.ProviderConfig} Bean reference */ String providerConfigBeanName = service.provider(); if (StringUtils.hasText(providerConfigBeanName)) { addPropertyReference(builder, "provider", providerConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.MonitorConfig} Bean reference */ String monitorConfigBeanName = service.monitor(); if (StringUtils.hasText(monitorConfigBeanName)) { addPropertyReference(builder, "monitor", monitorConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ApplicationConfig} Bean reference */ String applicationConfigBeanName = service.application(); if (StringUtils.hasText(applicationConfigBeanName)) { addPropertyReference(builder, "application", applicationConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ModuleConfig} Bean reference */ String moduleConfigBeanName = service.module(); if (StringUtils.hasText(moduleConfigBeanName)) { addPropertyReference(builder, "module", moduleConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.RegistryConfig} Bean reference */ String[] registryConfigBeanNames = service.registry(); List<RuntimeBeanReference> registryRuntimeBeanReferences = toRuntimeBeanReferences(registryConfigBeanNames); if (!registryRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("registries", registryRuntimeBeanReferences); } /** * Add {@link com.alibaba.dubbo.config.ProtocolConfig} Bean reference */ String[] protocolConfigBeanNames = service.protocol(); List<RuntimeBeanReference> protocolRuntimeBeanReferences = toRuntimeBeanReferences(protocolConfigBeanNames); if (!protocolRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("protocols", protocolRuntimeBeanReferences); } return builder.getBeanDefinition(); }
Example 5
Source File: AnnotationBean.java From spring-boot-starter-dubbo with Apache License 2.0 | 4 votes |
private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class<?> interfaceClass, String annotatedServiceBeanName) { BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class) .addConstructorArgValue(service) .addPropertyReference("ref", annotatedServiceBeanName) .addPropertyValue("interfaceClass", interfaceClass); /** * Add {@link com.alibaba.dubbo.config.ProviderConfig} Bean reference */ String providerConfigBeanName = service.provider(); if (StringUtils.hasText(providerConfigBeanName)) { builder.addPropertyReference("provider", providerConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.MonitorConfig} Bean reference */ String monitorConfigBeanName = service.monitor(); if (StringUtils.hasText(monitorConfigBeanName)) { builder.addPropertyReference("monitor", monitorConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ApplicationConfig} Bean reference */ String applicationConfigBeanName = service.application(); if (StringUtils.hasText(applicationConfigBeanName)) { builder.addPropertyReference("application", applicationConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.ModuleConfig} Bean reference */ String moduleConfigBeanName = service.module(); if (StringUtils.hasText(moduleConfigBeanName)) { builder.addPropertyReference("application", moduleConfigBeanName); } /** * Add {@link com.alibaba.dubbo.config.RegistryConfig} Bean reference */ String[] registryConfigBeanNames = service.registry(); List<RuntimeBeanReference> registryRuntimeBeanReferences = toRuntimeBeanReferences(registryConfigBeanNames); if (!registryRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("registries", registryRuntimeBeanReferences); } /** * Add {@link com.alibaba.dubbo.config.ProtocolConfig} Bean reference */ String[] protocolConfigBeanNames = service.protocol(); List<RuntimeBeanReference> protocolRuntimeBeanReferences = toRuntimeBeanReferences(protocolConfigBeanNames); if (!registryRuntimeBeanReferences.isEmpty()) { builder.addPropertyValue("protocols", protocolRuntimeBeanReferences); } return builder.getBeanDefinition(); }