This repository was archived by the owner on Jan 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathbatch-processing006.html
More file actions
212 lines (200 loc) · 6.61 KB
/
batch-processing006.html
File metadata and controls
212 lines (200 loc) · 6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Submitting Jobs to the Batch Runtime</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/style.css" rel="stylesheet">
<script src="https://use.fontawesome.com/96c4d89611.js"></script>
</head>
<body>
<table id="doc-title" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top">
<b>Java Platform, Enterprise Edition (Java EE) 8</b><br />
<b>The Java EE Tutorial</b>
<!-- <p class="beta">Beta Draft (Pre-General Availability)</p> -->
</td>
</tr>
</table>
<hr />
<table width="90%" id="top-nav" cellspacing="0" cellpadding="0">
<colgroup>
<col width="12%"/>
<col width="12%"/>
<col width="*"/>
</colgroup>
<tr>
<td align="left">
<a href="batch-processing005.html">
<span class="vector-font"><i class="fa fa-arrow-circle-left" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Previous</span>
</a>
</td>
<td align="left">
<a href="batch-processing007.html">
<span class=" vector-font"><i class="fa fa-arrow-circle-right vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Next</span>
</a>
</td>
<td align="right">
<a href="toc.html">
<span class=" vector-font"><i class="fa fa-list vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Contents</span>
</a>
</td>
</tr>
</table>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p><a id="BCGCAHCB"></a><a id="submitting-jobs-to-the-batch-runtime"></a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_submitting_jobs_to_the_batch_runtime">Submitting Jobs to the Batch Runtime</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The <code>JobOperator</code> interface in the <code>javax.batch.operations</code> package
enables you to submit jobs to the batch runtime and obtain information
about existing jobs. This interface provides the following
functionality.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Obtain the names of all known jobs.</p>
</li>
<li>
<p>Start, stop, restart, and abandon jobs.</p>
</li>
<li>
<p>Obtain job instances and job executions.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The <code>BatchRuntime</code> class in the <code>javax.batch.runtime</code> package provides
the <code>getJobOperator</code> factory method to obtain <code>JobOperator</code> objects.</p>
</div>
<div class="paragraph">
<p><a id="sthref282"></a><a id="starting-a-job"></a></p>
</div>
<div class="sect2">
<h3 id="_starting_a_job">Starting a Job</h3>
<div class="paragraph">
<p>The following example code demonstrates how to obtain a <code>JobOperator</code>
object and submit a batch job:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code class="language-oac_no_warn" data-lang="oac_no_warn">JobOperator jobOperator = BatchRuntime.getJobOperator();
Properties props = new Properties();
props.setProperty("parameter1", "value1");
...
long execID = jobOperator.start("simplejob", props);</code></pre>
</div>
</div>
<div class="paragraph">
<p>The first argument of the <code>JobOperator.start</code> method is the name of the
job as specified in its job definition file. The second parameter is a
<code>Properties</code> object that represents the parameters for this job
execution. You can use job parameters to pass to a job information that
is only known at runtime.</p>
</div>
<div class="paragraph">
<p><a id="BCGIBGFC"></a><a id="checking-the-status-of-a-job"></a></p>
</div>
</div>
<div class="sect2">
<h3 id="_checking_the_status_of_a_job">Checking the Status of a Job</h3>
<div class="paragraph">
<p>The <code>JobExecution</code> interface in the <code>javax.batch.runtime</code> package
provides methods to obtain information about submitted jobs. This
interface provides the following functionality.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Obtain the batch and exit status of a job execution.</p>
</li>
<li>
<p>Obtain the time the execution was started, updated, or ended.</p>
</li>
<li>
<p>Obtain the job name.</p>
</li>
<li>
<p>Obtain the execution ID.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The following example code demonstrates how to obtain the batch status
of a job using its execution ID:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code class="language-oac_no_warn" data-lang="oac_no_warn">JobExecution jobExec = jobOperator.getJobExecution(execID);
String status = jobExec.getBatchStatus().toString();</code></pre>
</div>
</div>
<div class="paragraph">
<p><a id="sthref283"></a><a id="invoking-the-batch-runtime-in-your-application"></a></p>
</div>
</div>
<div class="sect2">
<h3 id="_invoking_the_batch_runtime_in_your_application">Invoking the Batch Runtime in Your Application</h3>
<div class="paragraph">
<p>The component from which you invoke the batch runtime depends on the
architecture of your particular application. For example, you can invoke
the batch runtime from an enterprise bean, a servlet, a managed bean,
and so on.</p>
</div>
<div class="paragraph">
<p>See <a href="batch-processing008.html#BCGJHEHJ">The webserverlog Example
Application</a> and <a href="batch-processing009.html#BCGFCACD">The phonebilling
Example Application</a> for details on how to invoke the batch runtime from
a managed bean driven by a JavaServer Faces user interface.</p>
</div>
</div>
</div>
</div>
<hr />
<table width="90%" id="bottom-nav" cellspacing="0" cellpadding="0">
<colgroup>
<col width="12%"/>
<col width="12%"/>
<col width="*"/>
</colgroup>
<tr>
<td align="left">
<a href="batch-processing005.html">
<span class=" vector-font"><i class="fa fa-arrow-circle-left" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Previous</span>
</a>
</td>
<td align="left">
<a href="batch-processing007.html">
<span class="vector-font"><i class="fa fa-arrow-circle-right vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Next</span>
</a>
</td>
<td align="right">
<a href="toc.html">
<span class="vector-font"><i class="fa fa-list vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Contents</span>
</a>
</td>
</tr>
</table>
<span id="copyright">
<a href="img/cpyr.adoc">
<img src="img/oracle.gif" height="10px" alt="Oracle Logo" />
<span>Copyright © 2017, Oracle and/or its affiliates. All rights reserved.</span>
</a>
</span>
<!--<p align="center" class="beta">Beta Draft (Pre-General Availability)</p> -->
</body>
</html>