Chapter 31. Scripting
JBoss Data Grid includes a method of storing scripts on servers, allowing remote clients to execute scripts locally with the JDK's
javax.script.ScriptEngines. By default the JDK comes with Nashorn, capable of running JavaScript; however, this may be extended to run any JVM language that offers their own ScriptEngine.
31.1. Accessing the Script Cache Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Scripts are stored in a special, protected cache entitled
___script_cache. As this is a protected cache only loopback requests or connections with authorization enabled will be allowed to access the cache.
The following requirements must be met to connect to the
___script_cache remotely:
- A user has been defined with the
___script_managerrole. - The client has a secure connection to the server; this may be attained by following the instructions in Section 20.7, “Securing Interfaces”.
- Authorization has been enabled on the cache-container.
Example 31.1. Configuring the Server for Access the Script Cache
The following example covers configuring the server to access the script cache, using the
DIGEST-MD5 method of securing the Hot Rod connector.
- Add a user to the server as follows:
- Execute the
$JDG_HOME/bin/add-user.sh(Linux) or$JDG_HOME\bin\add-user.bat(Windows) script. - Enter
bat the first prompt to create anApplicationRealmuser.What type of user do you wish to add? a) Management User (mgmt-users.properties) b) Application User (application-users.properties) (a): b
What type of user do you wish to add? a) Management User (mgmt-users.properties) b) Application User (application-users.properties) (a): bCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Follow the prompts to define the desired username and password for the user.
- When prompted for the groups enter
___script_managerfor this user:What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]: ___script_manager
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]: ___script_managerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- Secure the communication between the client and server. As this example is using
DIGEST-MD5the instructions in will be followed. The following snippet demonstrates the necessary xml configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create the cache manager using the secured connection, as seen in the following code snippet:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow