BATCH-63: added <streams> element to <chunk>

This commit is contained in:
trisberg
2008-11-12 02:00:46 +00:00
parent 12c4fb0e59
commit 816c4b2532
3 changed files with 47 additions and 3 deletions

View File

@@ -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

View File

@@ -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[

View File

@@ -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>