cz.cuni.amis.pogamut.base.factory.guice
Class AbstractGuiceAgentFactory

Package class diagram package AbstractGuiceAgentFactory
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.factory.guice.AbstractGuiceAgentFactory
Direct Known Subclasses:
GuiceAgentFactory

public abstract class AbstractGuiceAgentFactory
extends Object

Abstract Guice-based factory that uses GuiceAgentModule for the bindings.

It simply wraps the Guice's Injector, which it creates based on the passed module.

The module can be reset using setAgentModule(GuiceAgentModule).

Author:
Jimmy

Constructor Summary
AbstractGuiceAgentFactory()
          Parameter-less constructor that can be utilized in situations when you have to set the GuiceAgentModule later.
AbstractGuiceAgentFactory(GuiceAgentModule module)
          Creates a Guice-based factory that will use Injector created using the 'module'.
 
Method Summary
protected  GuiceAgentModule getAgentModule()
          Returns the module that the factory is working with.
protected  com.google.inject.Injector getInjector()
          Injector that should be used to instantiates new objects according to the module.
protected  void setAgentModule(GuiceAgentModule module)
          Sets new agent module into the factory, it invalidates the injector so the new one is created when getInjector() is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractGuiceAgentFactory

public AbstractGuiceAgentFactory()
Parameter-less constructor that can be utilized in situations when you have to set the GuiceAgentModule later. (DO NOT FORGET TO DO IT VIA setAgentModule(GuiceAgentModule) :-)


AbstractGuiceAgentFactory

public AbstractGuiceAgentFactory(GuiceAgentModule module)
Creates a Guice-based factory that will use Injector created using the 'module'.

Parameters:
module - module that configures bindings between classes, may be null (specify module later using setAgentModule(GuiceAgentModule))
Method Detail

getAgentModule

protected GuiceAgentModule getAgentModule()
Returns the module that the factory is working with. Can be utilized to slip run-time dependencies into the module.

Returns:
factory module

setAgentModule

protected void setAgentModule(GuiceAgentModule module)
Sets new agent module into the factory, it invalidates the injector so the new one is created when getInjector() is called.

Parameters:
module - new module

getInjector

protected com.google.inject.Injector getInjector()
Injector that should be used to instantiates new objects according to the module.

Lazy-initialized using getAgentModule().

Returns:
injector configured by getAgentModule()


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