1 /*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.springframework.batch.core;
17
18 /**
19 * Batch domain object representing a job. Job is an explicit abstraction
20 * representing the configuration of a job specified by a developer. It should
21 * be noted that restart policy is applied to the job as a whole and not to a
22 * step.
23 *
24 * @author Dave Syer
25 *
26 */
27 public interface Job {
28
29 String getName();
30
31 /**
32 * Flag to indicate if this job can be restarted, at least in principle.
33 *
34 * @return true if this job can be restarted after a failure
35 */
36 boolean isRestartable();
37
38 /**
39 * Run the {@link JobExecution} and update the meta information like status
40 * and statistics as necessary. This method should not throw any exceptions
41 * for failed execution. Clients should be careful to inspect the
42 * {@link JobExecution} status to determine success or failure.
43 *
44 * @param execution a {@link JobExecution}
45 */
46 void execute(JobExecution execution);
47
48 /**
49 * If clients need to generate new parameters for the next execution in a
50 * sequence they can use this incrementer. The return value may be null, in
51 * the case that this job does not have a natural sequence.
52 *
53 * @return in incrementer to be used for creating new parameters
54 */
55 JobParametersIncrementer getJobParametersIncrementer();
56
57 /**
58 * A validator for the job parameters of a {@link JobExecution}. Clients of
59 * a Job may need to validate the parameters for a launch, before or during
60 * the execution.
61 *
62 * @return a validator that can be used to check parameter values (never
63 * null)
64 */
65 JobParametersValidator getJobParametersValidator();
66
67 }