001/*
002 * Copyright 2006-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.springframework.batch.core;
017
018import org.springframework.lang.Nullable;
019
020/**
021 * Batch domain object representing a job. Job is an explicit abstraction
022 * representing the configuration of a job specified by a developer. It should
023 * be noted that restart policy is applied to the job as a whole and not to a
024 * step.
025 * 
026 * @author Dave Syer
027 * @author Mahmoud Ben Hassine
028 */
029public interface Job {
030
031        String getName();
032
033        /**
034         * Flag to indicate if this job can be restarted, at least in principle.
035         * 
036         * @return true if this job can be restarted after a failure
037         */
038        boolean isRestartable();
039
040        /**
041         * Run the {@link JobExecution} and update the meta information like status
042         * and statistics as necessary. This method should not throw any exceptions
043         * for failed execution. Clients should be careful to inspect the
044         * {@link JobExecution} status to determine success or failure.
045         * 
046         * @param execution a {@link JobExecution}
047         */
048        void execute(JobExecution execution);
049
050        /**
051         * If clients need to generate new parameters for the next execution in a
052         * sequence they can use this incrementer. The return value may be {@code null},
053         * in the case that this job does not have a natural sequence.
054         * 
055         * @return in incrementer to be used for creating new parameters
056         */
057        @Nullable
058        JobParametersIncrementer getJobParametersIncrementer();
059
060        /**
061         * A validator for the job parameters of a {@link JobExecution}. Clients of
062         * a Job may need to validate the parameters for a launch, before or during
063         * the execution.
064         * 
065         * @return a validator that can be used to check parameter values (never
066         * {@code null})
067         */
068        JobParametersValidator getJobParametersValidator();
069
070}