Batch JSL Inheritance and Composition

In batch applications, it is a common practice to factor out common parts of job definition. It can be achieved with:

  • inheritance: inherit common parts from parent job xml;
  • composition: reference common parts as external entities.

Batch job xml inheritance is not included in JSR 352 Batch Spec 1.0. JBeret implements JSL inheritance based on the draft JSL Inheritance v1. Refer to that document for inheritance rules and restrictions. Note that this is an experimental feature and may undergo significant changes in future releases.

JSL Inheritance Examples

Here are some examples illustrating how to use JSL inheritance with JBeret.

Inherit step and flow within the same job xml document

Parent elements (step, flow, etc) are marked with attribute abstract = "true" to exclude them from direct execution. Child elements contains parent attribute, which points to the parent element.


<job id="inheritance" xmlns="" version="1.0">
    <!-- abstract step and flow -->
    <step id="step0" abstract="true">
        <batchlet ref="batchlet0"/>

    <flow id="flow0" abstract="true">
        <step id="flow0.step1" parent="step0"/>

    <!-- concrete step and flow -->
    <step id="step1" parent="step0" next="flow1"/>

    <flow id="flow1" parent="flow0"/>

Inherit step from a different job xml document

Child elements (step, job, etc) contain a jsl-name attribute, which specifies the job xml name (without .xml extension) containing the parent element.


<job id="chunk-child" xmlns="" version="1.0">
    <step id="chunk-child-step" parent="chunk-parent-step" jsl-name="chunk-parent">


<job id="chunk-parent" >
    <step id="chunk-parent-step" abstract="true">
        <chunk checkpoint-policy="item" skip-limit="5" retry-limit="5">
            <reader ref="R1"></reader>
            <processor ref="P1"></processor>
            <writer ref="W1"></writer>

            <checkpoint-algorithm ref="parent">
                    <property name="parent" value="parent"></property>
                <include class="java.lang.Exception"></include>
                <exclude class=""></exclude>
                <include class="java.lang.Exception"></include>
                <exclude class=""></exclude>
                <include class="java.lang.Exception"></include>
                <exclude class=""></exclude>

Resolve Custom XML External Entities

Compared to inheritance, custom XML external entity offers a more direct, low-level means of JSL composition. For example,


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE job [
        <!ENTITY job-segment SYSTEM "job-segment.xml">

<job id="job-with-xml-entities" xmlns="" version="1.0">


    <step id="job-with-xml-entities.step1">
        <batchlet ref="batchlet1"/>


<?xml version="1.0" encoding="UTF-8"?>

    <property name="" value=""/>

    <listener ref="EL1"></listener>
    <listener ref="EL2"></listener>

The target file of the entity (job-segment.xml in the above example) should be accessible and loadable by JBeret batch runtime, and typically reside in the same location as the referencing job xml (job-with-xml-entities.xml in the above example).