use of org.apache.dubbo.config.MethodConfig in project dubbo by alibaba.
the class ServiceClassPostProcessor method buildServiceBeanDefinition.
/**
* Build the {@link AbstractBeanDefinition Bean Definition}
*
* @param serviceAnnotation
* @param serviceAnnotationAttributes
* @param interfaceClass
* @param annotatedServiceBeanName
* @return
* @since 2.7.3
*/
private AbstractBeanDefinition buildServiceBeanDefinition(Annotation serviceAnnotation, AnnotationAttributes serviceAnnotationAttributes, 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", "interfaceName", "parameters");
propertyValues.addPropertyValues(new AnnotationPropertyValuesAdapter(serviceAnnotation, environment, ignoreAttributeNames));
// References "ref" property to annotated-@Service Bean
addPropertyReference(builder, "ref", annotatedServiceBeanName);
// Set interface
builder.addPropertyValue("interface", interfaceClass.getName());
// Convert parameters into map
builder.addPropertyValue("parameters", DubboAnnotationUtils.convertParameters(serviceAnnotationAttributes.getStringArray("parameters")));
// Add methods parameters
List<MethodConfig> methodConfigs = convertMethodConfigs(serviceAnnotationAttributes.get("methods"));
if (!methodConfigs.isEmpty()) {
builder.addPropertyValue("methods", methodConfigs);
}
/**
* Add {@link org.apache.dubbo.config.ProviderConfig} Bean reference
*/
String providerConfigBeanName = serviceAnnotationAttributes.getString("provider");
if (StringUtils.hasText(providerConfigBeanName)) {
addPropertyReference(builder, "provider", providerConfigBeanName);
}
/**
* Add {@link org.apache.dubbo.config.MonitorConfig} Bean reference
*/
String monitorConfigBeanName = serviceAnnotationAttributes.getString("monitor");
if (StringUtils.hasText(monitorConfigBeanName)) {
addPropertyReference(builder, "monitor", monitorConfigBeanName);
}
/**
* Add {@link org.apache.dubbo.config.ApplicationConfig} Bean reference
*/
String applicationConfigBeanName = serviceAnnotationAttributes.getString("application");
if (StringUtils.hasText(applicationConfigBeanName)) {
addPropertyReference(builder, "application", applicationConfigBeanName);
}
/**
* Add {@link org.apache.dubbo.config.ModuleConfig} Bean reference
*/
String moduleConfigBeanName = serviceAnnotationAttributes.getString("module");
if (StringUtils.hasText(moduleConfigBeanName)) {
addPropertyReference(builder, "module", moduleConfigBeanName);
}
/**
* Add {@link org.apache.dubbo.config.RegistryConfig} Bean reference
*/
String[] registryConfigBeanNames = serviceAnnotationAttributes.getStringArray("registry");
List<RuntimeBeanReference> registryRuntimeBeanReferences = toRuntimeBeanReferences(registryConfigBeanNames);
if (!registryRuntimeBeanReferences.isEmpty()) {
builder.addPropertyValue("registries", registryRuntimeBeanReferences);
}
/**
* Add {@link org.apache.dubbo.config.ProtocolConfig} Bean reference
*/
String[] protocolConfigBeanNames = serviceAnnotationAttributes.getStringArray("protocol");
List<RuntimeBeanReference> protocolRuntimeBeanReferences = toRuntimeBeanReferences(protocolConfigBeanNames);
if (!protocolRuntimeBeanReferences.isEmpty()) {
builder.addPropertyValue("protocols", protocolRuntimeBeanReferences);
}
return builder.getBeanDefinition();
}
use of org.apache.dubbo.config.MethodConfig in project dubbo by alibaba.
the class InvokerSideConfigUrlTest method initRefConf.
// ======================================================
// private helper
// ======================================================
private void initRefConf() {
regConfForConsumer = new RegistryConfig();
regConfForReference = new RegistryConfig();
methodConfForReference = new MethodConfig();
refConf = new ReferenceConfig<DemoService>();
consumerConf = new ConsumerConfig();
methodConfForReference.setName("sayName");
regConfForReference.setAddress("127.0.0.1:9090");
regConfForReference.setProtocol("mockregistry");
refConf.setInterface("org.apache.dubbo.config.api.DemoService");
refConf.setApplication(application);
// consumerConf.setApplication(appConfForConsumer);
refConf.setRegistry(regConfForReference);
consumerConf.setRegistry(regConfForConsumer);
refConf.setConsumer(consumerConf);
refConf.setMethods(Arrays.asList(new MethodConfig[] { methodConfForReference }));
refConf.setScope(SCOPE_REMOTE);
}
use of org.apache.dubbo.config.MethodConfig in project dubbo by alibaba.
the class MethodBuilder method build.
public MethodConfig build() {
MethodConfig methodConfig = new MethodConfig();
super.build(methodConfig);
methodConfig.setArguments(arguments);
methodConfig.setDeprecated(deprecated);
methodConfig.setExecutes(executes);
methodConfig.setName(name);
methodConfig.setOninvoke(oninvoke);
methodConfig.setOninvokeMethod(oninvokeMethod);
methodConfig.setOnreturn(onreturn);
methodConfig.setOnreturnMethod(onreturnMethod);
methodConfig.setOnthrow(onthrow);
methodConfig.setOnthrowMethod(onthrowMethod);
methodConfig.setReturn(isReturn);
methodConfig.setService(service);
methodConfig.setServiceId(serviceId);
methodConfig.setSticky(sticky);
methodConfig.setReliable(reliable);
methodConfig.setStat(stat);
methodConfig.setRetry(retry);
return methodConfig;
}
Aggregations