diff --git a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentJava.spec b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentJava.spec
index 037f8c04ee..837addd3ac 100644
--- a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentJava.spec
+++ b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentJava.spec
@@ -71,7 +71,6 @@ describe "Run SARL Agent from a Java Program" {
class MyProgram {
static def main(args : String[]) : void {
Boot::startJanus(
- null,
typeof(MyAgent),
args)
}
@@ -107,7 +106,6 @@ describe "Run SARL Agent from a Java Program" {
class MyProgram {
static def main(args : String[]) : void {
var janusKernel = Boot::startJanus(
- null,
typeof(MyAgent),
args)
janusKernel.spawn(typeof(MyAgent), args)
diff --git a/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/Boot.java b/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/Boot.java
index c6425c2a3a..8527fc4604 100644
--- a/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/Boot.java
+++ b/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/Boot.java
@@ -404,7 +404,7 @@ private static Class extends Agent> loadAgentClass(String fullyQualifiedName)
* Main function that is parsing the command line and launching the first agent.
*
* @param args - command line arguments
- * @see #startJanus(Class, Class, Object...)
+ * @see #startJanus(Class, Object...)
*/
public static void main(String[] args) {
try {
@@ -428,7 +428,7 @@ public static void main(String[] args) {
final Class extends Agent> agent = loadAgentClass(agentToLaunch);
assert agent != null;
- startJanus((Class extends Module>) null, (Class extends Agent>) agent, freeArgs);
+ startJanus(agent, freeArgs);
} catch (ChuckNorrisException exception) {
// Be silent
return;
@@ -802,12 +802,12 @@ public static void setPropertiesFrom(File propertyFile) throws IOException {
/**
* Replies the identifier of the boot agent from the system's properties. The boot agent is launched with
- * {@link #startJanus(Class, Class, Object...)}.
+ * {@link #startJanus(Class, Object...)}.
*
* @return the identifier of the boot agent, or null
if it is unknown.
* @since 2.0.2.0
* @see JanusConfig#BOOT_AGENT_ID
- * @see #startJanus(Class, Class, Object...)
+ * @see #startJanus(Class, Object...)
*/
public static UUID getBootAgentIdentifier() {
final String id = JanusConfig.getSystemProperty(JanusConfig.BOOT_AGENT_ID);
@@ -821,6 +821,31 @@ public static UUID getBootAgentIdentifier() {
return null;
}
+ /**
+ * Launch the Janus kernel and the first agent in the kernel.
+ *
+ *
Thus function does not parse the command line. See {@link #main(String[])} for the command line management. When this + * function is called, it is assumed that all the system's properties are correctly set. + * + *
The platformModule parameter permits to specify the injection module to use. The injection module is in change of + * creating/injecting all the components of the platform. The default injection module is retreived from the system property + * with the name stored in {@link JanusConfig#INJECTION_MODULE_NAME}. The default type for the injection module is stored in + * the constant {@link JanusConfig#INJECTION_MODULE_NAME_VALUE}. + * + *
The function {@link #getBootAgentIdentifier()} permits to retreive the identifier of the launched agent. + * + * @param agentCls - type of the first agent to launch. + * @param params - parameters to pass to the agent as its initliazation parameters. + * @return the kernel that was launched. + * @throws Exception - if it is impossible to start the platform. + * @see #main(String[]) + * @see #getBootAgentIdentifier() + */ + public static Kernel startJanus(Class extends Agent> agentCls, Object... params) + throws Exception { + return startJanusWithModuleType(null, agentCls, params); + } + /** * Launch the Janus kernel and the first agent in the kernel. * @@ -840,10 +865,11 @@ public static UUID getBootAgentIdentifier() { * @param params - parameters to pass to the agent as its initliazation parameters. * @return the kernel that was launched. * @throws Exception - if it is impossible to start the platform. + * @since 0.5 * @see #main(String[]) * @see #getBootAgentIdentifier() */ - public static Kernel startJanus(Class extends Module> platformModule, Class extends Agent> agentCls, Object... params) + public static Kernel startJanusWithModuleType(Class extends Module> platformModule, Class extends Agent> agentCls, Object... params) throws Exception { Class extends Module> startupModule = platformModule; if (startupModule == null) { @@ -851,7 +877,7 @@ public static Kernel startJanus(Class extends Module> platformModule, Class JanusConfig.INJECTION_MODULE_NAME_VALUE); } assert startupModule != null : "No platform injection module"; //$NON-NLS-1$ - return startJanus(startupModule.newInstance(), agentCls, params); + return startJanusWithModule(startupModule.newInstance(), agentCls, params); } /** @@ -872,10 +898,11 @@ public static Kernel startJanus(Class extends Module> platformModule, Class * @param params - parameters to pass to the agent as its initliazation parameters. * @return the kernel that was launched. * @throws Exception - if it is impossible to start the platform. + * @since 0.5 * @see #main(String[]) * @see #getBootAgentIdentifier() */ - public static Kernel startJanus(Module startupModule, Class extends Agent> agentCls, Object... params) throws Exception { + public static Kernel startJanusWithModule(Module startupModule, Class extends Agent> agentCls, Object... params) throws Exception { // Set the boot agent classname System.setProperty(JanusConfig.BOOT_AGENT, agentCls.getName()); // Get the start-up injection module diff --git a/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/BootTest.java b/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/BootTest.java index 49dd1895a3..0f89f0252f 100644 --- a/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/BootTest.java +++ b/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/BootTest.java @@ -1042,7 +1042,7 @@ public static class StartTests extends AbstractJanusTest { @Test public void startJanus() throws Exception { - Kernel kernel = Boot.startJanus(TestModule.class, AgentMock.class, "param1", "param2", "param3"); + Kernel kernel = Boot.startJanusWithModuleType(TestModule.class, AgentMock.class, "param1", "param2", "param3"); assertNotNull(kernel); @@ -1075,13 +1075,13 @@ public void getBootAgentIdentifier_notStarted() throws Exception { @Test public void getBootAgentIdentifier_started() throws Exception { - Boot.startJanus(TestModule.class, AgentMock.class); + Boot.startJanusWithModuleType(TestModule.class, AgentMock.class); assertEquals(ID, Boot.getBootAgentIdentifier()); } @Test public void getBootAgentIdentifier_startedAgain() throws Exception { - Boot.startJanus(TestModule.class, AgentMock.class); + Boot.startJanusWithModuleType(TestModule.class, AgentMock.class); assertEquals(ID, Boot.getBootAgentIdentifier()); assertEquals(ID, Boot.getBootAgentIdentifier()); } diff --git a/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/testutils/AbstractJanusRunTest.java b/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/testutils/AbstractJanusRunTest.java index 868fa63bb7..5cde844e8c 100644 --- a/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/testutils/AbstractJanusRunTest.java +++ b/sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/testutils/AbstractJanusRunTest.java @@ -265,7 +265,7 @@ public void write(byte[] b, int off, int len) throws IOException { module = Modules.override(new StandardJanusPlatformModule()).with(new ErrorLogTestingModule(this.results)); } Boot.setOffline(offline); - this.janusKernel = Boot.startJanus(module, type, getAgentInitializationParameters()); + this.janusKernel = Boot.startJanusWithModule(module, type, getAgentInitializationParameters()); Logger current = this.janusKernel.getLogger(); while (current.getParent() != null && current.getParent() != current) { current = current.getParent();