The Rhino container
MPF uses Rhino as the engine for running the JavaScript script used to implement adapter procedures.
Rhino is an open source JavaScript container developed by Mozilla. In addition to being part of Java 6, Rhino has two other advantages:
- It compiles the JavaScript code into byte code, which runs faster than interpreted code.
- It provides access to Java code directly from JavaScript. For example:
var date = new java.util.Date(); var millisec = date.getTime()Global variables are handled according to the following rules:
- In the same user session (for example, an application loaded in a browser), the values of global variables persist from one method call of an adapter to another method call of the same adapter (that is, they are not reset).
- If we create two different user sessions that connect to the same adapter (for example, by opening the same app in different browsers or devices), every user session holds its own global variable state.
- If a user session expires, the Rhino session expires, and variables are no longer defined.
Parent topic: Implementing adapter procedures