io.sarl.sre.janus.services.lifecycle
Class AgentLife
final class AgentLife
extends java.lang.Object
Describes any information that is required by the SRE for supporting the agent's life.
Maven Group Identifier:
io.sarl.sre.janus
Maven Artifact Identifier:
janus.kernel
Since:
0.6.0
Property Summary
Modifier and type Property and description
Address addressInInnerDefaultSpace
Replies the address of the agent into the default space of its inner context.
Agent agent
Replies the agent associated to this life.
Logging agentLogger
Replies the agent's logger.
ContextReference defaultContext
Replies the default context of the agent.
java.util.concurrent.ConcurrentLinkedDeque<E> enclosingContexts
Replies all the contexts in which the agent is located, including the default context and the external contexts.
int externalContextCount
Replies the number of external contexts in which the agent is located.
java.util.concurrent.ConcurrentLinkedDeque<E> externalContexts
Replies the external contexts in which the agent is located.
protected org.eclipse.xtext.xbase.lib.Procedures.Procedure2<P1,P2> internalSkillCallback
Replies the callback to be run when a skill is attached to the agent.
AgentState state
Replies the agent state.
Constructor Summary
Constructor and description
new(Provider<T>,Provider<T>)
Constructor.
Action Summary
Modifier and type Action and description
ContextReference addExternalContext(Context,Address)
Add a context in which the agent is located.
protected void attachAgentToDefaultContext(Context)
Set up the agent in order to be attached properly to its default context.
protected void detachAgentFromPlatform(EventListener,ConcurrentCollection<T>)
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,Provider<T>,Provider<T>)
Replies the data structure that is storing the living data of the agent for the SRE.
static AgentLife getAgentLifeOrNull(Agent)
Replies the data structure that is storing the living data of the agent for the SRE.
final Logging getAgentLogger
Replies the agent's logger.
ContextReference getDefaultContext
Replies the default context of the agent.
java.util.concurrent.ConcurrentLinkedDeque<E> getEnclosingContexts
Replies all the contexts in which the agent is located, including the default context and the external contexts.
final InternalEventBusCapacity getEventBus(Agent)
Replies the agent's event bus.
ContextReference getExternalContext(UUID)
Replies the external context with the given identifier.
int getExternalContextCount
Replies the number of external contexts in which the agent is located.
java.util.concurrent.ConcurrentLinkedDeque<E> getExternalContexts
Replies the external contexts in which the agent is located.
Context getInnerContext(Function1<Param,Result>)
Replies the inner context reference.
protected org.eclipse.xtext.xbase.lib.Procedures.Procedure2<P1,P2> getInternalSkillCallback
Replies the callback to be run when a skill is attached to the agent.
AgentState getState
Replies the agent state.
ContextReference removeExternalContext(Context)
Remove a context in which the agent is located.
ContextReference removeExternalContext(ContextReference)
Remove a context in which the agent is located.
Agent setAgent(Agent)
Change the agent associated to this life.
ContextReference setDefaultContext(Context,Address)
Change the default context of the agent.
Context setInnerContext(Context)
Set the inner context reference.
AgentState setState(AgentState)
Change the agent state.
boolean start(Agent,SkillUninstaller,Logger,UUID,Context,Object*)
Start the agent's life.
ConcurrentCollection<T> stop(Agent,SkillUninstaller,Logger,[boolean])
Stop the agent's life.
java.lang.String toString
Property Details
addressInInnerDefaultSpace
val addressInInnerDefaultSpace : Address
Replies the address of the agent into the default space of its inner context.

This property is an alias for the action: getAddressInInnerDefaultSpace

Returns:
the address, never null .
agent
val agent : Agent
Replies the agent associated to this life.

This property is an alias for the action: getAgent

agentLogger
val agentLogger : Logging
Replies the agent's logger.

This property is an alias for the action: getAgentLogger

Returns:
the logger.
defaultContext
val defaultContext : ContextReference
Replies the default context of the agent.

This property is an alias for the action: getDefaultContext

Returns:
the default context, never null .
enclosingContexts
val enclosingContexts : java.util.concurrent.ConcurrentLinkedDeque<E>
Replies all the contexts in which the agent is located, including the default context and the external contexts.

This property is an alias for the action: getEnclosingContexts

See:
getExternalContexts
externalContextCount
val externalContextCount : int
Replies the number of external contexts in which the agent is located. The default context is not counted.

This property is an alias for the action: getExternalContextCount

Returns:
the number of external contexts.
externalContexts
val externalContexts : java.util.concurrent.ConcurrentLinkedDeque<E>
Replies the external contexts in which the agent is located. The default context is not part of the replied collection.

This property is an alias for the action: getExternalContexts

See:
getEnclosingContexts
internalSkillCallback
protected val internalSkillCallback : org.eclipse.xtext.xbase.lib.Procedures.Procedure2<P1,P2>
Replies the callback to be run when a skill is attached to the agent.

This property is an alias for the action: getInternalSkillCallback

state
val state : AgentState
Replies the agent state.

This property is an alias for the action: getState

