cz.cuni.amis.pogamut.base.communication.mediator.impl
Class Mediator

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.mediator.impl.Mediator
All Implemented Interfaces:
IMediator, IComponent

public class Mediator
extends java.lang.Object
implements IMediator

This class should wrap the reading thread that continuously reads IWorldChangeEvent from the IWorldChangeEventOutput passing them to the without any delay.

Note that the mediator **NEEDS** setConsumer(IWorldChangeEventInput) called in order to be started by the IComponentBus.

Ignores IComponentControlHelper.startPaused(), performs IComponentControlHelper.start() in both start cases.


Field Summary
static Token COMPONENT_ID
           
protected  java.lang.Object threadMutex
          Mutex for start synchronization.
protected  cz.cuni.amis.pogamut.base.communication.mediator.impl.Mediator.Worker worker
          Worker instance - it implements Runnable interface and is continuously reading messages from the connection object and passing them to the receiver.
static java.lang.String WORKER_THREAD_NAME_PREFIX
          Name prefix for the worker thread and for the logs.
protected  java.lang.Thread workerThread
          Thread of the worker.
 
Constructor Summary
Mediator(IWorldChangeEventOutput producer, IComponentBus bus, IAgentLogger logger)
          The object in passed to the constructor (IWorldEventOutput) is world event producer.
 
Method Summary
 Token getComponentId()
          Unique identification of the component.
 LogCategory getLog()
           
 void setConsumer(IWorldChangeEventInput consumer)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPONENT_ID

public static final Token COMPONENT_ID

WORKER_THREAD_NAME_PREFIX

public static final java.lang.String WORKER_THREAD_NAME_PREFIX
Name prefix for the worker thread and for the logs.

See Also:
Constant Field Values

worker

protected cz.cuni.amis.pogamut.base.communication.mediator.impl.Mediator.Worker worker
Worker instance - it implements Runnable interface and is continuously reading messages from the connection object and passing them to the receiver.


workerThread

protected java.lang.Thread workerThread
Thread of the worker.


threadMutex

protected java.lang.Object threadMutex
Mutex for start synchronization.

Constructor Detail

Mediator

@Inject
public Mediator(IWorldChangeEventOutput producer,
                       IComponentBus bus,
                       IAgentLogger logger)
The object in passed to the constructor (IWorldEventOutput) is world event producer.

The mediator will read events from this producer and pass them to the IWorldEventInput specified during the start() of the mediator.

Note that the mediator **NEEDS** setConsumer(IWorldChangeEventInput) called in order to be started by the IComponentBus.

Parameters:
connection -
messageParser -
commandSerializer -
Throws:
CommunicationException
Method Detail

getComponentId

public Token getComponentId()
Description copied from interface: IComponent
Unique identification of the component.

Specified by:
getComponentId in interface IComponent
Returns:

getLog

public LogCategory getLog()

setConsumer

public void setConsumer(IWorldChangeEventInput consumer)
Specified by:
setConsumer in interface IMediator

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object