cz.cuni.amis.pogamut.base.factory.guice
Class GuiceRemoteAgentModule<PARAMS extends IRemoteAgentParameters>

Package class diagram package GuiceRemoteAgentModule
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>
              extended by cz.cuni.amis.pogamut.base.factory.guice.GuiceRemoteAgentModule<PARAMS>
All Implemented Interfaces:
com.google.inject.Module
Direct Known Subclasses:
GuiceTeamRemoteAgentModule

public abstract class GuiceRemoteAgentModule<PARAMS extends IRemoteAgentParameters>
extends GuiceCommunicationModule<PARAMS>

Module extending GuiceAgentModule for the purpose of remote agents (those communicating with the world using IWorldConnection).

Introducing getAddressProvider() that allows you to specify IWorldConnectionAddress at runtime.

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.
IYylex World message parser implementation.
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.configure() in the subclasses ;-) NOTE> that the module is defining bindings for {@link IWorldReaderProvider} and {@link IWorldWriterProvider} which might not be suitable for {@link INativeAgentFactory}s - fear not as those bindings might be rebind thanks to Guice v2.

Author:
Jimmy
See Also:
GuiceAgentModule

Constructor Summary
GuiceRemoteAgentModule()
           
 
Method Summary
protected  void configureModules()
          Override to create new module with your own bindings adding it into GuiceAgentModule.modules using GuiceCommunicationModule#addModule(Module).
protected  AdaptableProvider getAddressProvider()
           
 void prepareNewAgent(PARAMS agentParameters)
          Must be called before another agent instance can be created.
 
Methods inherited from class cz.cuni.amis.pogamut.base.factory.guice.GuiceAgentModule
addModule, configure, createAgentScope, createAgentTeamScope, getAgentIdProvider, getAgentParamsProvider, getAgentScope, getAgentTeamScope
 
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

GuiceRemoteAgentModule

public GuiceRemoteAgentModule()
Method Detail

getAddressProvider

protected AdaptableProvider getAddressProvider()

prepareNewAgent

public void prepareNewAgent(PARAMS agentParameters)
Description copied from class: GuiceAgentModule
Must be called before another agent instance can be created. It clears the GuiceAgentModule.agentScope and binds IAgentParameters.getAgentId() to the GuiceAgentModule.agentIdProvider.

Whenever you create your own IAgentParameters you may need to override this method to utilize your new run-time dependencies. In such case, always call super.prepareNewAgent(agentParameters) as a first command.

Overrides:
prepareNewAgent in class GuiceAgentModule<PARAMS extends IRemoteAgentParameters>

configureModules

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

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

Overrides:
configureModules in class GuiceCommunicationModule<PARAMS extends IRemoteAgentParameters>


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