org.mule.streaming
Class CompositeProducer<T>

java.lang.Object
  extended by org.mule.streaming.CompositeProducer<T>
All Implemented Interfaces:
Closeable, Producer<T>, ProvidesTotalHint

public class CompositeProducer<T>
extends Object
implements Producer<T>

Implementation of Producer to expose streams from several producers as a single data feed. Producers are consumed in order until they're all consumed. All producers need to share the same generic type T

Since:
3.5.0

Constructor Summary
CompositeProducer(List<Producer<T>> producers)
          Takes a list of producers to be composited.
CompositeProducer(Producer<T>... producers)
           
 
Method Summary
 void close()
          Closes all the producers
 T produce()
          Returns the next available item
 int size()
          Accumulates the total available count of all the producers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeProducer

public CompositeProducer(List<Producer<T>> producers)
Takes a list of producers to be composited. They will be consumed in this order

Parameters:
producers - a list of Producer

CompositeProducer

public CompositeProducer(Producer<T>... producers)
Method Detail

produce

public T produce()
Returns the next available item This method calls the produce method on the current producer. When that producer is exhausted, then it switches to the next one. When the last producer is also exhausted, then it returns null. This method does not close any producer when it is exhausted. Use the close method for that

Specified by:
produce in interface Producer<T>
Returns:
an item. Might be null

size

public int size()
Accumulates the total available count of all the producers. If one of them does not have a value available (returns -1) then it is not factored in

Specified by:
size in interface ProvidesTotalHint

close

public void close()
           throws MuleException
Closes all the producers

Specified by:
close in interface Closeable
Throws:
MuleException - if an exception occurs closing the resource


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.