Class TradeWriter
- java.lang.Object
- org.springframework.batch.item.ItemStreamSupport
- org.springframework.batch.sample.domain.trade.internal.TradeWriter
- All Implemented Interfaces:
ItemStream,ItemWriter<Trade>
public class TradeWriter extends ItemStreamSupport implements ItemWriter<Trade>
Delegates the actual writing to custom DAO delegate. Allows configurable exception raising for testing skip and restart.
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTOTAL_AMOUNT_KEY
Constructor Summary
Constructors Constructor Description TradeWriter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimalgetTotalPrice()voidopen(ExecutionContext executionContext)No-op.voidsetDao(TradeDao dao)voidsetFailingCustomers(java.util.List<java.lang.String> failingCustomers)Public setter for the the customers on which failure should occur.voidupdate(ExecutionContext executionContext)Return emptyExecutionContext.voidupdateTotalPrice(java.util.List<Trade> trades)voidwrite(java.util.List<? extends Trade> trades)Process the supplied data element.Methods inherited from class org.springframework.batch.item.ItemStreamSupport
close, getExecutionContextKey, setExecutionContextName, setName
Field Detail
TOTAL_AMOUNT_KEY
public static final java.lang.String TOTAL_AMOUNT_KEY
- See Also:
- Constant Field Values
Method Detail
write
public void write(java.util.List<? extends Trade> trades)
Description copied from interface:ItemWriterProcess the supplied data element. Will not be called with any null items in normal operation.- Specified by:
writein interfaceItemWriter<Trade>- Parameters:
trades- items to be written
updateTotalPrice
public void updateTotalPrice(java.util.List<Trade> trades)
open
public void open(ExecutionContext executionContext)
Description copied from class:ItemStreamSupportNo-op.- Specified by:
openin interfaceItemStream- Overrides:
openin classItemStreamSupport- Parameters:
executionContext- current step'sExecutionContext. Will be the executionContext from the last run of the step on a restart.- See Also:
ItemStream.open(ExecutionContext)
update
public void update(ExecutionContext executionContext)
Description copied from class:ItemStreamSupportReturn emptyExecutionContext.- Specified by:
updatein interfaceItemStream- Overrides:
updatein classItemStreamSupport- Parameters:
executionContext- to be updated- See Also:
ItemStream.update(ExecutionContext)
getTotalPrice
public java.math.BigDecimal getTotalPrice()
setDao
public void setDao(TradeDao dao)
setFailingCustomers
public void setFailingCustomers(java.util.List<java.lang.String> failingCustomers)
Public setter for the the customers on which failure should occur.- Parameters:
failingCustomers- The customers to fail on