@Singleton public class Kernel extends Object
The Kernel is a singleton.
The Kernel is assimilated to an agent that is omniscient and distributed other the network. It is containing all the other agents.
Modifier and Type | Class and Description |
---|---|
protected static class |
Kernel.AsynchronousKernelStoppingListener
Asynchronous listener on platform events.
|
Constructor and Description |
---|
Kernel(serviceManager : javax.inject.Provider<IServiceManager>,
exceptionHandler : javax.inject.Provider<Thread.UncaughtExceptionHandler>,
configuration : javax.inject.Provider<SreConfig>,
factories : javax.inject.Provider<Factories>)
Constructs a SRE kernel.
|
Modifier and Type | Method and Description |
---|---|
protected Kernel.AsynchronousKernelStoppingListener |
createKernelListener()
Create an instance of the kernel event listener.
|
SreConfig |
getConfiguration() |
Logger |
getLogger()
Replies the logger used by the kernel.
|
AgentContext |
getRootContext()
Replies the SRE context of the kernel.
|
<S extends com.google.common.util.concurrent.Service> |
getService(type : Class<S>)
Replies a kernel service that is alive.
|
boolean |
isRunning()
Replies if the kernel is running or not.
|
void |
shutdown([timeout : int])
Shutdown the kernel.
|
void |
spawn(agent : Class<? extends Agent>,
arguments : Object*)
Spawn an agent of the given type, and pass the parameters to its initialization function.
|
void |
spawn(nbAgents : int,
agent : Class<? extends Agent>,
params : Object*)
Spawn agents of the given type, and pass the parameters to its initialization function.
|
void |
spawn(agentID : UUID,
agent : Class<? extends Agent>,
params : Object*)
Spawn an agent of the given type, and pass the parameters to its initialization function.
|
@Inject
public new
(serviceManager : javax.inject.Provider<IServiceManager>,
exceptionHandler : javax.inject.Provider<Thread.UncaughtExceptionHandler>,
configuration : javax.inject.Provider<SreConfig>,
factories : javax.inject.Provider<Factories>)
serviceManager
- is the instance of the service manager that must be used by the kernel.
The service manager must already have registered services inside itself.exceptionHandler
- is the handler of the uncaught exceptions.configuration
- is the provider of SRE configuration.factories
- is the provider of the factories tool.@Pure
protected def
createKernelListener() : Kernel.AsynchronousKernelStoppingListener
Kernel
@Pure
public def
isRunning() : boolean
Kernel
The kernel is running if at least one agent is alive.
true
if the kernel is running; false
otherwise.@Pure
public def
getLogger() : Logger
Kernel
This function replies the logger of the logging service. If this service is down,
null
is replied.
public def
spawn(agent : Class<? extends Agent>,
arguments : Object*) : void
Kernel
agent
- the type of the agent to spawn.arguments
- the list of the parameters to pass to the agent initialization function.public def
spawn(nbAgents : int,
agent : Class<? extends Agent>,
params : Object*) : void
Kernel
nbAgents
- the number of agents to spawn.agent
- the type of the agents to spawn.params
- the list of the parameters to pass to the agent initialization function.public def
spawn(agentID : UUID,
agent : Class<? extends Agent>,
params : Object*) : void
Kernel
agentID
- the identifier of the agent to spawn. If null
the identifier is randomly selected.agent
- the type of the agent to spawn.params
- the list of the parameters to pass to the agent initialization function.@Pure publicdef
getService(type : Class<S>) : Swith
<S extends com.google.common.util.concurrent.Service>
Kernel
S
- - type of the type to reply.type
- type of the type to reply.null
.@Pure
public def
getRootContext() : AgentContext
Kernel
public def
shutdown([timeout : int]) : void
Kernel
timeout
- the maximum amount of milliseconds to wait for the shutdown.
If the provided value is strictly positive, it is the number of milliseconds
to wait for the termination of the shutdown. If the provided value is equal
to 0
, the function returns as soon as the shutdown process is launch
(no waiting for the termination of the shutdown). If the value is strictly
negative, the function waits forever for the termination of the shutdown
process. The default value is -1
.@Pure
public def
getConfiguration() : SreConfig
Copyright © 2021 the original authors or authors.