You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/08/10 12:28:17 UTC
[dubbo] branch master updated: Make code of process callback of
method cleaner in DubboBeanDefinitionParser (#4770)
This is an automated email from the ASF dual-hosted git repository.
lixiaojie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new b0064d7 Make code of process callback of method cleaner in DubboBeanDefinitionParser (#4770)
b0064d7 is described below
commit b0064d78a3b929eb3b25e0de9055412cb61f48ce
Author: Taosheng Wei <ts...@apache.org>
AuthorDate: Sat Aug 10 20:28:03 2019 +0800
Make code of process callback of method cleaner in DubboBeanDefinitionParser (#4770)
---
.../spring/schema/DubboBeanDefinitionParser.java | 26 ++++++++--------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java
index af42c9a..ee31d18 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java
@@ -62,6 +62,10 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
private static final Logger logger = LoggerFactory.getLogger(DubboBeanDefinitionParser.class);
private static final Pattern GROUP_AND_VERION = Pattern.compile("^[\\-.0-9_a-zA-Z]+(\\:[\\-.0-9_a-zA-Z]+)?$");
+ private static final String ONRETURN = "onreturn";
+ private static final String ONTHROW = "onthrow";
+ private static final String ONINVOKE = "oninvoke";
+ private static final String METHOD = "Method";
private final Class<?> beanClass;
private final boolean required;
@@ -190,24 +194,12 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
value = null;
}
reference = value;
- } else if ("onreturn".equals(property)) {
+ } else if(ONRETURN.equals(property) || ONTHROW.equals(property) || ONINVOKE.equals(property)) {
int index = value.lastIndexOf(".");
- String returnRef = value.substring(0, index);
- String returnMethod = value.substring(index + 1);
- reference = new RuntimeBeanReference(returnRef);
- beanDefinition.getPropertyValues().addPropertyValue("onreturnMethod", returnMethod);
- } else if ("onthrow".equals(property)) {
- int index = value.lastIndexOf(".");
- String throwRef = value.substring(0, index);
- String throwMethod = value.substring(index + 1);
- reference = new RuntimeBeanReference(throwRef);
- beanDefinition.getPropertyValues().addPropertyValue("onthrowMethod", throwMethod);
- } else if ("oninvoke".equals(property)) {
- int index = value.lastIndexOf(".");
- String invokeRef = value.substring(0, index);
- String invokeRefMethod = value.substring(index + 1);
- reference = new RuntimeBeanReference(invokeRef);
- beanDefinition.getPropertyValues().addPropertyValue("oninvokeMethod", invokeRefMethod);
+ String ref = value.substring(0, index);
+ String method = value.substring(index + 1);
+ reference = new RuntimeBeanReference(ref);
+ beanDefinition.getPropertyValues().addPropertyValue(property + METHOD, method);
} else {
if ("ref".equals(property) && parserContext.getRegistry().containsBeanDefinition(value)) {
BeanDefinition refBean = parserContext.getRegistry().getBeanDefinition(value);