outputStrategy
Class Batch

java.lang.Object
  extended by outputStrategy.Batch

final class Batch
extends java.lang.Object

Data structure used to stores processed messages until output is requested (see putOutBatch()). Then, all messages in the buffer are submitted to the InputOutputHandler, which sends them to their destination. Messages are added in sorted manner (alphabetic, ascending order) to prevent linkability of (incoming and outgoing) messages due to their position in the input and output stream.

This class is thread-safe.

Author:
Karl-Peter Fuchs

Constructor Summary
protected Batch(int initialMessageBufferSize, boolean isRequestBatch, boolean belongsToLastMix, InputOutputHandlerController inputOutputHandlerController)
          Constructs a new Batch that can be used to stores processed messages until output is requested (see putOutBatch()).
 
Method Summary
protected  void addMessage(Message message)
          Adds the bypassed message to the local buffer (at the correct position according to alphabetic, ascending order).
protected  void putOutBatch()
          Puts out the current batch, by submitting all messages in buffer to the InputOutputHandler, which sends them to their destination.
protected  int size()
          Returns the total number of messages currently in this Batch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Batch

protected Batch(int initialMessageBufferSize,
                boolean isRequestBatch,
                boolean belongsToLastMix,
                InputOutputHandlerController inputOutputHandlerController)
Constructs a new Batch that can be used to stores processed messages until output is requested (see putOutBatch()).

Parameters:
initialMessageBufferSize - Initial size for the data structure (ArrayList) used to store messages.
isRequestBatch - Indicates whether this Batch is used to collect Requests or Replyies.
belongsToLastMix - Indicates whether this Batch belongs to the last mix of a cascade or not.
inputOutputHandlerController - Reference on component InputOutputHandler (used to send messages to their destination when putOutBatch() was called).
Method Detail

size

protected int size()
Returns the total number of messages currently in this Batch.

Returns:
Total number of messages currently in this Batch.

addMessage

protected void addMessage(Message message)
Adds the bypassed message to the local buffer (at the correct position according to alphabetic, ascending order).

Parameters:
message - Message to be added to local buffer.

putOutBatch

protected void putOutBatch()
Puts out the current batch, by submitting all messages in buffer to the InputOutputHandler, which sends them to their destination.