IN PROGRESS - issue BATCH-127: Allow job configuration to control re-entrant behavior
http://opensource.atlassian.com/projects/spring/browse/BATCH-127 Refactor JobRepository.findOrCreateJob() to return JobExecution.
This commit is contained in:
@@ -234,4 +234,12 @@ public class JobExecution extends Entity {
|
||||
public String toString() {
|
||||
return super.toString()+", job=["+job+"]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this {@link JobExecution} indicates that it is running.
|
||||
* @return true if the end time is null
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
return endTime==null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.executor.JobExecutionException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobExecutionAlreadyRunningException extends JobExecutionException {
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
*/
|
||||
public JobExecutionAlreadyRunningException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @param cause
|
||||
*/
|
||||
public JobExecutionAlreadyRunningException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@ import org.springframework.batch.core.domain.StepInstance;
|
||||
public interface JobRepository {
|
||||
|
||||
/**
|
||||
* Find or create a job for a given {@link JobIdentifier} and configuration.
|
||||
* Find or create a job execution for a given {@link JobIdentifier} and configuration.
|
||||
* If the job that is uniquely identified by {@link JobIdentifier} already
|
||||
* exists, its persisted values (including ID) will be returned in a new
|
||||
* {@link JobInstance} object. If no previous run is found, a new job will
|
||||
@@ -59,11 +59,15 @@ public interface JobRepository {
|
||||
* identifies this particular run of the configuration across
|
||||
* possible restarts
|
||||
*
|
||||
* @return a valid job
|
||||
* @return a valid job execution for the identifier provided
|
||||
* @throws JobExecutionAlreadyRunningException
|
||||
* if there is a {@link JobExecution} alrady running for the
|
||||
* job instance that would otherwise be returned
|
||||
*
|
||||
*/
|
||||
public JobInstance findOrCreateJob(JobConfiguration jobConfiguration,
|
||||
JobIdentifier jobIdentifier);
|
||||
public JobExecution findOrCreateJob(JobConfiguration jobConfiguration,
|
||||
JobIdentifier jobIdentifier)
|
||||
throws JobExecutionAlreadyRunningException;
|
||||
|
||||
/**
|
||||
* Update a Job.
|
||||
|
||||
Reference in New Issue
Block a user