Package org.oddjob.beanbus.destinations
Class Batcher<T>
java.lang.Object
org.oddjob.beanbus.destinations.Batcher<T>
- Type Parameters:
T- The type of bean being batched.
- All Implemented Interfaces:
Flushable,AutoCloseable,Runnable,Consumer<T>,BusFilter<T,,Collection<T>> Outbound<Collection<T>>
public class Batcher<T>
extends Object
implements Consumer<T>, BusFilter<T,Collection<T>>, Flushable, Runnable, AutoCloseable
- Author:
- Rob
Description
Provide batching of beans.Example
Create Batches of 2 beans.
<oddjob>
<job>
<bus:bus id="bean-bus" xmlns:bus="oddjob:beanbus">
<of>
<bus:driver>
<values>
<list>
<values>
<value value="Apple"/>
<value value="Orange"/>
<value value="Pear"/>
<value value="Kiwi"/>
<value value="Banana"/>
</values>
</list>
</values>
</bus:driver>
<bean id="batcher" batchSize="2" class="org.oddjob.beanbus.destinations.Batcher"/>
<bus:collect id="results"/>
</of>
</bus:bus>
</job>
</oddjob>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()protected voiddispatch()Dispatch the beans.voidflush()intintgetCount()getName()intgetSize()Consumer<? super Collection<T>> getTo()voidreset()voidrun()voidsetBatchSize(int batchSize) voidvoidsetTo(Consumer<? super Collection<T>> next) Set the out bound destination.toString()
-
Constructor Details
-
Batcher
public Batcher()
-
-
Method Details
-
run
public void run() -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
reset
public void reset() -
accept
-
flush
- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
dispatch
protected void dispatch()Dispatch the beans. Called when a batch is ready of a trip is ending. -
getCount
public int getCount() -
getSize
public int getSize() -
getBatchSize
public int getBatchSize() -
setBatchSize
public void setBatchSize(int batchSize) -
getTo
-
setTo
Description copied from interface:OutboundSet the out bound destination. -
getName
-
setName
-
toString
-