WebSphere Application Server & Liberty

JSR-352 (Java Batch) Post #21: JSL Substitution Syntax

By David Follis posted Wed November 21, 2018 07:45 AM


This post is part of a series delving into the details of the JSR-352 (Java Batch) specification. Each post examines a very specific part of the specification and looks at how it works and how you might use it in a real batch application.

To start at the beginning, follow the link to the first post.

The next post in the series is here.

So far in this blog we’ve stayed pretty high level and not gotten down into the details, focusing more on concepts and best practices (or at least I’ve tried to do that).  But in this post we’re going to dig into the specific syntax of doing string substitution in Job Specification Language XML documents (JSL).  Why?  Because it looks pretty scary when you see it the first time and it really isn’t that bad…mostly.


The first thing to know is that you can substitute into pretty much any string value in the JSL.  Suppose you have a property that you set like this:

<property name=”A” value=”ValueA” /> 

You can set either of those strings to instead include strings that are substituted into that string.  For example:


<property name=”A” value=”Value#{jobProperties[‘someLetter’]}” />


That icky mess says that whatever value the Job Property called ‘someLetter’ has should be substituted into the string.  So if someLetter is set to ‘X’ then the value of property A will be ‘ValueX’.  On to the syntax.


It isn’t too bad if you take it in pieces.  A substitution is contained inside the ‘#{‘ and ‘}’ delimiters.  The ‘#’ indicates we’re doing substitution and the open/close curly braces show the start and end.  Inside the braces you tell it where to get the substitution value from.  You have four choices.  You can get the value of a Job Parameter or a Job Property (see the previous two blog posts).  You can also get the value of a System Property (specified with a ‘-D’ when the JVM was started).  The final option involves partitions, which we’ll get to later on.


So take a look at our example above once more…. We see the ‘#{‘ that starts the substitution and the ‘} that ends it.  And inside it the syntax says that we want a Job Property value.  The name of the property to use is inside the square brackets and single quotes (someLetter). 


Next time we’ll have a look at how to set up a default value.  To close out here I’ll give you a few more samples.  See if you can figure out how they resolve (answers next time).  Assume a Job Parameter of “XX” is passed in with a value of “ZZ”. 


<job id=”job1” >


        <property name=”ABC” value=”#{jobParameters[‘XX’]}” />

        <property name=”DEF” value=”ABC#{jobProperties[‘ABC’]}” />



<step id=”step1”>


        <property name=”GHI” value=”XYZ#{jobProperties[‘ABC’]}XYZ#{jobProperties[‘DEF’]}XYZ”/>