| 1 | /* | 
| 2 | * Copyright 2006-2013 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 |  | 
| 17 | package org.springframework.batch.core; | 
| 18 |  | 
| 19 | import org.springframework.util.Assert; | 
| 20 |  | 
| 21 | /** | 
| 22 | * Batch domain object representing a uniquely identifiable job run. | 
| 23 | * JobInstance can be restarted multiple times in case of execution failure and | 
| 24 | * it's lifecycle ends with first successful execution. | 
| 25 | * | 
| 26 | * Trying to execute an existing JobIntance that has already completed | 
| 27 | * successfully will result in error. Error will be raised also for an attempt | 
| 28 | * to restart a failed JobInstance if the Job is not restartable. | 
| 29 | * | 
| 30 | * @see Job | 
| 31 | * @see JobParameters | 
| 32 | * @see JobExecution | 
| 33 | * | 
| 34 | * @author Lucas Ward | 
| 35 | * @author Dave Syer | 
| 36 | * @author Robert Kasanicky | 
| 37 | * @author Michael Minella | 
| 38 | * | 
| 39 | */ | 
| 40 | @SuppressWarnings("serial") | 
| 41 | public class JobInstance extends Entity { | 
| 42 |  | 
| 43 | private final String jobName; | 
| 44 |  | 
| 45 | public JobInstance(Long id, String jobName) { | 
| 46 | super(id); | 
| 47 | Assert.hasLength(jobName); | 
| 48 | this.jobName = jobName; | 
| 49 | } | 
| 50 |  | 
| 51 | /** | 
| 52 | * @return the job name. (Equivalent to getJob().getName()) | 
| 53 | */ | 
| 54 | public String getJobName() { | 
| 55 | return jobName; | 
| 56 | } | 
| 57 |  | 
| 58 | @Override | 
| 59 | public String toString() { | 
| 60 | return super.toString() + ", Job=[" + jobName + "]"; | 
| 61 | } | 
| 62 |  | 
| 63 | } |