IN PROGRESS - issue BATCH-121: BatchResourceFactoryBean - is it adding any value?

http://opensource.atlassian.com/projects/spring/browse/BATCH-121

Change StepContext to contain a StepExecution instead of a JobIdentifier
This commit is contained in:
dsyer
2007-10-05 15:50:44 +00:00
parent 0b52801e35
commit 3b7b95626b
5 changed files with 19 additions and 19 deletions

View File

@@ -23,7 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.repeat.context.SynchronizedAttributeAccessor;
/**
@@ -36,7 +36,7 @@ public class SimpleStepContext extends SynchronizedAttributeAccessor implements
private Map callbacks = new HashMap();
private StepContext parent;
private JobIdentifier jobIdentifier;
private StepExecution stepExecution;
/**
* Default constructor.
@@ -123,17 +123,17 @@ public class SimpleStepContext extends SynchronizedAttributeAccessor implements
/**
* @param jobIdentifier
* @param stepExecution
*/
public void setJobIdentifier(JobIdentifier jobIdentifier) {
this.jobIdentifier = jobIdentifier;
public void setStepExecution(StepExecution stepExecution) {
this.stepExecution = stepExecution;
}
/* (non-Javadoc)
* @see org.springframework.batch.execution.scope.StepContext#getJobIdentifier()
*/
public JobIdentifier getJobIdentifier() {
return jobIdentifier;
public StepExecution getStepExecution() {
return stepExecution;
}
}

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.batch.execution.scope;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.core.AttributeAccessor;
/**
@@ -27,12 +27,12 @@ import org.springframework.core.AttributeAccessor;
public interface StepContext extends AttributeAccessor {
/**
* Accessor for the {@link JobIdentifier} associated with the currently
* Accessor for the {@link StepExecution} associated with the currently
* executing step.
*
* @return the {@link JobIdentifier} associated with the current step
* @return the {@link StepExecution} associated with the current step
*/
JobIdentifier getJobIdentifier();
StepExecution getStepExecution();
/**
* Accessor for the parent context.

View File

@@ -182,7 +182,7 @@ public class SimpleStepExecutor implements StepExecutor {
stepExecution.getJobExecution().unregisterStepContext(context);
}
});
stepScopeContext.setJobIdentifier(stepExecution.getJobExecution().getJobIdentifier());
stepScopeContext.setStepExecution(stepExecution);
context.setAttribute(StepScope.ID_KEY, stepExecution.getJobExecution()
.getJobIdentifier());
// Mark the context as a step context as a hint to scope

View File

@@ -20,13 +20,13 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
import org.springframework.batch.core.domain.StepExecution;
/**
* @author Dave Syer
*
*/
public class StepScopeContextTests extends TestCase {
public class SimpleStepContextTests extends TestCase {
private SimpleStepContext context = new SimpleStepContext(new SimpleStepContext());
@@ -45,12 +45,12 @@ public class StepScopeContextTests extends TestCase {
}
/**
* Test method for {@link org.springframework.batch.execution.scope.SimpleStepContext#getJobIdentifier()}.
* Test method for {@link org.springframework.batch.execution.scope.SimpleStepContext#getStepExecution()}.
*/
public void testGetJobIdentifier() {
assertNull(context.getJobIdentifier());
context.setJobIdentifier(new SimpleJobIdentifier("bar"));
assertEquals("bar", context.getJobIdentifier().getName());
assertNull(context.getStepExecution());
context.setStepExecution(new StepExecution(null, null));
assertNotNull(context.getStepExecution());
}
private List list = new ArrayList();

View File

@@ -148,7 +148,7 @@ public class DefaultStepExecutorTests extends TestCase {
assertEquals(1, jobExecution.getChunkContexts().size());
assertEquals(1, jobExecution.getStepContexts().size());
assertNotNull(StepSynchronizationManager.getContext()
.getJobIdentifier());
.getStepExecution());
processed.add("foo");
return ExitStatus.CONTINUABLE;
}