public final class Madkit extends Object
AgentAddress
for more information.withRole
version of all the messaging methods has been
added. See AbstractAgent.sendMessageWithRole(AgentAddress, Message, String)
for an example of such a
method.SendReply
methods. It enables the agent with
the possibility of replying directly to a given message. Also, it is now possible to get the reply to a message, or
to wait for a reply ( for Agent
subclasses only as they are threaded) See
AbstractAgent.sendReply(Message, Message)
for more details.AbstractAgent.getState()
method
for detailed information.AbstractAgent.getLogger()
for more details.Modifier and Type | Class and Description |
---|---|
static class |
Madkit.BooleanOption
Option used to activate or disable features on startup.
|
static class |
Madkit.LevelOption
MaDKit options valued with a string representing a
Level value. |
static class |
Madkit.Option
MaDKit options which are valued with a string representing parameters.
|
Modifier and Type | Field and Description |
---|---|
static String |
BUILD_ID |
static String |
VERSION |
static String |
WEB |
Constructor and Description |
---|
Madkit(String... options)
Launch a new kernel with predefined options.
|
Modifier and Type | Method and Description |
---|---|
void |
doAction(KernelAction action,
Object... parameters)
Makes the kernel do the corresponding action.
|
static void |
main(String[] options)
This main could be used to launch a new kernel using predefined options.
|
String |
toString() |
public static final String VERSION
public static final String BUILD_ID
public static final String WEB
public Madkit(String... options)
Here is an example of use:
public void somewhereInYourCode() { new Madkit(Option.launchAgents.toString(), // gets the --launchAgents string Client.class.getName() + ",true,20;" + Broker.class.getName() + ",true,10;" + Provider.class.getName() + ",false,20"); }
options
- the options which should be used to launch Madkit. If null
, the dektop mode is automatically
used.Madkit.Option
,
Madkit.BooleanOption
,
Madkit.LevelOption
public static void main(String[] options)
public static void main(String[] options) { new Madkit(options); }So, this main can be used as a MAS application entry point in two ways :
(1) From the command line:
For instance, assuming that your classpath is already set correctly:
>java madkit.kernel.Madkit agentLogLevel INFO --launchAgents madkit.marketorg.Client,20,true;madkit.marketorg.Broker,10,true;madkit.marketorg.Provider,20,true;
(2) It can be used programmatically anywhere, especially within main method of agent classes to ease their launch within an IDE.
Here is an example of how it can be used in this way:
public static void main(String[] args) { String[] argss = { LevelOption.agentLogLevel.toString(), "FINE", Option.launchAgents.toString(), // gets the -- launchAgents string Client.class.getName() + ",true,20;" + Broker.class.getName() + ",true,10;" + Provider.class.getName() + ",false,20" }; Madkit.main(argss);// launching the application }
options
- the options which should be used to launch Madkit: see Madkit.LevelOption
, Madkit.BooleanOption
and
Madkit.Option
public void doAction(KernelAction action, Object... parameters)
public void somewhereInYourCode() { ... Madkit m = new Madkit(args); ... m.doAction(KernelAction.LAUNCH_NETWORK); //start the network ... m.doAction(KernelAction.LAUNCH_AGENT, new Agent(), true); //launch a new agent with a GUI ... }
action
- the action to requestparameters
- the parameters of the request. To work properly, the actual class of the parameters should match the class
of the parameters of the underlying targeted method. For instance, for launching an Agent, one must use
m.doAction(KernelAction.LAUNCH_AGENT, new Agent(),Boolean.TRUE);
That is, in this case, using
"true" does not work since it is a String.
Fabien Michel, Olivier Gutknecht, Jacques Ferber - July 18 2017