public Collection<BeanDefinition> parse(Element element, ParserContext parserContext) { String idAttribute = element.getAttribute("id"); BeanDefinitionBuilder stateBuilder = BeanDefinitionBuilder .genericBeanDefinition("org.springframework.batch.core.jsr.job.flow.support.state.JsrSplitState"); List<Element> flowElements = DomUtils.getChildElementsByTagName(element, "flow"); if (flowElements.size() < 2) { parserContext.getReaderContext().error("A <split/> must contain at least two 'flow' elements.", element); } Collection<Object> flows = new ManagedList<>(); int i = 0; for (Element nextElement : flowElements) { FlowParser flowParser = new FlowParser(idAttribute + "." + i, jobFactoryRef); flows.add(flowParser.parse(nextElement, parserContext)); i++; } stateBuilder.addConstructorArgValue(flows); stateBuilder.addConstructorArgValue(idAttribute); PropertyValue propertyValue = getSplitTaskExecutorPropertyValue(parserContext.getRegistry()); stateBuilder.addPropertyValue(propertyValue.getName(), propertyValue.getValue()); return FlowParser.getNextElements(parserContext, null, stateBuilder.getBeanDefinition(), element); }
@Test public void testUserSpecifiedTaskExecutor() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/org/springframework/batch/core/jsr/configuration/xml/user-specified-split-task-executor-context.xml"); BeanDefinitionRegistry registry = (BeanDefinitionRegistry) context.getBeanFactory(); PropertyValue propertyValue = new JsrSplitParser(null).getSplitTaskExecutorPropertyValue(registry); RuntimeBeanReference runtimeBeanReferenceValue = (RuntimeBeanReference) propertyValue.getValue(); Assert.assertTrue("RuntimeBeanReference should have a name of jsr352splitTaskExecutor" , "jsr352splitTaskExecutor".equals(runtimeBeanReferenceValue.getBeanName())); context.close(); }
@Test public void testDefaultTaskExecutor() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/org/springframework/batch/core/jsr/configuration/xml/default-split-task-executor-context.xml"); BeanDefinitionRegistry registry = (BeanDefinitionRegistry) context.getBeanFactory(); PropertyValue propertyValue = new JsrSplitParser(null).getSplitTaskExecutorPropertyValue(registry); Assert.assertTrue("Task executor not an instance of SimpleAsyncTaskExecutor" , (propertyValue.getValue() instanceof SimpleAsyncTaskExecutor)); context.close(); }
public Collection<BeanDefinition> parse(Element element, ParserContext parserContext) { String idAttribute = element.getAttribute("id"); BeanDefinitionBuilder stateBuilder = BeanDefinitionBuilder .genericBeanDefinition("org.springframework.batch.core.jsr.job.flow.support.state.JsrSplitState"); List<Element> flowElements = DomUtils.getChildElementsByTagName(element, "flow"); if (flowElements.size() < 2) { parserContext.getReaderContext().error("A <split/> must contain at least two 'flow' elements.", element); } Collection<Object> flows = new ManagedList<Object>(); int i = 0; for (Element nextElement : flowElements) { FlowParser flowParser = new FlowParser(idAttribute + "." + i, jobFactoryRef); flows.add(flowParser.parse(nextElement, parserContext)); i++; } stateBuilder.addConstructorArgValue(flows); stateBuilder.addConstructorArgValue(idAttribute); PropertyValue propertyValue = getSplitTaskExecutorPropertyValue(parserContext.getRegistry()); stateBuilder.addPropertyValue(propertyValue.getName(), propertyValue.getValue()); return FlowParser.getNextElements(parserContext, null, stateBuilder.getBeanDefinition(), element); }
public Collection<BeanDefinition> parse(Element element, ParserContext parserContext) { String idAttribute = element.getAttribute("id"); BeanDefinitionBuilder stateBuilder = BeanDefinitionBuilder .genericBeanDefinition("org.springframework.batch.core.jsr.job.flow.support.state.JsrSplitState"); List<Element> flowElements = DomUtils.getChildElementsByTagName(element, "flow"); if (flowElements.size() < 2) { parserContext.getReaderContext().error("A <split/> must contain at least two 'flow' elements.", element); } Collection<Object> flows = new ManagedList<Object>(); int i = 0; for (Element nextElement : flowElements) { FlowParser flowParser = new FlowParser(idAttribute + "." + i, jobFactoryRef); flows.add(flowParser.parse(nextElement, parserContext)); i++; } stateBuilder.addConstructorArgValue(flows); stateBuilder.addConstructorArgValue(idAttribute); PropertyValue propertyValue = getSplitTaskExecutorPropertyValue(parserContext.getRegistry()); stateBuilder.addPropertyValue(propertyValue.getName(), propertyValue.getValue()); return FlowParser.getNextElements(parserContext, null, stateBuilder.getBeanDefinition(), element); }
public Collection<BeanDefinition> parse(Element element, ParserContext parserContext) { String idAttribute = element.getAttribute("id"); BeanDefinitionBuilder stateBuilder = BeanDefinitionBuilder .genericBeanDefinition("org.springframework.batch.core.jsr.job.flow.support.state.JsrSplitState"); List<Element> flowElements = DomUtils.getChildElementsByTagName(element, "flow"); if (flowElements.size() < 2) { parserContext.getReaderContext().error("A <split/> must contain at least two 'flow' elements.", element); } Collection<Object> flows = new ManagedList<Object>(); int i = 0; for (Element nextElement : flowElements) { FlowParser flowParser = new FlowParser(idAttribute + "." + i, jobFactoryRef); flows.add(flowParser.parse(nextElement, parserContext)); i++; } stateBuilder.addConstructorArgValue(flows); stateBuilder.addConstructorArgValue(idAttribute); PropertyValue propertyValue = getSplitTaskExecutorPropertyValue(parserContext.getRegistry()); stateBuilder.addPropertyValue(propertyValue.getName(), propertyValue.getValue()); return FlowParser.getNextElements(parserContext, null, stateBuilder.getBeanDefinition(), element); }