1.3. JBoss ON CLI Scripts and JBoss ON Server Scripts

There are two major ways to access the remote API: through the JBoss ON CLI and through a separate JBoss ON server script.
The scripts themselves are more or less identical, with the exception of some methods that are available when the JBoss ON CLI is run interactively. Both CLI scripts and server-side scripts are written in JavaScript and use the remote API primarily, with support from the domain API for tasks like searches.
The main difference is in how the scripts are invoked:
  • The JBoss ON CLI can be run manually, execute a script file, and even be invoked automatically by a system tool like cron. The CLI can connect to to any JBoss ON server and can be run remotely.
    Essentially, the CLI is a script execution engine. It exposes the remote API in a scripting language, which makes it more convenient to interact dynamically the JBoss ON server.
  • Server-side scripts are uploaded into a content repository, managed in the JBoss ON server database, and are then invoked in response to a fired alert. Even though the server-side scripts are located on the server, they still use the same APIs to communicate with the server as other CLI scripts.

1.3.1. Using CommonJS with JBoss ON CLI and Server Scripts

JBoss ON also supports use of CommonJS module loading mechanism for expressing dependencies among scripts. CommonJS is supported by both the CLI and for server scripts using the require function to locate and load scripts using variables.
Use of the legacy exec function in the CLI interactive session, while still supported, is not the preferred method. It is recommended to port scripts to the loading mechanisms supported by CommonJS as they are more secure, portable and extensible.
For more information about using CommonJS, a list of script sources and their compatibility with the CLI and server scripts, as well as how to locate and load scripts, refer to Chapter 6, Using Script Modules for Dependencies and Loading Custom Functions.