28 lines
4.3 KiB
HTML
28 lines
4.3 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg"><head><title>Batch Properties</title><link rel="stylesheet" type="text/css" href="docbook-epub.css"/><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"/><link rel="prev" href="ch12s03.xhtml" title="Dependency Injection"/><link rel="next" href="ch12s05.xhtml" title="Processing Models"/></head><body><header/><section class="section" title="Batch Properties" epub:type="subchapter" id="jsrJobProperties"><div class="titlepage"><div><div><h2 class="title" style="clear: both">Batch Properties</h2></div></div></div><section class="section" title="Property Support" epub:type="division" id="jsrPropertySupport"><div class="titlepage"><div><div><h3 class="title">Property Support</h3></div></div></div><p>JSR-352 allows for properties to be defined at the Job, Step and batch artifact level by way of
|
|
configuration in the JSL. Batch properties are configured at each level in the following way:</p><pre class="programlisting"><properties>
|
|
<property name="propertyName1" value="propertyValue1"/>
|
|
<property name="propertyName2" value="propertyValue2"/>
|
|
</properties></pre><p>
|
|
Properties may be configured on any batch artifact.</p></section><section class="section" title="@BatchProperty annotation" epub:type="division" id="jsrBatchPropertyAnnotation"><div class="titlepage"><div><div><h3 class="title"><code class="classname">@BatchProperty</code> annotation</h3></div></div></div><p>Properties are referenced in batch artifacts by annotating class fields with the
|
|
<code class="classname">@BatchProperty</code> and <code class="classname">@Inject</code> annotations (both annotations
|
|
are required by the spec). As defined by JSR-352, fields for properties must be String typed. Any type
|
|
conversion is up to the implementing developer to perform.</p><p>An <code class="classname">javax.batch.api.chunk.ItemReader</code> artifact could be configured with a
|
|
properties block such as the one described above and accessed as such:</p><pre class="programlisting">public class MyItemReader extends AbstractItemReader {
|
|
@Inject
|
|
@BatchProperty
|
|
private String propertyName1;
|
|
|
|
...
|
|
}</pre><p>
|
|
The value of the field "propertyName1" will be "propertyValue1"</p></section><section class="section" title="Property Substitution" epub:type="division" id="jsrPropertySubstitution"><div class="titlepage"><div><div><h3 class="title">Property Substitution</h3></div></div></div><p>Property substitution is provided by way of operators and simple conditional expressions. The general
|
|
usage is #{operator['key']}.</p><p>Supported operators:</p><p>
|
|
</p><div class="itemizedlist" epub:type="list"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem" epub:type="list-item"><p>jobParameters - access job parameter values that the job was started/restarted with.
|
|
</p></li><li class="listitem" epub:type="list-item"><p>jobProperties - access properties configured at the job level of the JSL.</p></li><li class="listitem" epub:type="list-item"><p>systemProperties - access named system properties.</p></li><li class="listitem" epub:type="list-item"><p>partitionPlan - access named property from the partition plan of a partitioned step.
|
|
</p></li></ul></div><p>
|
|
</p><pre class="programlisting">#{jobParameters['unresolving.prop']}?:#{systemProperties['file.separator']}</pre><p>
|
|
The left hand side of the assignment is the expected value, the right hand side is the default value. In
|
|
this example, the result will resolve to a value of the system property file.separator as
|
|
#{jobParameters['unresolving.prop']} is assumed to not be resolvable. If neither expressions can be
|
|
resolved, an empty String will be returned. Multiple conditions can be used, which are separated by a
|
|
';'.
|
|
</p></section></section><footer/></body></html> |