io.sarl.lang.core
Interface AgentContext
All Known Implementing Classes:
Context
interface AgentContext
An AgentContext defines the boundary of a sub-system, and gathers a collection of Spaces. Each context has a default context that provides a basic interaction context.
Maven Group Identifier:
io.sarl.lang
Maven Artifact Identifier:
core
Property Summary
Modifier and type Property and description
EventSpace defaultSpace
Replies the default space of the context.
java.util.UUID iD
Replies the identifier of the context.
ConcurrentCollection<T> spaces
Replies all the spaces defined in this context.
Action Summary
Modifier and type Action and description
abstract S createSpace(Class<T>,UUID,Object*)
Create an instance of space following the given specification.
abstract EventSpace getDefaultSpace
Replies the default space of the context.
abstract java.util.UUID getID
Replies the identifier of the context.
default S getOrCreateSpace(Class<T>,UUID,Object*)
Retreive or create an instance of space which was created with the given specification.
Deprecated for removal since 0.10: see getOrCreateSpaceWithSpec(Class, UUID, Object...)
abstract S getOrCreateSpaceWithID(Class<T>,UUID,Object*)
Retrieve or create an instance of space with the given identifier.
default S getOrCreateSpaceWithID(UUID,Class<T>,Object*)
Retrieve or create an instance of space with the given identifier.
Deprecated for removal since 0.10: see getOrCreateSpaceWithID(Class, UUID, Object...)
abstract S getOrCreateSpaceWithSpec(Class<T>,UUID,Object*)
Retrieve or create an instance of space which was created with the given specification.
abstract S getSpace(UUID)
Retrieve, but do not create, an instance of space following the given ID.
abstract ConcurrentCollection<T> getSpaces
Replies all the spaces defined in this context.
abstract ConcurrentCollection<T> getSpaces(Class<T>)
Replies all the spaces that are implementing the given specification.
abstract boolean isRootContext
Replies if the context is a root context.
Property Details
defaultSpace
val defaultSpace : EventSpace
Replies the default space of the context. The default space is assumed to be always an event-based space.

This property is an alias for the action: getDefaultSpace

Returns:
the default space.
iD
val iD : java.util.UUID
Replies the identifier of the context.

This property is an alias for the action: getID

Returns:
the identifier of the context.
spaces
val spaces : ConcurrentCollection<T>
Replies all the spaces defined in this context.

This property is an alias for the action: getSpaces

Returns:
the spaces.
Action Details
createSpace(Class<T>,UUID,Object*)
def createSpace(Class<T>,UUID,Object*) : S

with S extends Space

Create an instance of space following the given specification. This function always creates a new instance of space. It means that is a space with the given identifier already exists, this function does nothing and replies null. If you want to find an existing space prior to the creation of a new one, you should use getOrCreateSpace(Class, UUID, Object...).
Parameters:
<S> - - type of the created space.
spec - specification of the space to create.
spaceUUID - identifier of the new space.
creationParams - parameters to pass to the space constructor.
Returns:
the new space, or null if the space already exists.
See:
getOrCreateSpace(Class<T>,UUID,Object*) , getSpace(UUID)
getDefaultSpace
def getDefaultSpace : EventSpace
Replies the default space of the context. The default space is assumed to be always an event-based space.
Returns:
the default space.
getID
def getID : java.util.UUID
Replies the identifier of the context.
Returns:
the identifier of the context.
getOrCreateSpace(Class<T>,UUID,Object*)
def getOrCreateSpace(Class<T>,UUID,Object*) : S

with S extends Space

Retreive or create an instance of space which was created with the given specification.

This function tries to find a space that was created with the given specification. If none was found, this function creates a new space with the given space identifier and creation parameters.

Caution #1: This function ignores the default space when searching for a space created with an EventSpaceSpecification or OpenEventSpaceSpecification. Consequently, in the case of the spec argument is one of the previous types, and there is no other space in the context that was created with this specification, then the function creates a totally new space.

