inputOutputHandler
Class InputOutputHandlerController

java.lang.Object
  extended by inputOutputHandler.InputOutputHandlerController
All Implemented Interfaces:
InputOutputHandlerInterface

public final class InputOutputHandlerController
extends java.lang.Object
implements InputOutputHandlerInterface

Controller class of component InputOutputHandler. Implements the architecture interface InputOutputHandlerInterface.

Handles communication with clients, other mixes and receivers.

Waits for new connections from clients or other mixes and accepts messages using the classes ClientConnectionHandler, PreviousMixConnectionHandler, NextMixConnectionHandler and ProxyConnectionHandler and stores them in a ConcurrentLinkedQueue.

The process of accepting connections and receiving messages works in parallel to the mix operations. Therefore, the mix is capable of taking messages at any time (unless it is overloaded).

Sends (already mixed) messages to their destination using the same classes mentioned above. The mixed messages are stored in a ConcurrentLinkedQueue. The process of sending messages works in parallel to the mix operations. Therefore, the mix is capable of mixing new messages while sending the old ones.

This class is thread-safe.

Author:
Karl-Peter Fuchs

Constructor Summary
InputOutputHandlerController()
          Creates a new InputOutputHandler component that handles communication with clients, other mixes and proxies.
 
Method Summary
 void acceptConnections()
          Makes component listen for connections/messages on communication channels.
 void addReplies(Reply[] replies)
          Adds all the bypassed (already mixed) Replyies to the replyOutputQueue (from where they will be sent to their destination).
 void addReply(Reply reply)
          Adds the bypassed (already mixed) Reply to the replyOutputQueue (from where it will be sent to its destination).
 void addRequest(Request request)
          Adds the bypassed (already mixed) Request to the requestOutputQueue (from where it will be sent to its destination).
 void addRequests(Request[] requests)
          Adds all the bypassed (already mixed) Requests to the requestOutputQueue (from where they will be sent to their destination).
 Reply getReply()
          Returns a Reply (previously received, unprocessed) from a communication partner (e. g. proxy or other mix).
 Request getRequest()
          Returns a Request (previously received, unprocessed) from a communication partner (e. g. client or other mix).
 void initialize(UserDatabaseController userDatabase, OutputStrategyController outputStrategy, ExternalInformationPortController eip)
          Initialization method for this component.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputOutputHandlerController

public InputOutputHandlerController()
Creates a new InputOutputHandler component that handles communication with clients, other mixes and proxies.

Component can't be used before calling initialize().

See Also:
initialize( UserDatabaseController, OutputStrategyController, ExternalInformationPortController)
Method Detail

initialize

public void initialize(UserDatabaseController userDatabase,
                       OutputStrategyController outputStrategy,
                       ExternalInformationPortController eip)
Initialization method for this component. Must be called before using an instance of this class for anything but dispensing references on the instance itself.

Parameters:
userDatabase - Reference on component UserDatabase.
outputStrategy - Reference on component OutputStrategy.
eip - Reference on component ExternalInformationPort.

acceptConnections

public void acceptConnections()
Makes component listen for connections/messages on communication channels.

Specified by:
acceptConnections in interface InputOutputHandlerInterface

addRequest

public void addRequest(Request request)
Adds the bypassed (already mixed) Request to the requestOutputQueue (from where it will be sent to its destination).

Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).

Assures order (queuing strategy) and is thread-safe.

Used by component OutputStrategy.

Specified by:
addRequest in interface InputOutputHandlerInterface
Parameters:
request - Already processed message, that shall be sent to the next communication partner.
See Also:
getProcessedRequest(), addRequests(Request[])

addRequests

public void addRequests(Request[] requests)
Adds all the bypassed (already mixed) Requests to the requestOutputQueue (from where they will be sent to their destination).

Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).

Assures order (queuing strategy) and is thread-safe.

Used by component OutputStrategy.

Specified by:
addRequests in interface InputOutputHandlerInterface
Parameters:
requests - Already processed messages, that shall be sent to the next communication partner.
See Also:
getProcessedRequest(), addRequest(Request)

getRequest

public Request getRequest()
Returns a Request (previously received, unprocessed) from a communication partner (e. g. client or other mix). If no Requests are available, this method blocks until a new Request arrives.

Assures order (queuing strategy) and is thread-safe.

Specified by:
getRequest in interface InputOutputHandlerInterface
Returns:
A (previously received, unprocessed) Request.

addReply

public void addReply(Reply reply)
Adds the bypassed (already mixed) Reply to the replyOutputQueue (from where it will be sent to its destination).

Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).

Assures order (queuing strategy) and is thread-safe.

Used by component OutputStrategy.

Specified by:
addReply in interface InputOutputHandlerInterface
Parameters:
reply - Already processed message, that shall be sent to the next communication partner.
See Also:
getProcessedReply(), addReplies(Reply[])

addReplies

public void addReplies(Reply[] replies)
Adds all the bypassed (already mixed) Replyies to the replyOutputQueue (from where they will be sent to their destination).

Returns immediately (asynchronous behavior), the process of sending itself may be deferred (e. g. if communication channel is busy).

Assures order (queuing strategy) and is thread-safe.

Used by component OutputStrategy.

Specified by:
addReplies in interface InputOutputHandlerInterface
Parameters:
replies - Already processed messages, that shall be sent to the next communication partner.
See Also:
getProcessedReply(), addReply(Reply)

getReply

public Reply getReply()
Returns a Reply (previously received, unprocessed) from a communication partner (e. g. proxy or other mix). If no Replyies are available, this method blocks until a new Reply arrives.

Assures order (queuing strategy) and is thread-safe.

Specified by:
getReply in interface InputOutputHandlerInterface
Returns:
A (previously received, unprocessed) Reply.