private void parseMapperElement(Element element, ParserContext parserContext, MutablePropertyValues properties) { Element mapperElement = DomUtils.getChildElementByTagName(element, MAPPER_ELEMENT); if(mapperElement != null) { String mapperName = mapperElement.getAttribute(REF); properties.add(PARTITION_MAPPER_PROPERTY, new RuntimeBeanReference(mapperName)); new PropertyParser(mapperName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(mapperElement); } }
private void setProperties(Properties properties) { Object propertyValue; BeanDefinition beanDefinition = parserContext.getRegistry().getBeanDefinition(BATCH_PROPERTY_CONTEXT_BEAN_NAME); if(batchArtifactType.equals(BatchArtifactType.JOB)) { propertyValue = getJobProperties(properties); } else if (batchArtifactType.equals(BatchArtifactType.STEP)) { propertyValue = getProperties(stepName, properties); } else if (batchArtifactType.equals(BatchArtifactType.ARTIFACT)) { propertyValue = getProperties(beanName, properties); } else if (batchArtifactType.equals(BatchArtifactType.STEP_ARTIFACT)) { propertyValue = getStepArtifactProperties(beanDefinition, properties); } else { throw new IllegalStateException("Unhandled BatchArtifactType of: " + batchArtifactType); } beanDefinition.getPropertyValues().addPropertyValue(getPropertyName(batchArtifactType), propertyValue); }
protected void parsePartitionPlan(Element element, ParserContext parserContext, String stepName, MutablePropertyValues properties) { Element planElement = DomUtils.getChildElementByTagName(element, PLAN_ELEMENT); if(planElement != null) { String partitions = planElement.getAttribute(PARTITIONS_ATTRIBUTE); String threads = planElement.getAttribute(THREADS_ATTRIBUTE); if(!StringUtils.hasText(threads)) { threads = partitions; } List<Element> partitionProperties = DomUtils.getChildElementsByTagName(planElement, PROPERTIES_ELEMENT); if(partitionProperties != null) { for (Element partition : partitionProperties) { String partitionStepName = stepName + ":partition" + partition.getAttribute("partition"); new PropertyParser(partitionStepName, parserContext, BatchArtifactType.STEP, partitionStepName).parseProperty(partition); } } properties.add(THREADS_PROPERTY, threads); properties.add(PARTITIONS_PROPERTY, partitions); } } }
private void parsePropertyElement(Element propertyElement) { Properties properties = new Properties(); for (Element element : DomUtils.getChildElementsByTagName(propertyElement, PROPERTY_ELEMENT)) { properties.put(element.getAttribute(PROPERTY_NAME_ATTRIBUTE), element.getAttribute(PROPERTY_VALUE_ATTRIBUTE)); } setProperties(properties); setJobPropertiesBean(properties); }
/** * <p> * Parses a <property> tag value from the provided {@link Element}. <property> elements have a name and * value attribute which represent the property entries key and value. * </p> * * @param element the element to parse looking for <property/> */ public void parseProperty(Element element) { parsePropertyElement(element); }
@SuppressWarnings("unchecked") private Map<String, Map<String, Properties>> getStepArtifactProperties(BeanDefinition beanDefinition, Properties properties) { ManagedMap<String, Map<String, Properties>> stepArtifacts = new ManagedMap<>(); stepArtifacts.setMergeEnabled(true); Map<String, Map<String, Properties>> existingArtifacts = (Map<String, Map<String, Properties>>) beanDefinition.getPropertyValues().get(getPropertyName(batchArtifactType)); ManagedMap<String, Properties> artifactProperties = new ManagedMap<>(); artifactProperties.setMergeEnabled(true); if(existingArtifacts != null && existingArtifacts.containsKey(stepName)) { Map<String, Properties> existingArtifactsMap = existingArtifacts.get(stepName); for(Map.Entry<String, Properties> existingArtifactEntry : existingArtifactsMap.entrySet()) { artifactProperties.put(existingArtifactEntry.getKey(), existingArtifactEntry.getValue()); } } artifactProperties.put(beanName, properties); stepArtifacts.put(stepName, artifactProperties); return stepArtifacts; }
private void parsePropertyElement(Element propertyElement) { Properties properties = new Properties(); for (Element element : DomUtils.getChildElementsByTagName(propertyElement, PROPERTY_ELEMENT)) { properties.put(element.getAttribute(PROPERTY_NAME_ATTRIBUTE), element.getAttribute(PROPERTY_VALUE_ATTRIBUTE)); } setProperties(properties); setJobPropertiesBean(properties); }
/** * <p> * Parses <property> tag values from the provided {@link Element} if it contains a <properties /> element. * Only one <properties /> element may be present. <property> elements have a name and value attribute * which represent the property entries key and value. * </p> * * @param element the element to parse looking for <properties /> */ public void parseProperties(Element element) { List<Element> propertiesElements = DomUtils.getChildElementsByTagName(element, PROPERTIES_ELEMENT); if (propertiesElements.size() == 1) { parsePropertyElement(propertiesElements.get(0)); } else if (propertiesElements.size() > 1) { parserContext.getReaderContext().error("The <properties> element may not appear more than once.", element); } }
@SuppressWarnings("unchecked") private Map<String, Map<String, Properties>> getStepArtifactProperties(BeanDefinition beanDefinition, Properties properties) { ManagedMap<String, Map<String, Properties>> stepArtifacts = new ManagedMap<String, Map<String, Properties>>(); stepArtifacts.setMergeEnabled(true); Map<String, Map<String, Properties>> existingArtifacts = (Map<String, Map<String, Properties>>) beanDefinition.getPropertyValues().get(getPropertyName(batchArtifactType)); ManagedMap<String, Properties> artifactProperties = new ManagedMap<String, Properties>(); artifactProperties.setMergeEnabled(true); if(existingArtifacts != null && existingArtifacts.containsKey(stepName)) { Map<String, Properties> existingArtifactsMap = existingArtifacts.get(stepName); for(Map.Entry<String, Properties> existingArtifactEntry : existingArtifactsMap.entrySet()) { artifactProperties.put(existingArtifactEntry.getKey(), existingArtifactEntry.getValue()); } } artifactProperties.put(beanName, properties); stepArtifacts.put(stepName, artifactProperties); return stepArtifacts; }
private void parseReducerElement(Element element, ParserContext parserContext, MutablePropertyValues factoryBeanProperties) { Element reducerElement = DomUtils.getChildElementByTagName(element, REDUCER_ELEMENT); if(reducerElement != null) { String reducerName = reducerElement.getAttribute(REF); factoryBeanProperties.add(PARTITION_REDUCER_PROPERTY, new RuntimeBeanReference(reducerName)); new PropertyParser(reducerName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(reducerElement); } }
private void setProperties(Properties properties) { Object propertyValue; BeanDefinition beanDefinition = parserContext.getRegistry().getBeanDefinition(BATCH_PROPERTY_CONTEXT_BEAN_NAME); if(batchArtifactType.equals(BatchArtifactType.JOB)) { propertyValue = getJobProperties(properties); } else if (batchArtifactType.equals(BatchArtifactType.STEP)) { propertyValue = getProperties(stepName, properties); } else if (batchArtifactType.equals(BatchArtifactType.ARTIFACT)) { propertyValue = getProperties(beanName, properties); } else if (batchArtifactType.equals(BatchArtifactType.STEP_ARTIFACT)) { propertyValue = getStepArtifactProperties(beanDefinition, properties); } else { throw new IllegalStateException("Unhandled BatchArtifactType of: " + batchArtifactType); } beanDefinition.getPropertyValues().addPropertyValue(getPropertyName(batchArtifactType), propertyValue); }
private void parsePropertyElement(Element propertyElement) { Properties properties = new Properties(); for (Element element : DomUtils.getChildElementsByTagName(propertyElement, PROPERTY_ELEMENT)) { properties.put(element.getAttribute(PROPERTY_NAME_ATTRIBUTE), element.getAttribute(PROPERTY_VALUE_ATTRIBUTE)); } setProperties(properties); setJobPropertiesBean(properties); }
protected void parsePartitionPlan(Element element, ParserContext parserContext, String stepName, MutablePropertyValues properties) { Element planElement = DomUtils.getChildElementByTagName(element, PLAN_ELEMENT); if(planElement != null) { String partitions = planElement.getAttribute(PARTITIONS_ATTRIBUTE); String threads = planElement.getAttribute(THREADS_ATTRIBUTE); if(!StringUtils.hasText(threads)) { threads = partitions; } List<Element> partitionProperties = DomUtils.getChildElementsByTagName(planElement, PROPERTIES_ELEMENT); if(partitionProperties != null) { for (Element partition : partitionProperties) { String partitionStepName = stepName + ":partition" + partition.getAttribute("partition"); new PropertyParser(partitionStepName, parserContext, BatchArtifactType.STEP, partitionStepName).parseProperty(partition); } } properties.add(THREADS_PROPERTY, threads); properties.add(PARTITIONS_PROPERTY, partitions); } } }
/** * <p> * Parses a <property> tag value from the provided {@link Element}. <property> elements have a name and * value attribute which represent the property entries key and value. * </p> * * @param element the element to parse looking for <property/> */ public void parseProperty(Element element) { parsePropertyElement(element); }
@SuppressWarnings("unchecked") private Map<String, Map<String, Properties>> getStepArtifactProperties(BeanDefinition beanDefinition, Properties properties) { ManagedMap<String, Map<String, Properties>> stepArtifacts = new ManagedMap<String, Map<String, Properties>>(); stepArtifacts.setMergeEnabled(true); Map<String, Map<String, Properties>> existingArtifacts = (Map<String, Map<String, Properties>>) beanDefinition.getPropertyValues().get(getPropertyName(batchArtifactType)); ManagedMap<String, Properties> artifactProperties = new ManagedMap<String, Properties>(); artifactProperties.setMergeEnabled(true); if(existingArtifacts != null && existingArtifacts.containsKey(stepName)) { Map<String, Properties> existingArtifactsMap = existingArtifacts.get(stepName); for(Map.Entry<String, Properties> existingArtifactEntry : existingArtifactsMap.entrySet()) { artifactProperties.put(existingArtifactEntry.getKey(), existingArtifactEntry.getValue()); } } artifactProperties.put(beanName, properties); stepArtifacts.put(stepName, artifactProperties); return stepArtifacts; }
private void parseAnalyzerElement(Element element, ParserContext parserContext, MutablePropertyValues properties) { Element analyzerElement = DomUtils.getChildElementByTagName(element, ANALYZER_ELEMENT); if(analyzerElement != null) { String analyzerName = analyzerElement.getAttribute(REF); properties.add(PARTITION_ANALYZER_PROPERTY, new RuntimeBeanReference(analyzerName)); new PropertyParser(analyzerName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(analyzerElement); } }
private void setProperties(Properties properties) { Object propertyValue; BeanDefinition beanDefinition = parserContext.getRegistry().getBeanDefinition(BATCH_PROPERTY_CONTEXT_BEAN_NAME); if(batchArtifactType.equals(BatchArtifactType.JOB)) { propertyValue = getJobProperties(properties); } else if (batchArtifactType.equals(BatchArtifactType.STEP)) { propertyValue = getProperties(stepName, properties); } else if (batchArtifactType.equals(BatchArtifactType.ARTIFACT)) { propertyValue = getProperties(beanName, properties); } else if (batchArtifactType.equals(BatchArtifactType.STEP_ARTIFACT)) { propertyValue = getStepArtifactProperties(beanDefinition, properties); } else { throw new IllegalStateException("Unhandled BatchArtifactType of: " + batchArtifactType); } beanDefinition.getPropertyValues().addPropertyValue(getPropertyName(batchArtifactType), propertyValue); }
private void parsePropertyElement(Element propertyElement) { Properties properties = new Properties(); for (Element element : DomUtils.getChildElementsByTagName(propertyElement, PROPERTY_ELEMENT)) { properties.put(element.getAttribute(PROPERTY_NAME_ATTRIBUTE), element.getAttribute(PROPERTY_VALUE_ATTRIBUTE)); } setProperties(properties); setJobPropertiesBean(properties); }
protected void parsePartitionPlan(Element element, ParserContext parserContext, String stepName, MutablePropertyValues properties) { Element planElement = DomUtils.getChildElementByTagName(element, PLAN_ELEMENT); if(planElement != null) { String partitions = planElement.getAttribute(PARTITIONS_ATTRIBUTE); String threads = planElement.getAttribute(THREADS_ATTRIBUTE); if(!StringUtils.hasText(threads)) { threads = partitions; } List<Element> partitionProperties = DomUtils.getChildElementsByTagName(planElement, PROPERTIES_ELEMENT); if(partitionProperties != null) { for (Element partition : partitionProperties) { String partitionStepName = stepName + ":partition" + partition.getAttribute("partition"); new PropertyParser(partitionStepName, parserContext, BatchArtifactType.STEP, partitionStepName).parseProperty(partition); } } properties.add(THREADS_PROPERTY, threads); properties.add(PARTITIONS_PROPERTY, partitions); } } }
/** * <p> * Parses a <property> tag value from the provided {@link Element}. <property> elements have a name and * value attribute which represent the property entries key and value. * </p> * * @param element the element to parse looking for <property/> */ public void parseProperty(Element element) { parsePropertyElement(element); }