Caution #2: The spaceUUID parameter is used only if no existing space created with the given specification was found.
Parameters:
<S> - - type of the replied space.
spec - specification of the space to retreive/create.
spaceUUID - identifier used only when creating the space.
creationParams - parameters to pass to the space constructor.
Returns:
the space, never null and never the default space.
Deprecated:
see getOrCreateSpaceWithSpec(Class, UUID, Object...)
See:
getOrCreateSpaceWithID(UUID,Class<T>,Object*) , createSpace(Class<T>,UUID,Object*) , getSpace(UUID)
getOrCreateSpaceWithID(Class<T>,UUID,Object*)
def getOrCreateSpaceWithID(Class<T>,UUID,Object*) : S

with S extends Space

Retrieve or create an instance of space with the given identifier.

This function tries to find a space with the given identifier. If none was found, this function creates a new space with the given specification and creation parameters.

Caution #1: The spaceUUID parameter is given to the specification when creating the space.

Caution #2: The spaceUUID parameter is equal to the identifier of the default space in this context, then the default space is returned by this function.
Parameters:
<S> - - type of the replied space.
spaceUUID - identifier of the space.
spec - specification of the space for creating the space.
creationParams - parameters to pass to the space constructor.
Returns:
the space, never null .
Since:
0.6
See:
getOrCreateSpaceWithID(UUID,Class<T>,Object*) , createSpace(Class<T>,UUID,Object*) , getSpace(UUID)
getOrCreateSpaceWithID(UUID,Class<T>,Object*)
def getOrCreateSpaceWithID(UUID,Class<T>,Object*) : S

with S extends Space

Retrieve or create an instance of space with the given identifier.

This function tries to find a space with the given identifier. If none was found, this function creates a new space with the given specification and creation parameters.

Caution #1: The spaceUUID parameter is given to the specification when creating the space.

Caution #2: The spaceUUID parameter is equal to the identifier of the default space in this context, then the default space is returned by this function.
Parameters:
<S> - - type of the replied space.
spaceUUID - identifier of the space.
spec - specification of the space for creating the space.
creationParams - parameters to pass to the space constructor.
Returns:
the space, never null .
Deprecated:
see getOrCreateSpaceWithID(Class, UUID, Object...)
See:
getOrCreateSpaceWithID(UUID,Class<T>,Object*) , createSpace(Class<T>,UUID,Object*) , getSpace(UUID)
getOrCreateSpaceWithSpec(Class<T>,UUID,Object*)
def getOrCreateSpaceWithSpec(Class<T>,UUID,Object*) : S

with S extends Space

Retrieve or create an instance of space which was created with the given specification.

This function tries to find a space that was created with the given specification. If none was found, this function creates a new space with the given space identifier and creation parameters.

Caution: This function ignores the default space when searching for a space created with an EventSpaceSpecification or OpenEventSpaceSpecification. Consequently, in the case of the spec argument is one of the previous types, and there is no other space in the context that was created with this specification, then the function creates a totally new space.

Caution: The spaceUUID parameter is used only if no existing space created with the given specification was found.
Parameters:
<S> - - type of the replied space.
spec - specification of the space to retrieve/create.
spaceUUID - identifier used only when creating the space.
creationParams - parameters to pass to the space constructor.
Returns:
the space, never null and never the default space.
See:
getOrCreateSpaceWithID(UUID,Class<T>,Object*) , createSpace(Class<T>,UUID,Object*) , getSpace(UUID)
getSpace(UUID)
def getSpace(UUID) : S

with S extends Space

Retrieve, but do not create, an instance of space following the given ID. This function tries to find a space that fits the given specification. If none was found, this function replies null.
Parameters:
<S> - - type of the replied space.
spaceUUID - identifier of the space.
Returns:
the space, or null if there is no space found.
See:
createSpace(Class<T>,UUID,Object*) , getOrCreateSpace(Class<T>,UUID,Object*)
getSpaces
def getSpaces : ConcurrentCollection<T>
Replies all the spaces defined in this context.
Returns:
the spaces.
getSpaces(Class<T>)
def getSpaces(Class<T>) : ConcurrentCollection<T>

with S extends Space

Replies all the spaces that are implementing the given specification.
Parameters:
<S> - - type of the replied space.
spec - specification of the space to retreive.
Returns:
the spaces associated to the given space specification.
isRootContext
def isRootContext : boolean
Replies if the context is a root context.

A root context is associated to the platform kernel agent, which is not created into memory. For example, it means that there is no parent registered into the default space.
Returns:
true if the context is a root context.
Since:
0.12