20 lines
2.4 KiB
HTML
20 lines
2.4 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>Completion Policies</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="ch08.xhtml" title="Chapter 8. Repeat"/><link rel="next" href="ch08s03.xhtml" title="Exception Handling"/></head><body><header/><section class="section" title="Completion Policies" epub:type="subchapter" id="completionPolicies"><div class="titlepage"><div><div><h2 class="title" style="clear: both">Completion Policies</h2></div></div></div><p>Inside a <code class="classname">RepeatTemplate</code> the termination of
|
||
the loop in the <code class="methodname">iterate</code> method is determined by a
|
||
<code class="classname">CompletionPolicy</code> which is also a factory for the
|
||
<code class="classname">RepeatContext</code>. The
|
||
<code class="classname">RepeatTemplate</code> has the responsibility to use the
|
||
current policy to create a <code class="classname">RepeatContext</code> and pass
|
||
that in to the <code class="classname">RepeatCallback</code> at every stage in the
|
||
iteration. After a callback completes its
|
||
<code class="methodname">doInIteration</code>, the
|
||
<code class="classname">RepeatTemplate</code> has to make a call to the
|
||
<code class="classname">CompletionPolicy</code> to ask it to update its state
|
||
(which will be stored in the <code class="classname">RepeatContext</code>). Then
|
||
it asks the policy if the iteration is complete.</p><p>Spring Batch provides some simple general purpose implementations of
|
||
<code class="classname">CompletionPolicy</code>. The
|
||
<code class="classname">SimpleCompletionPolicy</code> just allows an execution up
|
||
to a fixed number of times (with <code class="code">RepeatStatus.FINISHED</code>
|
||
forcing early completion at any time).</p><p>Users might need to implement their own completion policies for more
|
||
complicated decisions. For example, a batch processing window that
|
||
prevents batch jobs from executing once the online systems are in use
|
||
would require a custom policy.</p></section><footer/></body></html> |