Modify factory method signature in JobExecution to make it not dependent on non-entity
This commit is contained in:
@@ -146,9 +146,10 @@ public class JobExecution extends Entity {
|
||||
|
||||
/**
|
||||
* Register a step execution with the current job execution.
|
||||
* @param stepName TODO
|
||||
*/
|
||||
public StepExecution createStepExecution(Step step) {
|
||||
StepExecution stepExecution = new StepExecution(step.getName(), this);
|
||||
public StepExecution createStepExecution(String stepName) {
|
||||
StepExecution stepExecution = new StepExecution(stepName, this);
|
||||
this.stepExecutions.add(stepExecution);
|
||||
return stepExecution;
|
||||
}
|
||||
|
||||
@@ -46,20 +46,4 @@ public class UnexpectedJobExecutionException extends RuntimeException {
|
||||
super(msg, nested);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance with a nested exception. The message is empty.
|
||||
* @deprecated use one of the other constructors
|
||||
*/
|
||||
public UnexpectedJobExecutionException(Throwable nested) {
|
||||
super(nested);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance, the message is empty.
|
||||
* @deprecated use one of the other constructors
|
||||
*/
|
||||
public UnexpectedJobExecutionException() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SimpleJob extends AbstractJob {
|
||||
|
||||
startedCount++;
|
||||
updateStatus(execution, BatchStatus.STARTED);
|
||||
currentStepExecution = execution.createStepExecution(step);
|
||||
currentStepExecution = execution.createStepExecution(step.getName());
|
||||
|
||||
StepExecution lastStepExecution = getJobRepository().getLastStepExecution(jobInstance, step);
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Date;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
@@ -128,12 +127,12 @@ public class JobExecutionTests extends TestCase {
|
||||
|
||||
public void testAddAndRemoveStepExecution() throws Exception {
|
||||
assertEquals(0, execution.getStepExecutions().size());
|
||||
execution.createStepExecution(new StepSupport("stepName"));
|
||||
execution.createStepExecution("step");
|
||||
assertEquals(1, execution.getStepExecutions().size());
|
||||
}
|
||||
|
||||
public void testStop() throws Exception {
|
||||
StepExecution stepExecution = execution.createStepExecution(new StepSupport("stepName"));
|
||||
StepExecution stepExecution = execution.createStepExecution("step");
|
||||
assertFalse(stepExecution.isTerminateOnly());
|
||||
execution.stop();
|
||||
assertTrue(stepExecution.isTerminateOnly());
|
||||
|
||||
@@ -50,7 +50,6 @@ import org.springframework.batch.core.repository.JobExecutionAlreadyRunningExcep
|
||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
/**
|
||||
@@ -234,8 +233,8 @@ public class SimpleJobOperatorTests {
|
||||
jobParameters = new JobParameters();
|
||||
jobExplorer.getJobExecution(111L);
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L);
|
||||
jobExecution.createStepExecution(new StepSupport("step1"));
|
||||
jobExecution.createStepExecution(new StepSupport("step2"));
|
||||
jobExecution.createStepExecution("step1");
|
||||
jobExecution.createStepExecution("step2");
|
||||
jobExecution.getStepExecutions().iterator().next().setId(21L);
|
||||
EasyMock.expectLastCall().andReturn(jobExecution);
|
||||
EasyMock.replay(jobExplorer);
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -146,7 +145,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
|
||||
dao.saveJobExecution(exec);
|
||||
exec = new JobExecution(jobInstance);
|
||||
exec.setLastUpdated(new Date(5L));
|
||||
exec.createStepExecution(new StepSupport("foo"));
|
||||
exec.createStepExecution("step");
|
||||
dao.saveJobExecution(exec);
|
||||
StepExecutionDao stepExecutionDao = getStepExecutionDao();
|
||||
if (stepExecutionDao != null) {
|
||||
@@ -180,7 +179,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
|
||||
public void testGetExecution() {
|
||||
JobExecution exec = new JobExecution(jobInstance);
|
||||
exec.setCreateTime(new Date(0));
|
||||
exec.createStepExecution(new StepSupport("foo"));
|
||||
exec.createStepExecution("step");
|
||||
|
||||
dao.saveJobExecution(exec);
|
||||
StepExecutionDao stepExecutionDao = getStepExecutionDao();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class StepExecutionResourceProxyTests extends TestCase {
|
||||
jobInstance = new JobInstance(new Long(0), new JobParameters(), "testJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance);
|
||||
Step step = new StepSupport("bar");
|
||||
stepExecution = jobExecution.createStepExecution(step);
|
||||
stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
resource.beforeStep(stepExecution);
|
||||
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class StepExecutionResourceProxyTests extends TestCase {
|
||||
.toJobParameters(), "testJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance);
|
||||
Step step = new StepSupport("bar");
|
||||
resource.beforeStep(jobExecution.createStepExecution(step));
|
||||
resource.beforeStep(jobExecution.createStepExecution(step.getName()));
|
||||
doTestPathName("spam-foo", "foo" + pathsep + "data" + pathsep);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase {
|
||||
jobInstance = new JobInstance(new Long(0), jobParameters, "testJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance);
|
||||
Step step = new StepSupport("bar");
|
||||
stepExecution = jobExecution.createStepExecution(step);
|
||||
stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
policy.beforeStep(stepExecution);
|
||||
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ public class SkipLimitStepFactoryBeanTests {
|
||||
|
||||
Step step = (Step) factory.getObject();
|
||||
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step);
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
|
||||
step.execute(stepExecution);
|
||||
assertEquals(4, stepExecution.getSkipCount());
|
||||
@@ -344,7 +344,7 @@ public class SkipLimitStepFactoryBeanTests {
|
||||
|
||||
Step step = (Step) factory.getObject();
|
||||
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step);
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
|
||||
step.execute(stepExecution);
|
||||
assertEquals(4, stepExecution.getSkipCount());
|
||||
|
||||
@@ -69,7 +69,7 @@ public class StepExecutionMessageHandler {
|
||||
JobExecution jobExecution = request.getJobExecution();
|
||||
JobInstance jobInstance = jobExecution.getJobInstance();
|
||||
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step);
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
try {
|
||||
|
||||
StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobInstance, step);
|
||||
|
||||
@@ -324,7 +324,7 @@ public class ChunkMessageItemWriterIntegrationTests {
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job,
|
||||
new JobParametersBuilder().addLong("job.counter", jobCounter++)
|
||||
.toJobParameters());
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step);
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
return stepExecution;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public class MessageOrientedStepTests {
|
||||
try {
|
||||
step.setExecutionTimeout(1000);
|
||||
step.setPollingInterval(100);
|
||||
step.execute(jobExecution.createStepExecution(step));
|
||||
step.execute(jobExecution.createStepExecution(step.getName()));
|
||||
fail("Expected StepExecutionTimeoutException");
|
||||
}
|
||||
catch (StepExecutionTimeoutException e) {
|
||||
@@ -123,7 +123,7 @@ public class MessageOrientedStepTests {
|
||||
return replyChannel.send(message);
|
||||
}
|
||||
});
|
||||
step.execute(jobExecution.createStepExecution(step));
|
||||
step.execute(jobExecution.createStepExecution(step.getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +136,7 @@ public class MessageOrientedStepTests {
|
||||
}
|
||||
});
|
||||
try {
|
||||
step.execute(jobExecution.createStepExecution(step));
|
||||
step.execute(jobExecution.createStepExecution(step.getName()));
|
||||
fail("Expected RuntimeException");
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
@@ -153,7 +153,7 @@ public class MessageOrientedStepTests {
|
||||
// Send a message to the reply channel to simulate step that we were
|
||||
// waiting for when we failed on the last execution.
|
||||
replyChannel.send(new GenericMessage<JobExecutionRequest>(jobExecutionRequest));
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step);
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
stepExecution.getExecutionContext().putString(MessageOrientedStep.WAITING, "true");
|
||||
step.execute(stepExecution);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user