Skip to content

Commit

Permalink
[docs] Update the documentation according to the novel SRE implementa…
Browse files Browse the repository at this point in the history
…tion.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Feb 16, 2020
1 parent 48ed53c commit 007e574
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 228 deletions.
Expand Up @@ -44,7 +44,7 @@ In the following example, the [:myspacename:] space is declared:
[:Success:]
import io.sarl.lang.core.Space
import io.sarl.lang.core.SpaceID
import io.sarl.lang.util.SynchronizedSet
import java.util.concurrent.ConcurrentSkipListSet
import java.util.UUID
abstract [:On]
class [:myspacename](MySpace) implements [:spacetype](Space) {
Expand All @@ -59,7 +59,7 @@ In the following example, the [:myspacename:] space is declared:
this.id
}

def getParticipants : SynchronizedSet<UUID> {
def getParticipants : ConcurrentSkipListSet<UUID> {
null
}

Expand All @@ -75,7 +75,7 @@ Back to the example, the code becomes:
[:Success:]
import io.sarl.lang.core.Space
import io.sarl.lang.core.SpaceID
import io.sarl.lang.util.SynchronizedSet
import java.util.concurrent.ConcurrentSkipListSet
import java.util.UUID
abstract [:On]
class [:myspacename](MySpace) implements [:spacetype](Space) {
Expand All @@ -94,7 +94,7 @@ Back to the example, the code becomes:
this.id
}

def getParticipants : SynchronizedSet<UUID> {
def getParticipants : ConcurrentSkipListSet<UUID> {
null
}

Expand All @@ -108,7 +108,7 @@ In order to enable the creation of an instance of [:myspacename!], a space speci
import io.sarl.lang.core.Space
import io.sarl.lang.core.SpaceID
import io.sarl.lang.core.SpaceSpecification
import io.sarl.lang.util.SynchronizedSet
import java.util.concurrent.ConcurrentSkipListSet
import java.util.UUID
class [:myspacename!] implements [:spacetype!] {
def [:fctname!](callerIdentity : UUID, parameter : Object) {
Expand All @@ -119,7 +119,7 @@ In order to enable the creation of an instance of [:myspacename!], a space speci
}
def getID : SpaceID {
}
def getParticipants : SynchronizedSet<UUID> {
def getParticipants : ConcurrentSkipListSet<UUID> {
}
}
[:On]
Expand All @@ -144,7 +144,7 @@ Back to the example, the code for the skill is:
import io.sarl.lang.core.Space
import io.sarl.lang.core.SpaceID
import io.sarl.lang.core.SpaceSpecification
import io.sarl.lang.util.SynchronizedSet
import java.util.concurrent.ConcurrentSkipListSet
import java.util.UUID
capacity [:mycapacityname!] {
def [:fctname!](parameter : Object)
Expand All @@ -158,7 +158,7 @@ Back to the example, the code for the skill is:
}
def getID : SpaceID {
}
def getParticipants : SynchronizedSet<UUID> {
def getParticipants : ConcurrentSkipListSet<UUID> {
}
}
class [:myspacespecname]([:myspacename!]Specification) implements SpaceSpecification<[:myspacename!]> {
Expand Down Expand Up @@ -207,7 +207,7 @@ to give the instance of the caller to the space. The code of the skill becomes:
import io.sarl.lang.core.Space
import io.sarl.lang.core.SpaceID
import io.sarl.lang.core.SpaceSpecification
import io.sarl.lang.util.SynchronizedSet
import java.util.concurrent.ConcurrentSkipListSet
import java.util.UUID
capacity [:mycapacityname!] {
def [:fctname!](parameter : Object)
Expand All @@ -221,7 +221,7 @@ to give the instance of the caller to the space. The code of the skill becomes:
}
def getID : SpaceID {
}
def getParticipants : SynchronizedSet<UUID> {
def getParticipants : ConcurrentSkipListSet<UUID> {
}
}
[:On]
Expand Down
Expand Up @@ -58,8 +58,8 @@ boot class in a Java Virtual Machine.
The typical command line is:


java [:cpcli](-cp) [:jarfile](app.jar) [:fullbootclass]{io.janusproject.[:bootclass](Boot)}
[:Fact:](io.janusproject.Boot)
java [:cpcli](-cp) [:jarfile](app.jar) [:fullbootclass]{io.sarl.sre.boot.[:bootclass](Boot)}
[:Fact:](io.sarl.sre.boot.Boot)


The option [:cpcli:] specifies the Jar file that contains
Expand All @@ -74,7 +74,7 @@ The example given in the previous section causes an error. Indeed, it is mandato
specify the fully qualified name of the agent to launch:


java -cp app.jar io.janusproject.Boot myapp.MyAgent
java -cp app.jar [:fullbootclass!] myapp.MyAgent


<veryimportant>The Janus platform allows to start only one agent from the command line.
Expand All @@ -95,7 +95,7 @@ that is containing all the jar files required for running your application, incl
the Janus jar file(s):


java -cp /path/to/myapplication.jar:/path/to/[:janusjarfile](io.janusproject.kernel-<version>-with-dependencies.jar) io.janusproject.Boot myapp.MyAgent
java -cp /path/to/myapplication.jar:/path/to/[:janusjarfile](io.janusproject.kernel-<version>-with-dependencies.jar) [:fullbootclass!] myapp.MyAgent

The [:janusjarfile:] file may be dowloaded from the [Janus website](http://www.janusproject.io/)

Expand All @@ -108,7 +108,7 @@ The Janus platform provides a collection of command line options.
For obtaining the list of these options, you should type:


java -cp app.jar io.janusproject.Boot --help
java -cp app.jar [:fullbootclass!] --help


## Use Maven Execution Plugin
Expand All @@ -124,10 +124,10 @@ you may use the Maven execution plugin for classing this booting class.
The typical command line is:


mvn exec:exec [:mavencliexec](-Dexec.executable)=java [:mavencliargs](-Dexec.args)="-cp %classpath io.janusproject.Boot"
mvn exec:exec [:mavencliexec](-Dexec.executable)=java [:mavencliargs](-Dexec.args)="-cp %classpath [:fullbootclass!]"


[:Fact:](io.janusproject.Boot)
[:Fact:](io.sarl.sre.boot.Boot)

The option [:mavencliexec:] specifies the Java executable.

Expand All @@ -143,7 +143,7 @@ Indeed, it is mandatory to specify the fully qualified name
of the agent to launch:


mvn exec:exec -Dexec.executable=java -Dexec.args="-cp %classpath io.janusproject.Boot <qualified_name_of_the_agent>"
mvn exec:exec -Dexec.executable=java -Dexec.args="-cp %classpath [:fullbootclass!] <qualified_name_of_the_agent>"


<veryimportant>The Janus platform allows to start only one agent from the command line.
Expand All @@ -161,7 +161,7 @@ The Janus platform provides a collection of command line options.
For obtaining the list of these options, you should type:


mvn exec:exec -Dexec.executable=java -Dexec.args="-cp %classpath io.janusproject.Boot --help"
mvn exec:exec -Dexec.executable=java -Dexec.args="-cp %classpath [:fullbootclass!] --help"



Expand Down
Expand Up @@ -108,66 +108,40 @@ pass with the [:initevent:] event to the launched agent.
If you want to launch more agents, please read the next section.</importantnote>

[:Success:]
import io.janusproject.Boot
import io.sarl.sre.boot.Boot
import myprogram.MyAgent
class MyProgram {
static def main(args : String*) {
[:boot](Boot)::[:startjanus](startJanus)(
[:boot](Boot)::createMainObject.[:startjanus](startAgent)(
typeof([:agenttype]{MyAgent}),
args)
}
}
[:End:]
import io.janusproject.Boot;
import io.sarl.sre.boot.Boot;
import myprogram.MyAgent;
public class MyProgram {
public static void main(String[] args) {
[:boot!].[:startjanus!]([:agenttype!].class, args);
[:boot!].createMainObject.[:startjanus!]([:agenttype!].class, args);
}
}


In the case you want to launch more than one agent programmatically,
you could use the [:kernel:] instance provided by Janus.
[:Fact:]{io.janusproject.kernel.[:kernel](Kernel)}
This instance is replied by the [:startjanus:] function of the [:boot:] class.

The [:kernel:] type provides the [:spawn:] functions, which permit launching
an agent programmatically.

The previous example could be updated for launching two agents of the same type.
The resulting code is shown below.

The first parameter of the [:spawn:] function is the Java type of the agent to launch.

The second parameter of the [:spawn:] function is the list of parameters to
pass with the [:initevent] event to the launched agent.

<important>that the first agent is launched by the [:startjanus:] function, and the
second agent is launched by the [:spawn:] function.</important>

This instance is replied by the [:getkernel:] function of the [:boot:] class.

[:Success:]
import io.janusproject.Boot
[:Off]
import io.sarl.sre.boot.Boot
import io.sarl.sre.boot.[:kernel](SreMain)
class MyProgram {
static def main(args : String*) {
var janusKernel = Boot::startJanus(
typeof(MyAgent),
args)
janusKernel.[:spawn]{spawn}(typeof(MyAgent), args)
def fct : void {
var sremain = Boot.createMainObject
var kernel = sremain.[:getkernel](getKernel)
}
}
[:Off]
agent MyAgent {}
[:End:]
import io.janusproject.Boot;
import myprogram.MyAgent;
public class MyProgram {
public static void main(String[] args) {
[:boot!].[:startjanus!]([:agenttype!].class, args);
janusKernel.[:spawn!](MyAgent.class, args);
}
}


## What's next?
Expand Down

0 comments on commit 007e574

Please sign in to comment.