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.String
TOTAL_AMOUNT_KEY
Constructor Summary
Constructors Constructor Description TradeWriter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimal
getTotalPrice()
void
open(ExecutionContext executionContext)
No-op.void
setDao(TradeDao dao)
void
setFailingCustomers(java.util.List<java.lang.String> failingCustomers)
Public setter for the the customers on which failure should occur.void
update(ExecutionContext executionContext)
Return emptyExecutionContext
.void
updateTotalPrice(java.util.List<Trade> trades)
void
write(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:ItemWriter
Process the supplied data element. Will not be called with any null items in normal operation.- Specified by:
write
in 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:ItemStreamSupport
No-op.- Specified by:
open
in interfaceItemStream
- Overrides:
open
in 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:ItemStreamSupport
Return emptyExecutionContext
.- Specified by:
update
in interfaceItemStream
- Overrides:
update
in 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