cz.cuni.amis.pogamut.base.factory.guice
Class GuiceCommunicationModule<PARAMS extends IAgentParameters>

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by cz.cuni.amis.pogamut.base.factory.guice.GuiceAgentModule<PARAMS>
          extended by cz.cuni.amis.pogamut.base.factory.guice.GuiceCommunicationModule<PARAMS>
All Implemented Interfaces:
com.google.inject.Module
Direct Known Subclasses:
GuiceRemoteAgentModule

public class GuiceCommunicationModule<PARAMS extends IAgentParameters>
extends GuiceAgentModule<PARAMS>

Base GaviaLib Guice module that covers the simple bindings for Pogamut's communication chain.

IWorldConnection IWorldConnection
Mapped class Target Description
IWorldReaderProvider -> Reader of the world's information.
IWorldWriterProvider -> Writer that sends commands to the agent's body in the world.
ICommandSerializer -> StringCommandSerializer Serializes commands using .toString() method.
IWorldChangeEventOutput -> WorldMessageTranslator Translator of InfoMessages into IWorldChangeEvents. Relies on the wrapped (world-dependent) implementation of IWorldMessageTranslator
IMediator -> Mediator Thread-wrapper, reader of IWorldChangeEventOutput that passes IWorldChangeEvent into IWorldChangeEventInput.
IWorldChangeEventInput -> IWorldView Consumer of IWorldChangeEvents.

To have successful module the descendant must specify these missing bindings:

Mapped class Description
IAgent Agent that should be instantiated
IWorldConnection Connection to the agent's world.
IWorldMessageParser Line oriented parser based on Yylex.
IYylex World message parser implementation.
IYylexObserver Yylex observer reporting errors.
IWorldMessageTranslator World-dependent implementation of InfoMessages translator into IWorldChangeEvent that can be consumed by IWorldView.
IWorldView World view processing {@link IWorldChangeEvent}s into {@link IWorldEvent}s that should be consumed by {@link IAgent} implementation.
... plus all newly introduced dependencies (by various implementors of mentioned interfaces).

... don't forget to call super.configureModules() in the subclasses. ;-)

If you want to bind custom (your own) class to one of the interface that is already binded (meaning you need to alter GaviaLib), do it this way:

  1. BE TOTALY SURE WHAT YOU'RE DOING :-) or it will fail horribly or you may cripple the IDE...
  2. Copy-paste (YES, COPY-PASTE IS THE BEST WAY) the implementation of the class you want to change and alter it to suits your needs.
  3. Always make those classes AgentScoped!
  4. Create new module where you re-specify the binding of desired interface.


Constructor Summary
GuiceCommunicationModule()
           
 
Method Summary
protected  void configureModules()
          Override to create new module with your own bindings adding it into GuiceAgentModule.modules using GuiceCommunicationModule#addModule(Module).
 
Methods inherited from class cz.cuni.amis.pogamut.base.factory.guice.GuiceAgentModule
addModule, configure, createAgentScope, getAgentIdProvider, getAgentParamsProvider, getAgentScope, prepareNewAgent
 
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuiceCommunicationModule

public GuiceCommunicationModule()
Method Detail

configureModules

protected void configureModules()
Override to create new module with your own bindings adding it into GuiceAgentModule.modules using GuiceCommunicationModule#addModule(Module).

See configureModules() source code for the example (utilizes anonymous class, instantiating AbstractModule).

Overrides:
configureModules in class GuiceAgentModule<PARAMS extends IAgentParameters>