IN PROGRESS - issue BATCH-7: Remove transaction synchronization and state management from input/output sources (formerly buffering)
http://jira.springframework.org/browse/BATCH-7 Remove references to RestartData
This commit is contained in:
@@ -98,10 +98,6 @@ public class MapStepDao implements StepDao {
|
||||
stepExecution.setId(new Long(currentId++));
|
||||
executions.add(stepExecution);
|
||||
}
|
||||
|
||||
public void saveRestartData(Long stepId, StreamContext streamContext) {
|
||||
restartsById.put(stepId, streamContext);
|
||||
}
|
||||
|
||||
public List findStepExecutions(StepInstance step) {
|
||||
Set executions = (Set) executionsById.get(step.getId());
|
||||
|
||||
@@ -185,9 +185,9 @@ public class SimpleStepExecutor {
|
||||
// the conversation in StepScope
|
||||
stepContext.setAttribute(StepScope.ID_KEY, stepExecution.getJobExecution().getId());
|
||||
|
||||
final boolean saveRestartData = step.isSaveStreamContext();
|
||||
final boolean saveStreamContext = step.isSaveStreamContext();
|
||||
|
||||
if (saveRestartData && isRestart) {
|
||||
if (saveStreamContext && isRestart) {
|
||||
stepContext.setInitialStreamContext(stepInstance.getStreamContext());
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ public class SimpleStepExecutor {
|
||||
// only if chunk was successful
|
||||
stepExecution.apply(contribution);
|
||||
|
||||
if (saveRestartData) {
|
||||
if (saveStreamContext) {
|
||||
stepInstance.setStreamContext(stepContext.getStreamContext());
|
||||
jobRepository.update(stepInstance);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.execution.repository.dao.StepDao;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
|
||||
public class MockStepDao implements StepDao {
|
||||
|
||||
@@ -46,10 +45,6 @@ public class MockStepDao implements StepDao {
|
||||
return newSteps;
|
||||
}
|
||||
|
||||
public StreamContext getRestartData(Long stepId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getStepExecutionCount(StepInstance step) {
|
||||
return 1;
|
||||
}
|
||||
@@ -57,9 +52,6 @@ public class MockStepDao implements StepDao {
|
||||
public void save(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
public void saveRestartData(Long stepId, StreamContext streamContext) {
|
||||
}
|
||||
|
||||
public void update(StepInstance step) {
|
||||
}
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
* Test to ensure that if a StepDao returns invalid
|
||||
* restart data, it is corrected.
|
||||
*/
|
||||
public void testCreateStepsFixesInvalidRestartData() throws Exception{
|
||||
public void testCreateStepsFixesInvalidStreamContext() throws Exception{
|
||||
|
||||
List jobs = new ArrayList();
|
||||
|
||||
@@ -432,7 +432,7 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
assertTrue(step.getStreamContext().getProperties().isEmpty());
|
||||
}
|
||||
|
||||
public void testFindStepsFixesInvalidRestartData() throws Exception{
|
||||
public void testFindStepsFixesInvalidStreamContext() throws Exception{
|
||||
List jobs = new ArrayList();
|
||||
jobDao.findJobInstances(jobConfiguration.getName(), jobParameters);
|
||||
jobs.add(databaseJob);
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
|
||||
assertEquals(step3, tempStep);
|
||||
}
|
||||
|
||||
public void testUpdateStepWithoutRestartData(){
|
||||
public void testUpdateStepWithoutStreamContext(){
|
||||
|
||||
step1.setStatus(BatchStatus.COMPLETED);
|
||||
stepDao.update(step1);
|
||||
@@ -147,7 +147,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
|
||||
assertEquals(tempStep, step1);
|
||||
}
|
||||
|
||||
public void testUpdateStepWithRestartData(){
|
||||
public void testUpdateStepWithStreamContext(){
|
||||
|
||||
step1.setStatus(BatchStatus.COMPLETED);
|
||||
Properties data = new Properties();
|
||||
|
||||
@@ -106,7 +106,7 @@ public class MapStepDaoTests extends TestCase {
|
||||
assertEquals(2, dao.getStepExecutionCount(step));
|
||||
}
|
||||
|
||||
public void testSaveRestartData() throws Exception {
|
||||
public void testSaveStreamContext() throws Exception {
|
||||
assertEquals(null, dao.getStreamContext(step.getId()));
|
||||
step.setStatus(BatchStatus.COMPLETED);
|
||||
Properties data = new Properties();
|
||||
|
||||
@@ -101,7 +101,7 @@ public class SimpleStepConfigurationTests extends TestCase {
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.execution.step.simple.AbstractStep#isSaveStreamContext()}.
|
||||
*/
|
||||
public void testIsSaveRestartData() {
|
||||
public void testIsSaveStreamContext() {
|
||||
assertEquals(false, configuration.isSaveStreamContext());
|
||||
configuration.setSaveStreamContext(true);
|
||||
assertEquals(true, configuration.isSaveStreamContext());
|
||||
|
||||
@@ -277,7 +277,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
|
||||
/*
|
||||
* make sure a job that has never been executed before, but does have
|
||||
* saveRestartData = true, doesn't have restoreFrom called on it.
|
||||
* saveStreamContext = true, doesn't have restoreFrom called on it.
|
||||
*/
|
||||
public void testNonRestartedJob() throws Exception {
|
||||
StepInstance step = new StepInstance(new Long(1));
|
||||
@@ -290,7 +290,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
stepExecutor.execute(stepExecution);
|
||||
|
||||
assertFalse(tasklet.isRestoreFromCalled());
|
||||
assertTrue(tasklet.isGetRestartDataCalled());
|
||||
assertTrue(tasklet.isGetStreamContextCalled());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -312,14 +312,14 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
|
||||
assertTrue(tasklet.isRestoreFromCalled());
|
||||
assertTrue(tasklet.isRestoreFromCalledWithSomeContext());
|
||||
assertTrue(tasklet.isGetRestartDataCalled());
|
||||
assertTrue(tasklet.isGetStreamContextCalled());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that a job that is being restarted, but has saveRestartData set to
|
||||
* false, doesn't have restore or getRestartData called on it.
|
||||
* Test that a job that is being restarted, but has saveStreamContext set to
|
||||
* false, doesn't have restore or getStreamContext called on it.
|
||||
*/
|
||||
public void testNoSaveRestartDataRestartableJob() {
|
||||
public void testNoSaveStreamContextRestartableJob() {
|
||||
StepInstance step = new StepInstance(new Long(1));
|
||||
step.setStepExecutionCount(1);
|
||||
MockRestartableTasklet tasklet = new MockRestartableTasklet();
|
||||
@@ -336,11 +336,11 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
}
|
||||
|
||||
assertFalse(tasklet.isRestoreFromCalled());
|
||||
assertFalse(tasklet.isGetRestartDataCalled());
|
||||
assertFalse(tasklet.isGetStreamContextCalled());
|
||||
}
|
||||
|
||||
/*
|
||||
* Even though the job is restarted, and saveRestartData is true, nothing
|
||||
* Even though the job is restarted, and saveStreamContext is true, nothing
|
||||
* will be restored because the Tasklet does not implement Restartable.
|
||||
*/
|
||||
public void testRestartJobOnNonRestartableTasklet() throws Exception {
|
||||
@@ -430,7 +430,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
|
||||
private class MockRestartableTasklet implements Tasklet, ItemStream {
|
||||
|
||||
private boolean getRestartDataCalled = false;
|
||||
private boolean getStreamContextCalled = false;
|
||||
|
||||
private boolean restoreFromCalled = false;
|
||||
|
||||
@@ -446,7 +446,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
}
|
||||
|
||||
public StreamContext getStreamContext() {
|
||||
getRestartDataCalled = true;
|
||||
getStreamContextCalled = true;
|
||||
return new GenericStreamContext(PropertiesConverter.stringToProperties("spam=bucket"));
|
||||
}
|
||||
|
||||
@@ -455,8 +455,8 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
restoreFromCalledWithSomeContext = data.getProperties().size() > 0;
|
||||
}
|
||||
|
||||
public boolean isGetRestartDataCalled() {
|
||||
return getRestartDataCalled;
|
||||
public boolean isGetStreamContextCalled() {
|
||||
return getStreamContextCalled;
|
||||
}
|
||||
|
||||
public boolean isRestoreFromCalled() {
|
||||
|
||||
@@ -184,7 +184,7 @@ public class HibernateCursorItemReader extends AbstractItemReader implements Ite
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current row number wrapped as <code>RestartData</code>
|
||||
* @return the current row number wrapped as <code>StreamContext</code>
|
||||
*/
|
||||
public StreamContext getStreamContext() {
|
||||
Properties props = new Properties();
|
||||
|
||||
@@ -394,7 +394,7 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.restart.Restartable#getRestartData()
|
||||
* @see org.springframework.batch.restart.Restartable#getStreamContext()
|
||||
*/
|
||||
public StreamContext getStreamContext() {
|
||||
String skipped = skippedRows.toString();
|
||||
@@ -405,10 +405,9 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen
|
||||
return context;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.restart.Restartable#restoreFrom(org.springframework.batch.restart.RestartData)
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.item.ItemStream#restoreFrom(org.springframework.batch.item.StreamContext)
|
||||
*/
|
||||
public void restoreFrom(StreamContext data) {
|
||||
Assert.state(!initialized);
|
||||
|
||||
@@ -161,7 +161,7 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource
|
||||
* been initialized before calling restore (meaning, read has been called)
|
||||
* then an IllegalStateException will be thrown, since all input sources
|
||||
* should be restored before being read from, otherwise already processed
|
||||
* data could be returned. The RestartData attempting to be restored from
|
||||
* data could be returned. The {@link StreamContext} attempting to be restored from
|
||||
* must have been obtained from the <strong>same input source as the one
|
||||
* being restored from</strong> otherwise it is invalid.
|
||||
*
|
||||
@@ -172,9 +172,9 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource
|
||||
*/
|
||||
public final void restoreFrom(StreamContext data) {
|
||||
|
||||
Assert.notNull(data, "RestartData must not be null.");
|
||||
Assert.notNull(data, "StreamContext must not be null.");
|
||||
Assert.notNull(data.getProperties(),
|
||||
"RestartData properties must not be null.");
|
||||
"StreamContext properties must not be null.");
|
||||
Assert.state(!initialized,
|
||||
"Cannot restore when already intialized. Call"
|
||||
+ " close() first before restore()");
|
||||
|
||||
@@ -20,9 +20,9 @@ public interface KeyGenerator {
|
||||
/**
|
||||
* Restore the keys list based on provided restart data.
|
||||
*
|
||||
* @param restartData, the restart data to restore the keys list from.
|
||||
* @param streamContext, the restart data to restore the keys list from.
|
||||
* @return a list of keys.
|
||||
* @throws IllegalArgumentException is restartData is null.
|
||||
* @throws IllegalArgumentException is streamContext is null.
|
||||
*/
|
||||
List restoreKeys(StreamContext streamContext);
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface KeyGenerator {
|
||||
* Return the provided key as restart data.
|
||||
*
|
||||
* @param key to be converted to restart data.
|
||||
* @return RestartData representation of the key.
|
||||
* @return StreamContext representation of the key.
|
||||
* @throws IllegalArgumentException if key is null.
|
||||
* @throws IllegalArgumentException if key is an incompatible type.
|
||||
*/
|
||||
|
||||
@@ -33,15 +33,15 @@ import org.springframework.util.ClassUtils;
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
* @see RestartDataRowMapper
|
||||
* @see StreamContextRowMapper
|
||||
*/
|
||||
public class ColumnMapStreamContextRowMapper extends ColumnMapRowMapper implements RestartDataRowMapper{
|
||||
public class ColumnMapStreamContextRowMapper extends ColumnMapRowMapper implements StreamContextRowMapper{
|
||||
|
||||
public static final String KEY_PREFIX = ClassUtils.getQualifiedName(ColumnMapStreamContextRowMapper.class) + ".KEY.";
|
||||
|
||||
public PreparedStatementSetter createSetter(StreamContext streamContext) {
|
||||
|
||||
ColumnMapRestartData columnData = new ColumnMapRestartData(streamContext.getProperties());
|
||||
ColumnMapStreamContext columnData = new ColumnMapStreamContext(streamContext.getProperties());
|
||||
|
||||
List columns = new ArrayList();
|
||||
for (Iterator iterator = columnData.keys.entrySet().iterator(); iterator.hasNext();) {
|
||||
@@ -56,19 +56,19 @@ public class ColumnMapStreamContextRowMapper extends ColumnMapRowMapper implemen
|
||||
public StreamContext createStreamContext(Object key) {
|
||||
Assert.isInstanceOf(Map.class, key, "Input to create StreamContext must be of type Map.");
|
||||
Map keys = (Map)key;
|
||||
return new ColumnMapRestartData(keys);
|
||||
return new ColumnMapStreamContext(keys);
|
||||
}
|
||||
|
||||
|
||||
private static class ColumnMapRestartData extends GenericStreamContext {
|
||||
private static class ColumnMapStreamContext extends GenericStreamContext {
|
||||
|
||||
private final Map keys;
|
||||
|
||||
public ColumnMapRestartData(Map keys) {
|
||||
public ColumnMapStreamContext(Map keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public ColumnMapRestartData(Properties props) {
|
||||
public ColumnMapStreamContext(Properties props) {
|
||||
|
||||
keys = CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(props.size());
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* <p>Jdbc implementation of the {@link KeyGenerator} interface that works for composite keys.
|
||||
* (i.e. keys represented by multiple columns) A sql query to be used to return the keys and
|
||||
* a {@link RestartDataRowMapper} to map each row in the resultset to an Object must be set in
|
||||
* a {@link StreamContextRowMapper} to map each row in the resultset to an Object must be set in
|
||||
* order to work correctly.
|
||||
* </p>
|
||||
*
|
||||
@@ -43,7 +43,7 @@ public class MultipleColumnJdbcKeyGenerator implements
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private RestartDataRowMapper keyMapper = new ColumnMapStreamContextRowMapper();
|
||||
private StreamContextRowMapper keyMapper = new ColumnMapStreamContextRowMapper();
|
||||
|
||||
private String sql;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class MultipleColumnJdbcKeyGenerator implements
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.sql.scratch.AbstractDrivingQueryItemReader#restoreKeys(org.springframework.batch.restart.RestartData)
|
||||
* @see org.springframework.batch.io.driving.KeyGenerator#restoreKeys(org.springframework.batch.item.StreamContext)
|
||||
*/
|
||||
public List restoreKeys(StreamContext streamContext) {
|
||||
|
||||
@@ -94,10 +94,10 @@ public class MultipleColumnJdbcKeyGenerator implements
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.restart.Restartable#getRestartData()
|
||||
* @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsStreamContext(java.lang.Object)
|
||||
*/
|
||||
public StreamContext getKeyAsStreamContext(Object key) {
|
||||
Assert.state(keyMapper != null, "RestartDataConverter must not be null.");
|
||||
Assert.state(keyMapper != null, "Kye mapper must not be null.");
|
||||
return keyMapper.createStreamContext(key);
|
||||
}
|
||||
|
||||
@@ -121,12 +121,12 @@ public class MultipleColumnJdbcKeyGenerator implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link RestartDataRowMapper} to be used to map a resultset
|
||||
* Set the {@link StreamContextRowMapper} to be used to map a resultset
|
||||
* to keys.
|
||||
*
|
||||
* @param keyMapper
|
||||
*/
|
||||
public void setKeyMapper(RestartDataRowMapper keyMapper) {
|
||||
public void setKeyMapper(StreamContextRowMapper keyMapper) {
|
||||
this.keyMapper = keyMapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,21 +30,26 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* <p>Jdbc {@link KeyGenerator} implementation that only works for a single column key. A sql
|
||||
* query must be passed in which will be used to return a list of keys. Each key will be mapped
|
||||
* by a {@link RowMapper} that returns a mapped key. By default, the {@link SingleColumnRowMapper}
|
||||
* is used, and will convert keys into well known types at runtime. It is extremely important to
|
||||
* note that only one column should be mapped to an object and returned as a key. If multiple
|
||||
* columns are returned as a key in this strategy, then restart will not function properly. Instead
|
||||
* a strategy that supports keys comprised of multiple columns should be used.
|
||||
*
|
||||
* <p>Restartability: Because the key is only one column, restart is made much more simple. Before
|
||||
* each commit, the last processed key is returned to be stored as restart data. Upon restart, that
|
||||
* same key is given back to restore from, using a separate 'RestartQuery'. This means that only the
|
||||
* keys remaining to be processed are returned, rather than returning the original list of keys and
|
||||
* iterating forward to that last committed point.
|
||||
* <p>
|
||||
* Jdbc {@link KeyGenerator} implementation that only works for a single column
|
||||
* key. A sql query must be passed in which will be used to return a list of
|
||||
* keys. Each key will be mapped by a {@link RowMapper} that returns a mapped
|
||||
* key. By default, the {@link SingleColumnRowMapper} is used, and will convert
|
||||
* keys into well known types at runtime. It is extremely important to note that
|
||||
* only one column should be mapped to an object and returned as a key. If
|
||||
* multiple columns are returned as a key in this strategy, then restart will
|
||||
* not function properly. Instead a strategy that supports keys comprised of
|
||||
* multiple columns should be used.
|
||||
*
|
||||
* <p>
|
||||
* Restartability: Because the key is only one column, restart is made much more
|
||||
* simple. Before each commit, the last processed key is returned to be stored
|
||||
* as restart data. Upon restart, that same key is given back to restore from,
|
||||
* using a separate 'RestartQuery'. This means that only the keys remaining to
|
||||
* be processed are returned, rather than returning the original list of keys
|
||||
* and iterating forward to that last committed point.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @since 1.0
|
||||
*/
|
||||
@@ -63,10 +68,10 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator {
|
||||
public SingleColumnJdbcKeyGenerator() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new instance using the provided jdbcTemplate and string representing
|
||||
* the sql statement that should be used to retrieve keys.
|
||||
* Constructs a new instance using the provided jdbcTemplate and string
|
||||
* representing the sql statement that should be used to retrieve keys.
|
||||
*
|
||||
* @param jdbcTemplate
|
||||
* @param sql
|
||||
@@ -81,7 +86,8 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator {
|
||||
this.sql = sql;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.driving.KeyGenerationStrategy#retrieveKeys()
|
||||
*/
|
||||
public List retrieveKeys() {
|
||||
@@ -90,27 +96,28 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator {
|
||||
|
||||
/**
|
||||
* Get the restart data representing the last processed key.
|
||||
*
|
||||
* @see KeyGenerator#getKeyAsRestartData()
|
||||
*
|
||||
* @see KeyGenerator#getKeyAsStreamContext(Object)
|
||||
* @throws IllegalArgumentException if key is null.
|
||||
*/
|
||||
public StreamContext getKeyAsStreamContext(Object key) {
|
||||
|
||||
|
||||
Assert.notNull(key, "The key must not be null.");
|
||||
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty(RESTART_KEY, key.toString());
|
||||
return new GenericStreamContext(props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the remaining to be processed for the provided {@link StreamContext}.
|
||||
* The RestartData attempting to be restored from must have been obtained from the
|
||||
* <strong>same KeyGenerationStrategy as the one
|
||||
* being restored from</strong> otherwise it is invalid.
|
||||
*
|
||||
* @param StreamContext obtained by calling getRestartData during a previous
|
||||
* run.
|
||||
* Return the remaining to be processed for the provided
|
||||
* {@link StreamContext}. The {@link StreamContext} attempting to be
|
||||
* restored from must have been obtained from the <strong>same
|
||||
* KeyGenerationStrategy as the one being restored from</strong> otherwise
|
||||
* it is invalid.
|
||||
*
|
||||
* @param StreamContext obtained by calling
|
||||
* {@link #getKeyAsStreamContext(Object)} during a previous run.
|
||||
* @throws IllegalStateException if restart sql statement is null.
|
||||
* @throws IllegalArgumentException if restart data is null.
|
||||
* @see KeyGenerator#restoreKeys(org.springframework.batch.item.StreamContext)
|
||||
@@ -118,8 +125,8 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator {
|
||||
public List restoreKeys(StreamContext streamContext) {
|
||||
|
||||
Assert.notNull(streamContext, "The restart data must not be null.");
|
||||
Assert.state(StringUtils.hasText(restartSql), "The RestartQuery must not be null or empty" +
|
||||
" in order to restart.");
|
||||
Assert.state(StringUtils.hasText(restartSql), "The RestartQuery must not be null or empty"
|
||||
+ " in order to restart.");
|
||||
|
||||
String lastProcessedKey = streamContext.getProperties().getProperty(RESTART_KEY);
|
||||
|
||||
@@ -130,18 +137,18 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator {
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(jdbcTemplate, "JdbcTemplate must not be null.");
|
||||
Assert.hasText(sql, "The DrivingQuery must not be null or empty.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the {@link RowMapper} to be used to map each key to an object.
|
||||
*
|
||||
*
|
||||
* @param keyMapper
|
||||
*/
|
||||
public void setKeyMapper(RowMapper keyMapper) {
|
||||
@@ -149,14 +156,15 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SQL query to be used to return the remaining keys to be processed.
|
||||
*
|
||||
* Set the SQL query to be used to return the remaining keys to be
|
||||
* processed.
|
||||
*
|
||||
* @param restartSql
|
||||
*/
|
||||
public void setRestartSql(String restartSql) {
|
||||
this.restartSql = restartSql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the SQL statement to be used to return the keys to be processed.
|
||||
*
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.jdbc.core.RowMapper;
|
||||
* @see RowMapper
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface RestartDataRowMapper extends RowMapper {
|
||||
public interface StreamContextRowMapper extends RowMapper {
|
||||
|
||||
/**
|
||||
* Given the provided composite key, return a RestartData representation.
|
||||
@@ -74,7 +74,7 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen
|
||||
* file and position the buffer reader according to information provided by
|
||||
* the restart data
|
||||
*
|
||||
* @param restartData restartData information
|
||||
* @param data {@link StreamContext} information
|
||||
*/
|
||||
public void restoreFrom(StreamContext data) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user