View Javadoc

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.launch;
17  
18  import org.springframework.batch.core.Job;
19  import org.springframework.batch.core.JobExecution;
20  import org.springframework.batch.core.JobParameters;
21  import org.springframework.batch.core.JobParametersInvalidException;
22  import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
23  import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
24  import org.springframework.batch.core.repository.JobRestartException;
25  
26  /**
27   * Simple interface for controlling jobs, including possible ad-hoc executions,
28   * based on different runtime identifiers. It is extremely important to note
29   * that this interface makes absolutely no guarantees about whether or not calls
30   * to it are executed synchronously or asynchronously. The javadocs for specific
31   * implementations should be checked to ensure callers fully understand how the
32   * job will be run.
33   * 
34   * @author Lucas Ward
35   * @author Dave Syer
36   */
37  
38  public interface JobLauncher {
39  
40  	/**
41  	 * Start a job execution for the given {@link Job} and {@link JobParameters}
42  	 * . If a {@link JobExecution} was able to be created successfully, it will
43  	 * always be returned by this method, regardless of whether or not the
44  	 * execution was successful. If there is a past {@link JobExecution} which
45  	 * has paused, the same {@link JobExecution} is returned instead of a new
46  	 * one created. A exception will only be thrown if there is a failure to
47  	 * start the job. If the job encounters some error while processing, the
48  	 * JobExecution will be returned, and the status will need to be inspected.
49  	 * 
50  	 * @return the {@link JobExecution} if it returns synchronously. If the
51  	 * implementation is asynchronous, the status might well be unknown.
52  	 * 
53  	 * @throws JobExecutionAlreadyRunningException if the JobInstance identified
54  	 * by the properties already has an execution running.
55  	 * @throws IllegalArgumentException if the job or jobInstanceProperties are
56  	 * null.
57  	 * @throws JobRestartException if the job has been run before and
58  	 * circumstances that preclude a re-start.
59  	 * @throws JobInstanceAlreadyCompleteException if the job has been run
60  	 * before with the same parameters and completed successfully
61  	 * @throws JobParametersInvalidException if the parameters are not valid for
62  	 * this job
63  	 */
64  	public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
65  			JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException;
66  
67  }