public class SreMain extends Object implements SREBootstrap
Modifier and Type | Method and Description |
---|---|
void |
addSREListener(listener : SREListener)
Add an observer on the SRE.
|
protected io.bootique.BQRuntime |
createRuntime(bootique : io.bootique.Bootique,
module : Class<? extends com.google.inject.Module>,
args : String*)
Create the SRE runtime.
|
static String[] |
filterCommandLineArguments(args : String[])
Filter the command-line arguments for extracting the -D parameters.
|
protected void |
fireSREStarted()
Notifies the observers that the SRE has been started.
|
protected void |
fireSREStopped()
Notifies the observers that the SRE has been stopped.
|
Kernel |
getKernel()
Replies the reference to the kernel.
|
Logger |
getKernelLogger()
Replies the logger used by the SRE.
|
io.bootique.BQRuntime |
getRuntime() |
<T> T |
getService(serviceType : Class<T>)
Replies the service of the given type that is implemented into the SRE.
|
UUID |
getUniverseContextUUID()
Replies the UUID of the root/universe context that is given by the user of the bootstrap.
|
UUID |
getUniverseSpaceUUID()
Replies the UUID of the root/universe default space that is given by the user of the bootstrap.
|
boolean |
isRunning()
Replies if the kernel is running.
|
void |
removeSREListener(listener : SREListener)
Remove the given observer on the SRE.
|
int |
runSRE(args : String*)
Run the SRE.
|
void |
setBootAgentTypeContextUUID()
Force the SRE platform to use a default context identifier that is build upon the classname of the boot agent.
|
void |
setCommandLineArguments(commandLineArguments : String[])
Specify arguments that should be used by the SRE as command-line arguments.
|
void |
setRandomContextUUID()
Force the SRE platform to use a random identifier for its default context.
|
boolean |
setRuntime(runtime : io.bootique.BQRuntime)
Set the Bootique runtime instance.
|
void |
setSpecificContextUUID()
Force the SRE platform to use the identifier hard-coded in the source code for its default context.
|
void |
setUniverseContextUUID(id : UUID)
Force the identifier of the root/universe context in case the SRE is run when the
default
identifier mode is enabled . |
void |
setUniverseSpaceUUID(id : UUID)
Force the identifier of the root/universe default space in case the SRE is run when the
default
identifier mode is enabled . |
void |
setVerboseLevel(level : int)
Force the verbosity level.
|
void |
shutdown(timeout : int)
Stop the SRE.
|
void |
startAgent(agentCls : Class<? extends Agent>,
params : Object*)
Launch the SRE and the first agent in the kernel.
|
void |
startAgent(nbAgents : int,
agentCls : Class<? extends Agent>,
params : Object*)
Launch the SRE and the first agent in the kernel.
|
void |
startAgentWithID(agentCls : Class<? extends Agent>,
agentID : UUID,
params : Object*)
Launch the SRE and the first agent in the kernel and assigning a specific UUID.
|
void |
startBootAgent()
Start the boot agent if it is specified in the boot configuration.
|
AgentContext |
startWithoutAgent(asCommandLineApp : boolean,
[bootique : io.bootique.Bootique],
[module : Class<? extends com.google.inject.Module>])
Start the agent framework without agent.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isActive, setOffline, shutdown, shutdown, startWithoutAgent, startWithoutAgent
@Pure
public def
getKernel() : Kernel
SreMain
public def
setRuntime(runtime : io.bootique.BQRuntime) : boolean
SreMain
runtime
- the new Bootique runtime.true
if the runtime has been changed.@Pure
public def
isRunning() : boolean
SREBootstrap
isRunning
in interface SREBootstrap
true
if the kernel is running. false
is replied
if the kernel was stopped.public def
setRandomContextUUID() : void
SREBootstrap
This function has no effect if the agent framework is already launched.
setRandomContextUUID
in interface SREBootstrap
public def
setBootAgentTypeContextUUID() : void
SREBootstrap
This function has no effect if the agent framework is already launched.
setBootAgentTypeContextUUID
in interface SREBootstrap
public def
setSpecificContextUUID() : void
SREBootstrap
This function has no effect if the agent framework is already launched.
public def
setUniverseContextUUID(id : UUID) : void
SREBootstrap
default
identifier mode is enabled
.
This function has no effect if the agent framework is already launched.
setUniverseContextUUID
in interface SREBootstrap
id
- the identifier, or null
if the default identifier should be used.@Pure
public def
getUniverseContextUUID() : UUID
SREBootstrap
This function has no effect if the agent framework is already launched.
getUniverseContextUUID
in interface SREBootstrap
null
if no identifier is provided by the user and the default identifier should be used.public def
setUniverseSpaceUUID(id : UUID) : void
SREBootstrap
default
identifier mode is enabled
.
This function has no effect if the agent framework is already launched.
setUniverseSpaceUUID
in interface SREBootstrap
id
- the identifier, or null
if the default identifier should be used.@Pure
public def
getUniverseSpaceUUID() : UUID
SREBootstrap
This function has no effect if the agent framework is already launched.
getUniverseSpaceUUID
in interface SREBootstrap
null
if no identifier is provided by the user and the default identifier should be used.public def
setVerboseLevel(level : int) : void
SREBootstrap
This function may have no effect if the agent framework is already launched. This depends on the implementation of the SRE.
The value of the level
argument does not depend on a specific logging infrastructure.
Indeed, JUL, Log4J and SLF4J attach different numeric values to the different logging levels.
Consequently, the numerical values that are assummed by this function are:
<= 0
: off, no logging.= 1
: errors only.= 2
: errors and warnings.= 3
: errors, warnings and info.= 4
: errors, warnings, info, debug 1.= 5
: errors, warnings, info, debug 1 to 2.= 6
: errors, warnings, info, debug 1 to 3.= 7
: all messages.setVerboseLevel
in interface SREBootstrap
level
- the verbosity level. See explanation in the documentation of this function.@Pure
public def
getKernelLogger() : Logger
SREBootstrap
This function replies a not null
value only if the kernel was launched.
getKernelLogger
in interface SREBootstrap
null
if the kernel was not launched or has no logger.protected def
createRuntime(bootique : io.bootique.Bootique,
module : Class<? extends com.google.inject.Module>,
args : String*) : io.bootique.BQRuntime
SreMain
bootique
- the instance of the bootique accessor, or null
if none is provided.module
- specify the type of the injection module to be used by the bootique accessor.args
- the command line arguments to put into the bootique accessor. This argument is used only if bootique
is evaluated to null
.public static def
filterCommandLineArguments(args : String[]) : String[]
SreMain
args
- the arguments.public def
runSRE(args : String*) : int
SreMain
This function runs the SRE and exits with the return code.
args
- the command line arguments.public def
startWithoutAgent(asCommandLineApp : boolean,
[bootique : io.bootique.Bootique],
[module : Class<? extends com.google.inject.Module>]) : AgentContext
SreMain
asCommandLineApp
- indicates if the application should be started as a commend-line application.
If true
, the SRE is started and run directly. Then, the "start agent" functions becomes
unusable because the SRE has started everything as it is called from the shell command line.
If false
, the SRE is started in is normal way and all the functions are available according
to their own specifications.
If it not recommended to invoke this function with this argument evaluated to true
.bootique
- the Bootique instance to set up the framework. If it is null
,
the default Bootique instance is created.module
- the injection module to use. If it is null
, the default module is used.public def
startAgent(nbAgents : int,
agentCls : Class<? extends Agent>,
params : Object*) : void
SREBootstrap
The function #getBootAgentIdentifier()
permits to retrieve the identifier of the first launched agent.
startAgent
in interface SREBootstrap
nbAgents
- the number of agents to be launched.agentCls
- type of the first agent to launch.params
- parameters to pass to the agent as its initialization parameters.#getBootAgentIdentifier()
public def
startBootAgent() : void
SreMain
public def
startAgent(agentCls : Class<? extends Agent>,
params : Object*) : void
SREBootstrap
The function #getBootAgentIdentifier()
permits to retrieve the identifier of the first launched agent.
startAgent
in interface SREBootstrap
agentCls
- type of the first agent to launch.params
- parameters to pass to the agent as its initialization parameters.#getBootAgentIdentifier()
public def
startAgentWithID(agentCls : Class<? extends Agent>,
agentID : UUID,
params : Object*) : void
SREBootstrap
startAgentWithID
in interface SREBootstrap
agentCls
- type of the first agent to launch.agentID
- the identifier of the agent to be created.params
- parameters to pass to the agent as its initialization parameters.public def
shutdown(timeout : int) : void
SREBootstrap
shutdown
in interface SREBootstrap
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
.SREBootstrap.shutdown()
,
SREBootstrap.shutdown(boolean)
,
SREBootstrap.shutdown(int)
@Pure publicdef
getService(serviceType : Class<T>) : Twith
<T>
SREBootstrap
getService
in interface SREBootstrap
T
- the type of the service.serviceType
- the type of the service.null
if the SRE does not have any instance of service of the given type.public def
addSREListener(listener : SREListener) : void
SREBootstrap
addSREListener
in interface SREBootstrap
listener
- the observer to add.public def
removeSREListener(listener : SREListener) : void
SREBootstrap
removeSREListener
in interface SREBootstrap
listener
- the observer to remove.protected def
fireSREStarted() : void
SreMain
protected def
fireSREStopped() : void
SreMain
@Pure
public def
getRuntime() : io.bootique.BQRuntime
public def
setCommandLineArguments(commandLineArguments : String[]) : void
SREBootstrap
setCommandLineArguments
in interface SREBootstrap
commandLineArguments
- the command-line arguments.Copyright © 2021 the original authors or authors.