Script compilation and caching
You create scripts by using the Automation Scripts application. You can write a script or import script code. After you save the script in the Automation Scripts application, the script is compiled, saved to the Maximo® database, and cached into memory.
Script compilation
The scripting framework uses the JSR223 specification. When a script is run, the interpreter is given the script code. The interpreter loads, evaluates, and runs the script code. If this sequence of tasks is performed every time that a script is run, running the script becomes inefficient, and business application responsiveness is adversely impacted. Instead of using this approach, the scripting framework compiles and caches the script. Script compilation immediately reads, evaluates, and compiles into intermediate bytecode in a single action. After this intermediate bytecode is cached, significant time is saved because when you run the script, the system no longer needs to load and evaluate the script code.
Intermediate bytecode
The ability to compile a script depends upon support available in the underlying scripting engine. Maximo Manage includes the Nashorn JavaScript and Jython scripting engines, both of which support compiling a script into Java™ byte code. Other scripting engines might not offer the same support.
Script cache
Maximo Manage implements a script cache that loads the Java bytecode representation of a script into memory. This cache enables running the script to be more efficient. The script cache is refreshed under the following conditions:
- A launchpoint and script are created by using the Automation Scripts application
- An existing script is modified and saved in the Automation Scripts application
- The application server starts up Maximo Manage
The script cache adheres to the Maximo Manage standard caching mechanism, and script changes are automatically propagated to all Java virtual machine (JVM) instances in a clustered environment.
Running scripts
At run time, the scripting framework runs the script using the appropriate script language interpreter. If an error is encountered, statements and traces about the error are written to the application server console or to the product log file if the file is enabled. The script stops when it encounters the first error. Script run time is always written in milliseconds.