|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mule.streaming.AbstractConsumer<T,P>
T - the type that the consumer will returnP - the type that the producer generatespublic abstract class AbstractConsumer<T,P>
Base implementation of Consumer. This template class takes care of the
contract's subtleties like returning fast when closed and throwing the correct
types of exceptions
| Field Summary | |
|---|---|
protected Producer<P> |
producer
|
| Constructor Summary | |
|---|---|
AbstractConsumer(Producer<P> producer)
|
|
| Method Summary | |
|---|---|
protected abstract boolean |
checkConsumed()
Implement this method to actualy check for the Producer being fully
consumed without worrying about it being closed or throwing any exceptions |
void |
close()
Closes the resource. |
T |
consume()
Retrieves the next available item. |
protected abstract T |
doConsume()
Implement this method to actually consume the producer without worrying about exception types or checking fo this consumer to be closed. |
boolean |
isConsumed()
Returns true if no more items are available or if the consumer
was closed. |
int |
size()
returns the total amount of items available for storage/processing. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Producer<P> producer
| Constructor Detail |
|---|
public AbstractConsumer(Producer<P> producer)
| Method Detail |
|---|
protected abstract T doConsume()
throws NoSuchElementException
null
null
NoSuchElementExceptionprotected abstract boolean checkConsumed()
Producer being fully
consumed without worrying about it being closed or throwing any exceptions
Producer has been consumed or not
public final T consume()
throws NoSuchElementException
consume in interface Consumer<T>null otherwise
NoSuchElementExceptionpublic final boolean isConsumed()
true if no more items are available or if the consumer
was closed. When this method returns true, implementors of this
class are require to invoke the Closeable.close() method before
returning in order to release resources as quickly as possible. Users of this
component who no longer need this require before it is fully consumed are also
required to close it.
isConsumed in interface Consumer<T>true if no more items are available. false
otherwise
public void close()
throws MuleException
close in interface CloseableMuleException - if an exception occurs closing the resourcepublic int size()
size in interface ProvidesTotalHint
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||