public interface LifecycleService
extends com.google.common.util.concurrent.Service
Modifier and Type | Method and Description |
---|---|
void |
addDynamicSkillProvider(provider : DynamicSkillProvider)
Add a dynamic skill provider that must be used for the agents that are spawned
after the call to this function.
|
void |
addKernelAgentLifecycleListener(listener : KernelAgentLifecycleListener)
Add a listener on the changes related to the kernel agent.
|
void |
addLifecycleServiceListener(agentLifecycleListener : LifecycleServiceListener)
Add a listener on the changes in the current state of an agent.
|
boolean |
getSpawnEnable()
Replies if the spawning of agents is enabled or disabled.
|
boolean |
killAgent(agent : Agent,
forceKillable : boolean,
terminationCause : Object)
Kill the given agent.
|
void |
removeDynamicSkillProvider(provider : DynamicSkillProvider)
Remove a dynamic skill provider that must be not be used any more for the agents that are spawned.
|
void |
removeKernelAgentLifecycleListener(listener : KernelAgentLifecycleListener)
Remove a listener on the changes related to the kernel agent.
|
void |
removeLifecycleServiceListener(agentLifecycleListener : LifecycleServiceListener)
Remove a listener on the changes in the current state of an agent.
|
void |
setSpawnEnable(enable : boolean)
Enable or disable the spawning of agents.
|
void |
spawnAgent(nbAgents : int,
spawningAgent : UUID,
parent : Context,
agentId : UUID,
agentClazz : Class<? extends Agent>,
params : Object[])
Spawn agents of the given type, and pass the parameters to its initialization function.
|
def
setSpawnEnable(enable : boolean) : void
LifecycleService
enable
- indicates if the spawning of agents is enable or disable.@Pure
def
getSpawnEnable() : boolean
LifecycleService
def
spawnAgent(nbAgents : int,
spawningAgent : UUID,
parent : Context,
agentId : UUID,
agentClazz : Class<? extends Agent>,
params : Object[]) : void
LifecycleService
This function is not blocking until all the agents are spawned.
nbAgents
- the number of agents to spawn.spawningAgent
- the agent which is spawning, if null
, the root agent (Janus kernel) is assumed.parent
- the parent entity that is creating the agents.agentId
- the identifier of the agent to spawn. If null
the identifier is randomly selected.
If nbAgents
is greater than 1, the agent identifier must be null
.agentClazz
- the type of the agents to spawn.callback
- function that is invoked when an identifier of spawned agent is known. The number of times this callback
is invoked depends on the service's implementation. But, the contract is that is must be called at least one time when
one or more agent is spawned.params
- the list of the parameters to pass to the agent initialization function.def
killAgent(agent : Agent,
forceKillable : boolean,
terminationCause : Object) : boolean
LifecycleService
An agent could be killed only if it does not contain sub-agents.
Because the agent reference is passed to this function, only the objects which have this reference could kill the agent.
agent
- the agent to kill.forceKillable
- indicates if the kill of the agent should be tested before killing it.
Usually, the agent cannot be killed when it contains other agents. This flag
enables or disables to the run of this test. If true
, the agent is always assumed
to be killable.terminationCause
- is the cause of the termination of the agent.
If it is null
, the agent does not provide a specific termination cause.true
if the agent was killed by this call; false
if the agent
is unknown or already killed.def
addLifecycleServiceListener(agentLifecycleListener : LifecycleServiceListener) : void
LifecycleService
agentLifecycleListener
- the listener on the any change in the life-cycle of the agent.def
removeLifecycleServiceListener(agentLifecycleListener : LifecycleServiceListener) : void
LifecycleService
agentLifecycleListener
- the listener on the any change in the life-cycle of the agent.def
addKernelAgentLifecycleListener(listener : KernelAgentLifecycleListener) : void
LifecycleService
listener
- listener on the spawning events in the local kernel.def
removeKernelAgentLifecycleListener(listener : KernelAgentLifecycleListener) : void
LifecycleService
listener
- listener on the spawning events in the local kernel.def
addDynamicSkillProvider(provider : DynamicSkillProvider) : void
LifecycleService
provider
- is the provider of skills for newly created agents.def
removeDynamicSkillProvider(provider : DynamicSkillProvider) : void
LifecycleService
provider
- is the provider of skills to be removed.Copyright © 2021 the original authors or authors.