Constructor Details
new(Provider<T>,Provider<T>)
new(Provider<T>,Provider<T>)
Constructor.
Parameters:
factories - the provider of factories tool.
agentLevelInjector - the initializer of the agent trait.
Action Details
addExternalContext(Context,Address)
def addExternalContext(Context,Address) : ContextReference
Add a context in which the agent is located.
Parameters:
context - the context in which the agent is now located.
address - the address of the agent in the default space of the given context.
Returns:
the created reference, or null if the reference cannot be added (because the given context is already the default context).
attachAgentToDefaultContext(Context)
protected def attachAgentToDefaultContext(Context)
Set up the agent in order to be attached properly to its default context.
Parameters:
spawningContext - the context in which the agent is spawn.
Since:
0.12
detachAgentFromPlatform(EventListener,ConcurrentCollection<T>)
protected def detachAgentFromPlatform(EventListener,ConcurrentCollection<T>)
Detach the agent from the platform.

This function removes the agent from the default space of its default context.
Parameters:
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.
getAddressInInnerDefaultSpace
def getAddressInInnerDefaultSpace : Address
Replies the address of the agent into the default space of its inner context.
Returns:
the address, never null .
getAgent
def getAgent : Agent
Replies the agent associated to this life.
getAgentLife(Agent,Provider<T>,Provider<T>)
def getAgentLife(Agent,Provider<T>,Provider<T>) : AgentLife
Replies the data structure that is storing the living data of the agent for the SRE. If this data structure does not exists, it is automatically created.
Parameters:
agent - the instance of the agent for which the life description should be retrieved
factories - the provider of factories tool.
agentLevelInjector - the injector that must be used for injecting members into an agent.
See:
#getAgentLifeOrNull
getAgentLifeOrNull(Agent)
def getAgentLifeOrNull(Agent) : AgentLife
Replies the data structure that is storing the living data of the agent for the SRE. If this data structure does not exists, it is NOT created.
Parameters:
agent - the instance of the agent for which the life description should be retrieved
Since:
0.10
See:
#getAgentLife
getAgentLogger
def getAgentLogger : Logging
Replies the agent's logger.
Returns:
the logger.
getDefaultContext
def getDefaultContext : ContextReference
Replies the default context of the agent.
Returns:
the default context, never null .
getEnclosingContexts
def getEnclosingContexts : java.util.concurrent.ConcurrentLinkedDeque<E>
Replies all the contexts in which the agent is located, including the default context and the external contexts.
See:
getExternalContexts
getEventBus(Agent)
def getEventBus(Agent) : InternalEventBusCapacity
Replies the agent's event bus.
Parameters:
ag - is the reference to the owner to consider
Returns:
the event bus.
getExternalContext(UUID)
def getExternalContext(UUID) : ContextReference
Replies the external context with the given identifier.
Parameters:
identifier - the identifier of the context.
Returns:
the context, or null
getExternalContextCount
def getExternalContextCount : int
Replies the number of external contexts in which the agent is located. The default context is not counted.
Returns:
the number of external contexts.
getExternalContexts
def getExternalContexts : java.util.concurrent.ConcurrentLinkedDeque<E>
Replies the external contexts in which the agent is located. The default context is not part of the replied collection.
See:
getEnclosingContexts
getInnerContext(Function1<Param,Result>)
def getInnerContext(Function1<Param,Result>) : Context
Replies the inner context reference.
Parameters:
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.
Returns:
the instance of inner context, or null
getInternalSkillCallback
protected def getInternalSkillCallback : org.eclipse.xtext.xbase.lib.Procedures.Procedure2<P1,P2>
Replies the callback to be run when a skill is attached to the agent.
getState
def getState : AgentState
Replies the agent state.
removeExternalContext(Context)
def removeExternalContext(Context) : ContextReference
Remove a context in which the agent is located.
removeExternalContext(ContextReference)
def removeExternalContext(ContextReference) : ContextReference
Remove a context in which the agent is located.
setAgent(Agent)
def setAgent(Agent) : Agent
Change the agent associated to this life.
setDefaultContext(Context,Address)
def setDefaultContext(Context,Address) : ContextReference
Change the default context of the agent.
Parameters:
context - the next context, never null.
address - the address of the agent into the default space of the given context.
Returns:
the reference to the previous default context.
setInnerContext(Context)
def setInnerContext(Context) : Context
Set the inner context reference.
Parameters:
innerContext - the instance of inner context, or null
Returns:
the previous context, or null .
setState(AgentState)
def setState(AgentState) : AgentState
Change the agent state.
start(Agent,SkillUninstaller,Logger,UUID,Context,Object*)
def start(Agent,SkillUninstaller,Logger,UUID,Context,Object*) : boolean
Start the agent's life.

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.
Parameters:
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 unavailable
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.
Returns:
true is successful, i.e. the AgentSpawned could be fired.
stop(Agent,SkillUninstaller,Logger,[boolean])
def stop(Agent,SkillUninstaller,Logger,[boolean]) : ConcurrentCollection<T>
Stop the agent's life.

This function is invoked for executing the killing stage of the agent.
Parameters:
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 unavailable
fireDestroy - indicates if the Destroy event should be fired.
Returns:
the contexts from which the agent was removed.
toString
def toString : java.lang.String