Bean
A bean is a type that contains methods implementing business logic. In batch, interfaces such as ItemReader, ItemProcessor, ItemWriter, and Tasklet, which are written to compose steps, have their roles during step execution predefined. Therefore, during development, the required interfaces must be implemented to develop the bean.
1. ItemReader
In a batch step, it retrieves data to be processed from resources such as DB or files and delivers it to ItemProcessor or ItemWriter.
Implemented interface
public interface org.springframework.batch.item.ItemReader
Implemented method: Responsible for reading each unit of target data from DB or files
T read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException;
2. ItemProcessor
It processes/transforms items received from ItemReader according to business requirements and delivers them to ItemWriter.
Implemented interface
public interface org.springframework.batch.item.ItemProcessor<I, O>
Implemented method: Responsible for processing each unit of target data according to business requirements
O process(I item) throws Exception;
3. ItemWriter
It records items received from ItemReader or ItemProcessor into storage media such as DB or files.
Implemented interface
public interface org.springframework.batch.item.ItemWriter<T>
Implemented method: Responsible for recording processed result data into DB or files per commit unit, or transmitting it to external systems
void write(List<? extends T> items) throws Exception;
4. ItemStream
Before the step starts, it performs initialization to use resources such as DB or files, and after the step is completed, it performs resource cleanup and, if necessary, progress management by executing this interface.
Implemented interface
public interface org.springframework.batch.item.ItemStream
Implemented method: Initialization processing - called by the framework before the step starts
void open(ExecutionContext executionContext) throws ItemStreamException;
Implemented method: Progress state recording - called by the framework at each commit (per commit-interval)
void update(ExecutionContext executionContext) throws ItemStreamException;
Implemented method: Resource cleanup - called by the framework after the step is completed
void close() throws ItemStreamException;