org.springframework.batch.item.database
Interface KeyCollector

All Known Implementing Classes:
IbatisKeyCollector, MultipleColumnJdbcKeyCollector, SingleColumnJdbcKeyCollector

public interface KeyCollector

Strategy interface used to collect keys in driving query input.

Author:
Lucas Ward
See Also:
DrivingQueryItemReader

Method Summary
 List retrieveKeys(ExecutionContext executionContext)
          Retrieve the keys to be iterated over.
 void updateContext(Object key, ExecutionContext executionContext)
          Given the provided key, store it in the provided ExecutionContext.
 

Method Detail

retrieveKeys

List retrieveKeys(ExecutionContext executionContext)

Retrieve the keys to be iterated over. If the ExecutionContext provided includes any state relevant to this collector (because it was stored as part of saveState()) then it should start from the point indicated by that state.

In the case of a restart, (i.e. the ExecutionContext contains relevant state) this method should return only the keys that are remaining to be processed. For example, if the are 1,000 keys, and the 500th is processed before the batch job terminates unexpectedly, upon restart keys 501 through 1,000 should be returned.

Parameters:
executionContext - ExecutionContext containing any potential initial state that could potentially be used to retrieve the correct keys.
Returns:
list of keys returned by the driving query (can be empty but not null)

updateContext

void updateContext(Object key,
                   ExecutionContext executionContext)
Given the provided key, store it in the provided ExecutionContext. This is necessary because retrieveKeys() will be called with the ExecutionContext that is provided as a result of this method. Since only the KeyCollector can know what format the ExecutionContext should be in, it should also save the state, as opposed to the DrivingQueryItemReader doing it for all KeyCollector implementations.

Parameters:
key - to be converted to restart data.
Throws:
IllegalArgumentException - if key is null.
IllegalArgumentException - if key is an incompatible type.


Copyright © 2009 SpringSource. All Rights Reserved.