Interface KeyCollector

All Known Implementing Classes:
IbatisKeyCollector, MultipleColumnJdbcKeyCollector, SingleColumnJdbcKeyCollector

public interface KeyCollector

Strategy interface used to collect keys in driving query input.

Lucas Ward
See Also:

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


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.

executionContext - ExecutionContext containing any potential initial state that could potentially be used to retrieve the correct keys.
list of keys returned by the driving query


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.

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

Copyright © 2008 SpringSource. All Rights Reserved.