Contents

Scripted Agents with Janus

Since version 0.5, the Janus platform provides the ability to code the agents with scripting languages. Scripting languages permits to use Janus for people who do not want to code in Java programming language. Moreover, scripting languages permits to dynamically build programs for the agents.


Most scripting languages are dynamically typed. You can usually create new variables without predetermining the variable type, and you can reuse variables to store values of different types. Also, scripting languages tend to perform many type conversions automatically, for example, converting the number 10 to the text "10" as necessary. Although some scripting languages are compiled, most languages are interpreted. Script environments generally perform the script compilation and execution within the same process. Usually, these environments also parse and compile scripts into intermediate code when they are first executed.


These qualities of scripting languages help you write applications faster, execute commands repeatedly, and tie together components from different technologies. Special-purpose scripting languages can perform specific tasks more easily or more quickly than can more general-purpose languages. For example, many developers think that the Perl scripting language is a great way to process text and to generate reports. Other developers use the scripting languages available in bash or ksh command shells for both command and job control. Other scripting languages help to define user interfaces or web content conveniently. Developers might use the Java programming language and platform for any of these tasks, but scripting languages sometimes perform the job as well or better. This fact doesn't detract from the power and richness of the Java platform but simply acknowledges that scripting languages have an important place in the developer's toolbox.


Combining scripting languages with the Janus platform provides to the developers an opportunity to leverage the abilities of both environments. You can continue to use scripting languages for all the reasons you already have, and you can use the powerful Java class library to extend the abilities of those languages. If you are a Java language programmer, you now have the ability to ship applications that your customers can significantly and dynamically customize. The synergy between the Java platform and scripting languages produces an environment in which developers and end users can collaborate to create more useful, dynamic applications.


The Janus platform provides wrappers to several the script language interpreters that are compliant with the JSR 223. For the interpreter that are not JSR 223, their integration in the Janus platform may require more works, but it is possible. See the tutorial "Adding a script interpreter in Janus" for details.

Janus Features for Scripting Interpeters

It is easy to integrate a script language interpreter in the Janus platform if it is compliant with the JSR 223.

The Janus platform must provide an extension of the script language interpreter that ensures:

  1. all the scripts are executed in the context of a single agent;
  2. there is no sharing of variables between two agent execution contexts.
  3. the functions defined in the Janus platform API are accessible from the scripts.


In addition to the extension of the script interpreter, the Janus platform also provides an extension of the Agent class that is dedicated to the execution of a script. In this case, the functions activateAgent, liveAgent</end>, and <code>endAgent are the script equivalents to the three Java functions of the agent's life cycle (aka. activate, live, and end).

Adding a Script Interpeter into Janus

The tutorial "Adding a Script Interpreter into Janus" details how to write the Java code to support a new script language.

Supported Script Languages

2016-01-24SARL 0.3.1 and Janus 2.0.3.1 are available.
2015-11-30SARL 0.3.0 and Janus 2.0.3.0 are available.
This page was last modified on 25 April 2013, at 11:42. This page has been accessed 10,004 times.
Copyright 2010-2017 © Janus Core Developers - Privacy policy