org.oddjob.beanbus.destinations
Class Batcher<T>

java.lang.Object
  extended by org.oddjob.beanbus.AbstractDestination<T>
      extended by org.oddjob.beanbus.destinations.Batcher<T>
Type Parameters:
T - The type of bean being batched.
All Implemented Interfaces:
Iterable<T>, Collection<T>, BusFilter<T,Collection<T>>, Outbound<Collection<T>>

public class Batcher<T>
extends AbstractDestination<T>
implements BusFilter<T,Collection<T>>

Description

Provide batching of beans.

Example

Create Batches of 2 beans.
<oddjob>
    <job>
        <bean-bus>
            <parts>
                <bus:iterable-driver id="bean-bus" xmlns:bus="oddjob:beanbus">
                    <beans>
                        <list>
                            <values>
                                <value value="Apple"/>
                                <value value="Orange"/>
                                <value value="Pear"/>
                                <value value="Kiwi"/>
                                <value value="Banana"/>
                            </values>
                        </list>
                    </beans>
                </bus:iterable-driver>
                <bean id="batcher" batchSize="2" class="org.oddjob.beanbus.destinations.Batcher"/>
                <bus:bean-capture id="results" xmlns:bus="oddjob:beanbus"/>
            </parts>
        </bean-bus>
    </job>
</oddjob>
Author:
rob

Constructor Summary
Batcher()
           
 
Method Summary
 boolean add(T bean)
           
protected  void dispatch()
          Dispatch the beans.
 int getBatchSize()
           
 int getCount()
           
 String getName()
           
 int getSize()
           
 Collection<? super Collection<T>> getTo()
           
 boolean isEmpty()
           
 void setBatchSize(int batchSize)
           
 void setBeanBus(BusConductor busConductor)
           
 void setName(String name)
           
 void setTo(Collection<? super Collection<T>> next)
          Set the out bound destination.
 String toString()
           
 
Methods inherited from class org.oddjob.beanbus.AbstractDestination
addAll, clear, contains, containsAll, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

Batcher

public Batcher()
Method Detail

add

public boolean add(T bean)
Specified by:
add in interface Collection<T>

dispatch

protected void dispatch()
Dispatch the beans. Called when a batch is ready of a trip is ending.


setBeanBus

@Inject
public void setBeanBus(BusConductor busConductor)

getCount

public int getCount()

getSize

public int getSize()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<T>
Overrides:
isEmpty in class AbstractDestination<T>

getBatchSize

public int getBatchSize()

setBatchSize

public void setBatchSize(int batchSize)

getTo

public Collection<? super Collection<T>> getTo()

setTo

public void setTo(Collection<? super Collection<T>> next)
Description copied from interface: Outbound
Set the out bound destination.

Specified by:
setTo in interface Outbound<Collection<T>>

getName

public String getName()

setName

public void setName(String name)

toString

public String toString()
Overrides:
toString in class Object