Class Madkit

java.lang.Object
madkit.kernel.Madkit

public class Madkit extends Object
  • Constructor Details

    • Madkit

      public Madkit(String... args)
      Constructs a `Madkit` instance with the specified command-line arguments.
      Parameters:
      args - the command-line arguments
  • Method Details

    • launchAgent

      public void launchAgent(Agent a)
      Launches the specified agent.
      Parameters:
      a - the agent to launch
    • doAction

      public void doAction(KernelAction action, Object... parameters)
      Makes the kernel do the corresponding action. This is done by sending a message directly to the kernel agent. This should not be used intensively since it is better to control the execution flow of the application using the agents running in the kernel. Still it provides a way to launch and manage a kernel from any java application as a third party service.
      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
                                      ...
      }
      
      Parameters:
      action - the action to request
      parameters - 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.
    • exit

      public void exit()
      Requests the kernel to exit. This will terminate all agents and then the kernel itself. This returns only when the kernel has effectively terminated or after a timeout of 20 seconds.
    • getConfig

      public KernelConfig getConfig()
      Returns the kernel configuration.
      Returns:
      the kernel configuration
    • main

      public static void main(String[] args)
      The main method for the MaDKit platform.
      Parameters:
      args - the command-line arguments