BATCH-219 and BATCH-330: Created ExecutionAttributes, which are stored in the table BATCH_STEP_EXECUTION_ATTRIBUTES.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
|
||||
/**
|
||||
* Represents a contribution to a {@link StepExecution}, buffering changes
|
||||
@@ -30,7 +30,7 @@ public class StepContribution {
|
||||
|
||||
private StepExecution execution;
|
||||
|
||||
private StreamContext streamContext;
|
||||
private ExecutionAttributes streamContext;
|
||||
|
||||
private int commitCount;
|
||||
|
||||
@@ -69,15 +69,15 @@ public class StepContribution {
|
||||
*
|
||||
* @param streamContext
|
||||
*/
|
||||
public void setStreamContext(StreamContext streamContext) {
|
||||
public void setStreamContext(ExecutionAttributes streamContext) {
|
||||
this.streamContext = streamContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public getter for the {@link StreamContext}.
|
||||
* Public getter for the {@link ExecutionAttributes}.
|
||||
* @return the stream context
|
||||
*/
|
||||
public StreamContext getStreamContext() {
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return streamContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public class StepExecution extends Entity {
|
||||
|
||||
private Date endTime = null;
|
||||
|
||||
private StreamContext streamContext = new StreamContext();
|
||||
private ExecutionAttributes streamContext = new ExecutionAttributes();
|
||||
|
||||
private ExitStatus exitStatus = ExitStatus.UNKNOWN;
|
||||
|
||||
@@ -88,11 +88,11 @@ public class StepExecution extends Entity {
|
||||
taskCount++;
|
||||
}
|
||||
|
||||
public StreamContext getStreamContext() {
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return streamContext;
|
||||
}
|
||||
|
||||
public void setStreamContext(StreamContext statistics) {
|
||||
public void setStreamContext(ExecutionAttributes statistics) {
|
||||
this.streamContext = statistics;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -49,7 +49,7 @@ public class StepInstance extends Entity {
|
||||
|
||||
private BatchStatus status;
|
||||
|
||||
private StreamContext streamContext = new StreamContext();
|
||||
private ExecutionAttributes streamContext = new ExecutionAttributes();
|
||||
|
||||
private int stepExecutionCount = 0;
|
||||
|
||||
@@ -84,11 +84,11 @@ public class StepInstance extends Entity {
|
||||
this.stepExecutionCount = stepExecutionCount;
|
||||
}
|
||||
|
||||
public StreamContext getStreamContext() {
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return streamContext;
|
||||
}
|
||||
|
||||
public void setStreamContext(StreamContext streamContext) {
|
||||
public void setStreamContext(ExecutionAttributes streamContext) {
|
||||
this.streamContext = streamContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -30,7 +30,7 @@ import org.springframework.batch.item.StreamContext;
|
||||
* must first be obtained using the findOrCreateJob method. Once a Job and it's
|
||||
* related steps are obtained, they can be updated. It should be noted that any
|
||||
* reconstituted steps are expected to contain restart data <strong>if the step
|
||||
* says it wants to be restored after a restart, and {@link StreamContext}
|
||||
* says it wants to be restored after a restart, and {@link ExecutionAttributes}
|
||||
* exists.</strong>
|
||||
* </p>
|
||||
*
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.batch.core.domain;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -41,11 +41,11 @@ public class StepContributionTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepContribution#setStreamContext(StreamContext)}.
|
||||
* {@link org.springframework.batch.core.domain.StepContribution#setStreamContext(ExecutionAttributes)}.
|
||||
*/
|
||||
public void testSetStreamContext() {
|
||||
assertEquals(null, contribution.getStreamContext());
|
||||
StreamContext context = new StreamContext();
|
||||
ExecutionAttributes context = new ExecutionAttributes();
|
||||
context.putString("foo", "bar");
|
||||
contribution.setStreamContext(context);
|
||||
assertEquals(1, contribution.getStreamContext().getProperties().size());
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.Date;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ public class StepExecutionTests extends TestCase {
|
||||
|
||||
public void testStreamContext() throws Exception {
|
||||
assertNotNull(execution.getStreamContext());
|
||||
StreamContext context = new StreamContext();
|
||||
ExecutionAttributes context = new ExecutionAttributes();
|
||||
context.putString("foo", "bar");
|
||||
execution.setStreamContext(context );
|
||||
assertEquals("bar", execution.getStreamContext().getString("foo"));
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.batch.core.domain;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
@@ -50,7 +51,9 @@ public class StepInstanceTests extends TestCase {
|
||||
public void testGetStreamContext() {
|
||||
assertNotNull(instance.getStreamContext());
|
||||
assertTrue(instance.getStreamContext().getProperties().isEmpty());
|
||||
instance.setStreamContext(new StreamContext(PropertiesConverter.stringToProperties("foo=bar")));
|
||||
ExecutionAttributes executionAttributes = new ExecutionAttributes();
|
||||
executionAttributes.putString("foo", "bar");
|
||||
instance.setStreamContext(executionAttributes);
|
||||
assertEquals("bar", instance.getStreamContext().getProperties().getProperty("foo"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user