You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/20 02:47:09 UTC

[GitHub] [shardingsphere-elasticjob] terrymanu commented on a change in pull request #1617: Fix spring namespace example for job-error-handler

terrymanu commented on a change in pull request #1617:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1617#discussion_r508175558



##########
File path: elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/parser/JobBeanDefinitionParser.java
##########
@@ -82,21 +82,26 @@ private BeanDefinition createJobConfigurationBeanDefinition(final Element elemen
         } else {
             result.addConstructorArgValue(Arrays.asList(element.getAttribute(JobBeanDefinitionTag.JOB_LISTENER_TYPES_ATTRIBUTE).split(",")));
         }
-        String tracingRef = element.getAttribute(JobBeanDefinitionTag.TRACING_REF_ATTRIBUTE);
-        if (Strings.isNullOrEmpty(tracingRef)) {
-            result.addConstructorArgValue(Collections.emptyList());
-        } else {
-            Collection<BeanDefinition> extraConfigs = new ManagedList<>(1);
-            extraConfigs.add(parserContext.getRegistry().getBeanDefinition(tracingRef));
-            result.addConstructorArgValue(extraConfigs);
-        }
+        result.addConstructorArgValue(parseExtraConfigs(new String[]{JobBeanDefinitionTag.TRACING_REF_ATTRIBUTE, JobBeanDefinitionTag.ERROR_HANDLER_CONFIG_REF_ATTRIBUTE},
+                element, parserContext));
         result.addConstructorArgValue(element.getAttribute(JobBeanDefinitionTag.DESCRIPTION_ATTRIBUTE));
         result.addConstructorArgValue(parsePropsElement(element, parserContext));
         result.addConstructorArgValue(element.getAttribute(JobBeanDefinitionTag.DISABLED_ATTRIBUTE));
         result.addConstructorArgValue(element.getAttribute(JobBeanDefinitionTag.OVERWRITE_ATTRIBUTE));
         return result.getBeanDefinition();
     }
     
+    private Collection<BeanDefinition> parseExtraConfigs(final String[] extraConfigRefs, final Element element, final ParserContext parserContext) {
+        Collection<BeanDefinition> extraConfigs = new ManagedList<>(extraConfigRefs.length);
+        for (String each : extraConfigRefs) {
+            String attribute = element.getAttribute(each);
+            if (!Strings.isNullOrEmpty(attribute)) {
+                extraConfigs.add(parserContext.getRegistry().getBeanDefinition(attribute));
+            }
+        }
+        return extraConfigs;

Review comment:
       Return value should be name as `result`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org