BATCH-63: added <streams> element to <chunk>
This commit is contained in:
@@ -49,7 +49,7 @@ import org.w3c.dom.NamedNodeMap;
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Thomas Risberg
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class StepParser {
|
||||
|
||||
@@ -293,7 +293,6 @@ public class StepParser {
|
||||
Element listenersElement =
|
||||
DomUtils.getChildElementByTagName(element, "listeners");
|
||||
if (listenersElement != null) {
|
||||
List<String> listenerRefs = new ArrayList<String>();
|
||||
List<BeanReference> listenerBeans = new ArrayList<BeanReference>();
|
||||
List<Element> listenerElements =
|
||||
DomUtils.getChildElementsByTagName(listenersElement, "listener");
|
||||
@@ -316,7 +315,6 @@ public class StepParser {
|
||||
listenerElement.getTagName() + "> element with attributes: " + attributes);
|
||||
}
|
||||
if (StringUtils.hasText(listenerRef)) {
|
||||
listenerRefs.add(listenerRef);
|
||||
BeanReference bean = new RuntimeBeanReference(listenerRef);
|
||||
listenerBeans.add(bean);
|
||||
}
|
||||
@@ -340,6 +338,32 @@ public class StepParser {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void handleStreamsElement(Element element, RootBeanDefinition bd, ParserContext parserContext) {
|
||||
Element streamsElement =
|
||||
DomUtils.getChildElementByTagName(element, "streams");
|
||||
if (streamsElement != null) {
|
||||
List<BeanReference> listenerBeans = new ArrayList<BeanReference>();
|
||||
List<Element> listenerElements =
|
||||
DomUtils.getChildElementsByTagName(streamsElement, "listener");
|
||||
if (listenerElements != null) {
|
||||
for (Element listenerElement : listenerElements) {
|
||||
String listenerRef = listenerElement.getAttribute("ref");
|
||||
if (StringUtils.hasText(listenerRef)) {
|
||||
BeanReference bean = new RuntimeBeanReference(listenerRef);
|
||||
listenerBeans.add(bean);
|
||||
}
|
||||
else {
|
||||
throw new BeanCreationException("ref not specified for <" + listenerElement.getTagName() + "> element");
|
||||
}
|
||||
}
|
||||
}
|
||||
ManagedList arguments = new ManagedList();
|
||||
arguments.addAll(listenerBeans);
|
||||
bd.getPropertyValues().addPropertyValue("streams", arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
* @param parserContext
|
||||
|
||||
@@ -242,6 +242,23 @@
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="streams" minOccurs="0" maxOccurs="1">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
List of all streams to be included for the step definition
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="stream" minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="ref" type="xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="skippable-exception-classes" minOccurs="0" maxOccurs="1">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<listener class="org.springframework.batch.core.configuration.xml.TestListener"/>
|
||||
<listener ref="listener"/>
|
||||
</listeners>
|
||||
<streams>
|
||||
<stream ref="reader"/>
|
||||
</streams>
|
||||
</chunk>
|
||||
</step>
|
||||
</job>
|
||||
|
||||
Reference in New Issue
Block a user