io.sarl.sre.janus.services.lifecycle
Interface LifecycleService
All Superinterfaces:
org.arakhne.afc.services.IService
All Known Implementing Classes:
AbstractLifecycleService, InjectionBasedLifecycleService, StandardLifecycleService
interface LifecycleService
implements org.arakhne.afc.services.IService
This service provides the tools to manage the life-cycle of the agents.
Maven Group Identifier:
io.sarl.sre.janus
Maven Artifact Identifier:
janus.kernel
Property Summary
Modifier and type Property and description
boolean spawnEnable
Replies if the spawning of agents is enabled or disabled.
Action Summary
Modifier and type Action and description
abstract void addDynamicSkillProvider(DynamicSkillProvider)
Add a dynamic skill provider that must be used for the agents that are spawned after the call to this function.
abstract void addKernelAgentLifecycleListener(KernelAgentLifecycleListener)
Add a listener on the changes related to the kernel agent.
abstract void addLifecycleServiceListener(LifecycleServiceListener)
Add a listener on the changes in the current state of an agent.
abstract boolean getSpawnEnable
Replies if the spawning of agents is enabled or disabled.
abstract boolean killAgent(Agent,boolean,Object)
Kill the given agent.
abstract void removeDynamicSkillProvider(DynamicSkillProvider)
Remove a dynamic skill provider that must be not be used any more for the agents that are spawned.
abstract void removeKernelAgentLifecycleListener(KernelAgentLifecycleListener)
Remove a listener on the changes related to the kernel agent.
abstract void removeLifecycleServiceListener(LifecycleServiceListener)
Remove a listener on the changes in the current state of an agent.
abstract void setSpawnEnable(boolean)
Enable or disable the spawning of agents.
abstract void spawnAgent(int,UUID,Context,UUID,Class<T>,Object)
Spawn agents of the given type, and pass the parameters to its initialization function.
Property Details
spawnEnable
var spawnEnable : boolean
Replies if the spawning of agents is enabled or disabled.

This property is an alias for the action: getSpawnEnable

Returns:
the flag that indicates if the spawning of agents is enable or disable.
Since:
0.11
Action Details
addDynamicSkillProvider(DynamicSkillProvider)
def addDynamicSkillProvider(DynamicSkillProvider)
Add a dynamic skill provider that must be used for the agents that are spawned after the call to this function.
Parameters:
provider - is the provider of skills for newly created agents.
addKernelAgentLifecycleListener(KernelAgentLifecycleListener)
def addKernelAgentLifecycleListener(KernelAgentLifecycleListener)
Add a listener on the changes related to the kernel agent.
Parameters:
listener - listener on the spawning events in the local kernel.
addLifecycleServiceListener(LifecycleServiceListener)
def addLifecycleServiceListener(LifecycleServiceListener)
Add a listener on the changes in the current state of an agent.
Parameters:
agentLifecycleListener - the listener on the any change in the life-cycle of the agent.
getSpawnEnable
def getSpawnEnable : boolean
Replies if the spawning of agents is enabled or disabled.
Returns:
the flag that indicates if the spawning of agents is enable or disable.
Since:
0.11
killAgent(Agent,boolean,Object)
def killAgent(Agent,boolean,Object) : boolean
Kill the given agent.

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.
Parameters:
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.
Returns:
true if the agent was killed by this call; false if the agent is unknown or already killed.
Since:
0.12
removeDynamicSkillProvider(DynamicSkillProvider)
def removeDynamicSkillProvider(DynamicSkillProvider)
Remove a dynamic skill provider that must be not be used any more for the agents that are spawned.
Parameters:
provider - is the provider of skills to be removed.
removeKernelAgentLifecycleListener(KernelAgentLifecycleListener)
def removeKernelAgentLifecycleListener(KernelAgentLifecycleListener)
Remove a listener on the changes related to the kernel agent.
Parameters:
listener - listener on the spawning events in the local kernel.
removeLifecycleServiceListener(LifecycleServiceListener)
def removeLifecycleServiceListener(LifecycleServiceListener)
Remove a listener on the changes in the current state of an agent.
Parameters:
agentLifecycleListener - the listener on the any change in the life-cycle of the agent.
setSpawnEnable(boolean)
def setSpawnEnable(boolean)
Enable or disable the spawning of agents.
Parameters:
enable - indicates if the spawning of agents is enable or disable.
Since:
0.11
spawnAgent(int,UUID,Context,UUID,Class<T>,Object)
def spawnAgent(int,UUID,Context,UUID,Class<T>,Object)
Spawn agents of the given type, and pass the parameters to its initialization function.

This function is not blocking until all the agents are spawned.
Parameters:
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.
params - the list of the parameters to pass to the agent initialization function.