RESOLVED - issue BATCH-330: Modify RestartData to be a typesafe form of map
http://jira.springframework.org/browse/BATCH-330 Remove references to RestartData
This commit is contained in:
@@ -20,12 +20,12 @@ import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
/**
|
||||
* RestartDataRowMapper extends the standard {@link RowMapper} interface to provide for
|
||||
* converting an object returned from a RowMapper to RestartData and back again. One
|
||||
* {@link ExecutionAttributesRowMapper} extends the standard {@link RowMapper} interface to provide for
|
||||
* converting an object returned from a RowMapper to {@link ExecutionAttributes} and back again. One
|
||||
* of the most common use cases for this type of functionality is the DrivingQuery approach
|
||||
* to sql processing. Using a RestartDataRowMapper, developers can create each unique key
|
||||
* to sql processing. Using a {@link ExecutionAttributesRowMapper}, developers can create each unique key
|
||||
* to suite their specific needs, and also describe how such a key would be converted to
|
||||
* RestartData, so that it can be serialized and stored.
|
||||
* {@link ExecutionAttributes}, so that it can be serialized and stored.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @see RowMapper
|
||||
@@ -34,7 +34,7 @@ import org.springframework.jdbc.core.RowMapper;
|
||||
public interface ExecutionAttributesRowMapper extends RowMapper {
|
||||
|
||||
/**
|
||||
* Given the provided composite key, return a RestartData representation.
|
||||
* Given the provided composite key, return a {@link ExecutionAttributes} representation.
|
||||
*
|
||||
* @param key
|
||||
* @return ExecutionAttributes representing the composite key.
|
||||
|
||||
@@ -177,14 +177,14 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade
|
||||
* @see ItemStream#getExecutionAttributes()
|
||||
*/
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
ExecutionAttributes restartData = new ExecutionAttributes();
|
||||
restartData.putLong(READ_COUNT_STATISTICS_NAME, currentRecordCount);
|
||||
return restartData;
|
||||
ExecutionAttributes executionAttributes = new ExecutionAttributes();
|
||||
executionAttributes.putLong(READ_COUNT_STATISTICS_NAME, currentRecordCount);
|
||||
return executionAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the input source for the given restart data by rereading and
|
||||
* skipping the number of records stored in the RestartData.
|
||||
* skipping the number of records stored in the {@link ExecutionAttributes}.
|
||||
*
|
||||
* @param ExecutionAttributes that holds the line count from the last commit.
|
||||
* @throws IllegalStateException if the ItemReader has already been
|
||||
|
||||
@@ -40,34 +40,4 @@ public class MultipleColumnJdbcDrivingQueryItemReaderIntegrationTests extends
|
||||
return fooItemReader;
|
||||
}
|
||||
|
||||
// private static class FooRestartDataConverter implements RestartDataRowMapper{
|
||||
//
|
||||
// private static final String ID_RESTART_KEY = "FooRestartDataConverter.id";
|
||||
// private static final String VALUE_RESTART_KEY = "FooRestartDataConverter.value";
|
||||
//
|
||||
// public RestartData createRestartData(Object compositeKey) {
|
||||
//
|
||||
// List values = (List)compositeKey;
|
||||
// Properties data = new Properties();
|
||||
// data.setProperty(ID_RESTART_KEY, values.get(0).toString());
|
||||
// data.setProperty(VALUE_RESTART_KEY, values.get(1).toString());
|
||||
// return new GenericRestartData(data);
|
||||
// }
|
||||
//
|
||||
// public Object[] createSetter(RestartData restartData) {
|
||||
// Object[] args = new Object[2];
|
||||
// args[0] = restartData.getProperties().get(ID_RESTART_KEY);
|
||||
// args[1] = restartData.getProperties().getProperty(VALUE_RESTART_KEY);
|
||||
// return args;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class FooCompositeKeyMapper implements RowMapper{
|
||||
// public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
// List key = new ArrayList();
|
||||
// key.add(new Long(rs.getLong(1)));
|
||||
// key.add(new Long(rs.getLong(2)));
|
||||
// return key;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
public class ColumnMapExecutionAttributesRowMapperTests extends TestCase {
|
||||
|
||||
private static final String KEY = ColumnMapExecutionAttributesRowMapper.KEY_PREFIX;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
key.put("2", new Integer(2));
|
||||
}
|
||||
|
||||
public void testCreateRestartDataWithInvalidType() throws Exception {
|
||||
public void testCreateExecutionAttributesWithInvalidType() throws Exception {
|
||||
|
||||
try{
|
||||
mapper.createExecutionAttributes(new Object());
|
||||
@@ -49,7 +49,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateRestartDataWithNull(){
|
||||
public void testCreateExecutionAttributesWithNull(){
|
||||
|
||||
try{
|
||||
mapper.createExecutionAttributes(null);
|
||||
@@ -59,14 +59,14 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateRestartData() throws Exception {
|
||||
public void testCreateExecutionAttributes() throws Exception {
|
||||
ExecutionAttributes streamContext = mapper.createExecutionAttributes(key);
|
||||
Properties props = streamContext.getProperties();
|
||||
assertEquals("1", props.getProperty(KEY + "0"));
|
||||
assertEquals("2", props.getProperty(KEY + "1"));
|
||||
}
|
||||
|
||||
public void testCreateRestartDataFromEmptyKeys() throws Exception {
|
||||
public void testCreateExecutionAttributesFromEmptyKeys() throws Exception {
|
||||
|
||||
ExecutionAttributes streamContext = mapper.createExecutionAttributes(new HashMap());
|
||||
assertEquals(0, streamContext.getProperties().size());
|
||||
@@ -60,7 +60,7 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran
|
||||
assertEquals(new Integer(5), key.get("VALUE"));
|
||||
}
|
||||
|
||||
public void testGetKeyAsRestartData(){
|
||||
public void testGetKeyAsExecutionAttributes(){
|
||||
|
||||
Map key = CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(1);
|
||||
key.put("ID", new Long(3));
|
||||
|
||||
Reference in New Issue
Block a user