cz.cuni.amis.pogamut.base.utils.guice
Class AgentScope

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.utils.guice.AgentScope
All Implemented Interfaces:
com.google.inject.Scope, IAgentScope

public class AgentScope
extends java.lang.Object
implements IAgentScope

Scope used during the construction of the agent - treating all new instances (of classes annotated with AgentScoped) as singletons.

After instantiation of the agent, Pogamut calls clearScope() to release all references to instantiated objects that allows to reuse the injector again to get another instance of the agent.

We need this, because we're usually have one connection object that must be injected into two different classes thus must be treated "as a singleton for one instantiation of the agent". (This is not the only example...)

Every pogamut.base class is AgentScoped.


Nested Class Summary
static class AgentScope.SingletonProvider<T>
           
 
Constructor Summary
AgentScope()
           
 
Method Summary
 void clearScope()
          Release all AgentScoped objects that the scope is holding.
<T> com.google.inject.Provider
scope(com.google.inject.Key<T> key, com.google.inject.Provider<T> creator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.inject.Scope
toString
 

Constructor Detail

AgentScope

public AgentScope()
Method Detail

scope

public <T> com.google.inject.Provider scope(com.google.inject.Key<T> key,
                                            com.google.inject.Provider<T> creator)
Specified by:
scope in interface com.google.inject.Scope

clearScope

public void clearScope()
Description copied from interface: IAgentScope
Release all AgentScoped objects that the scope is holding.

Specified by:
clearScope in interface IAgentScope