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

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

public class Mediator
extends 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 cz.cuni.amis.utils.token.Token COMPONENT_ID
           
protected  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 String WORKER_THREAD_NAME_PREFIX
          Name prefix for the worker thread and for the logs.
protected  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
 cz.cuni.amis.utils.token.Token getComponentId()
          Unique identification of the component.
 LogCategory getLog()
           
 void setConsumer(IWorldChangeEventInput consumer)
           
 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 cz.cuni.amis.utils.token.Token COMPONENT_ID

WORKER_THREAD_NAME_PREFIX

public static final 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 Thread workerThread
Thread of the worker.


threadMutex

protected 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 cz.cuni.amis.utils.token.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 String toString()
Overrides:
toString in class Object


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.