public final class AgentLife extends Object
Constructor and Description |
---|
AgentLife(factories : javax.inject.Provider<Factories>,
agentLevelInjector : javax.inject.Provider<ConfigurableAgentInjector>)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ContextReference |
addExternalContext(context : Context,
address : Address)
Add a context in which the agent is located.
|
protected void |
attachAgentToDefaultContext(spawningContext : Context)
Set up the agent in order to be attached properly to its default context.
|
protected void |
detachAgentFromPlatform(listener : EventListener,
enclosingContexts : ConcurrentCollection<ContextReference>)
Detach the agent from the platform.
|
Address |
getAddressInInnerDefaultSpace()
Replies the address of the agent into the default space of its inner context.
|
Agent |
getAgent()
Replies the agent associated to this life.
|
static AgentLife |
getAgentLife(agent : Agent,
factories : javax.inject.Provider<Factories>,
agentLevelInjector : javax.inject.Provider<ConfigurableAgentInjector>)
Replies the data structure that is storing the living data of the agent for the SRE.
|
static AgentLife |
getAgentLifeOrNull(agent : Agent)
Replies the data structure that is storing the living data of the agent for the SRE.
|
Logging |
getAgentLogger()
Replies the agent's logger.
|
ContextReference |
getDefaultContext()
Replies the default context of the agent.
|
ConcurrentLinkedDeque<ContextReference> |
getEnclosingContexts()
Replies all the contexts in which the agent is located, including the default context and
the external contexts.
|
InternalEventBusCapacity |
getEventBus(ag : Agent)
Replies the agent's event bus.
|
ContextReference |
getExternalContext(identifier : UUID)
Replies the external context with the given identifier.
|
int |
getExternalContextCount()
Replies the number of external contexts in which the agent is located.
|
ConcurrentLinkedDeque<ContextReference> |
getExternalContexts()
Replies the external contexts in which the agent is located.
|
Context |
getInnerContext(creator : (AgentLife)=>Context)
Replies the inner context reference.
|
protected (Agent,Skill)=>void |
getInternalSkillCallback()
Replies the callback to be run when a skill is attached to the agent.
|
AgentState |
getState()
Replies the agent state.
|
ContextReference |
removeExternalContext(context : Context)
Remove a context in which the agent is located.
|
ContextReference |
removeExternalContext(context : ContextReference)
Remove a context in which the agent is located.
|
Agent |
setAgent(agent : Agent)
Change the agent associated to this life.
|
ContextReference |
setDefaultContext(context : Context,
address : Address)
Change the default context of the agent.
|
Context |
setInnerContext(innerContext : Context)
Set the inner context reference.
|
AgentState |
setState(state : AgentState)
Change the agent state.
|
boolean |
start(startingAgent : Agent,
skillUninstaller : SkillUninstaller,
logger : Logger,
spawningAgent : UUID,
spawningContext : Context,
initializationParameters : Object*)
Start the agent's life.
|
ConcurrentCollection<ContextReference> |
stop(dyingAgent : Agent,
skillUninstaller : SkillUninstaller,
logger : Logger,
[fireDestroy : boolean])
Stop the agent's life.
|
String |
toString() |
public new
(factories : javax.inject.Provider<Factories>,
agentLevelInjector : javax.inject.Provider<ConfigurableAgentInjector>)
factories
- the provider of factories tool.agentLevelInjector
- the initializer of the agent trait.@Pure
public static def
getAgentLife(agent : Agent,
factories : javax.inject.Provider<Factories>,
agentLevelInjector : javax.inject.Provider<ConfigurableAgentInjector>) : AgentLife
AgentLife
agent
- the instance of the agent for which the life description should be retrievedfactories
- the provider of factories tool.agentLevelInjector
- the injector that must be used for injecting members into an agent.AgentLife.getAgentLifeOrNull(io.sarl.lang.core.Agent)
@Pure
public static def
getAgentLifeOrNull(agent : Agent) : AgentLife
AgentLife
agent
- the instance of the agent for which the life description should be retrievedAgentLife.getAgentLife(io.sarl.lang.core.Agent, javax.inject.Provider<io.sarl.sre.internal.Factories>, javax.inject.Provider<io.sarl.sre.internal.ConfigurableAgentInjector>)
@Pure
public final def
getAgentLogger() : Logging
AgentLife
@Pure
public final def
getEventBus(ag : Agent) : InternalEventBusCapacity
AgentLife
ag
- is the reference to the owner to consider@Pure
protected def
getInternalSkillCallback() : (Agent,Skill)=>void
AgentLife
public def
start(startingAgent : Agent,
skillUninstaller : SkillUninstaller,
logger : Logger,
spawningAgent : UUID,
spawningContext : Context,
initializationParameters : Object*) : boolean
AgentLife
This function is invoked for executing the born stage of the agent.
If an exception is thrown into the initialization code of the agent, the exception is forwarded.
startingAgent
- is the reference to the starting agent.skillUninstaller
- the skill uninstaller.logger
- the logger to use for reporting initialization errors when the agent's logger is unavailablestartError
- the exception that avoid to start the agent.spawningAgent
- the identifier of the agent which has spawn this starting agent. This agent could be outside the spawningContext.
If null
, the root agent (Janus kernel) is assumed.spawningContext
- the context in which the agent is spawned.initializationParameters
- the parameters to give to the agent for its start-up.true
is successful, i.e. the AgentSpawned
could be fired.protected def
attachAgentToDefaultContext(spawningContext : Context) : void
AgentLife
spawningContext
- the context in which the agent is spawn.eventBus
- the event bus of the agent.protected def
detachAgentFromPlatform(listener : EventListener,
enclosingContexts : ConcurrentCollection<ContextReference>) : void
AgentLife
This function removes the agent from the default space of its default context.
listener
- the listener on space events that must be unregistered.enclosingContexts
- is the list of context for which we should be sure that the agent is out.public def
stop(dyingAgent : Agent,
skillUninstaller : SkillUninstaller,
logger : Logger,
[fireDestroy : boolean]) : ConcurrentCollection<ContextReference>
AgentLife
This function is invoked for executing the killing stage of the agent.
dyingAgent
- is the agent to be killed.skillUninstaller
- the skill uninstaller.logger
- the logger to use for reporting initialization errors when the agent's logger is unavailablefireDestroy
- indicates if the Destroy
event should be fired.@Pure
public def
getAgent() : Agent
AgentLife
public def
setAgent(agent : Agent) : Agent
AgentLife
@Pure
public def
getState() : AgentState
AgentLife
public def
setState(state : AgentState) : AgentState
AgentLife
public def
setInnerContext(innerContext : Context) : Context
AgentLife
innerContext
- the instance of inner context, or null
null
.@Pure
public def
getInnerContext(creator : (AgentLife)=>Context) : Context
AgentLife
creator
- is invoked to create the inner context thread-safely. If is it null
,
the context will not be created on-the-fly if it is not already known.null
@Pure
public def
getAddressInInnerDefaultSpace() : Address
AgentLife
null
.public def
addExternalContext(context : Context,
address : Address) : ContextReference
AgentLife
context
- the context in which the agent is now located.address
- the address of the agent in the default space of the given context.null
if the reference cannot be added (because the given context is already the default context).public def
removeExternalContext(context : Context) : ContextReference
AgentLife
public def
removeExternalContext(context : ContextReference) : ContextReference
AgentLife
@Pure
public def
getExternalContexts() : ConcurrentLinkedDeque<ContextReference>
AgentLife
#getEnclosingContexts()}
@Pure
public def
getExternalContextCount() : int
AgentLife
@Pure
public def
getEnclosingContexts() : ConcurrentLinkedDeque<ContextReference>
AgentLife
#getExternalContexts()}
@Pure
public def
getExternalContext(identifier : UUID) : ContextReference
AgentLife
identifer
- the identifier of the context.null
public def
setDefaultContext(context : Context,
address : Address) : ContextReference
AgentLife
context
- the next context, never null
.address
- the address of the agent into the default space of the given context.@Pure
public def
getDefaultContext() : ContextReference
AgentLife
null
.Copyright © 2021 the original authors or authors.