org.jcreme.processing
Interface Consumer

All Known Implementing Classes:
DefaultConsumer

public interface Consumer

The interface describing the behavior of objects acting as consumers. This Interface along with the Producer Interface is designed to enable to easily string "consumption - production" pieces together. It enables to separate the successive operations applied to data so that the developers can concentrate their efforts on the operations themselves and not on how they are to be stringed or how the application will be architectured (distributed producers and consumers, pools, load balancing...) The architecture issues merely appear at deployment time.

Version:
$Revision: 1.2 $
Author:
$Author: dbregeon $

Method Summary
 java.lang.Object consumeItem()
          Consumes a new item from the parent producer.
 Producer getProvider()
          Returns the producer whose objects the consumer will consume.
 void setProvider(Producer provider)
          Sets the producer whose objects the consumer will consume.
 boolean validateItem(java.lang.Object item)
          Tells the parent producer that this consumer has finished with this object.
 

Method Detail

setProvider

public void setProvider(Producer provider)
                 throws java.lang.IllegalArgumentException
Sets the producer whose objects the consumer will consume.

Parameters:
provider - The producer to be set.
Throws:
java.lang.IllegalArgumentException - In case the type of the given producer doesn't match the expected type.

getProvider

public Producer getProvider()
Returns the producer whose objects the consumer will consume.

Returns:
The producer whose objects the consumer will consume.

consumeItem

public java.lang.Object consumeItem()
Consumes a new item from the parent producer.

Returns:
The next object provided by the parent producer.

validateItem

public boolean validateItem(java.lang.Object item)
Tells the parent producer that this consumer has finished with this object.

Parameters:
item - an item that was previously retrieved through the consumeItem method.
Returns:
true if item was successfully validated. false otherwise.


Copyright 2006 null. All Rights Reserved.