Valve for evaluating scripts using the Oracle Nashorn scripting engine included in JDK 8.

Supported scripting languages depends on the configuration and version of the Java Runtime.

The following languages are supported on all platforms:

  • JavaScript (application/javascript)
  • ECMA

Valve operates on the Current Item Set and will process all Items surviving the common item filtering rules.


Name Description Default value Mandatory Supports property expansion
mime_type Mime type of script. Used for looking up compatible script engine. Yes No
script Inline script No No
script_path Path to script No No

Script execution

The following object are in context during script execution:

  • flow
  • log
  • itemFactory (helper for creating items)
  • request
  • attributes
  • session

For more information about script execution, see Server scripting reference.

Example Configuration (Simple inline)

  "name": "ScriptEvalValve",
  "enabled": "true",
  "config": {
    "mime_type": "application/javascript"
    "script_path": "console.log('From inline script');"

Example Configuration (path)

  "name": "ScriptEvalValve",
  "enabled": "true",
  "config": {
    "mime_type": "application/javascript"
    "script_path": "src/js/test.js"

Example Configuration (script)

 * JavaScript that creates an LDAP compatible "user item" based on
 * an input parameter called ‘id’.
// Get input parameter
var id = flow.getParameter('id');
// Create DN for item (to be used as
var dn = 'cn=test_' + id + '_cn,ou=test,dc=example,dc=com';
// Create item using factory
var item = itemFactory.createItem(dn);
// Set item properties - all based on the supplied id
item.addProperty('objectClass', 'inetOrgPerson');
item.addProperty('cn', 'test_' + id + '_cn');
item.addProperty('sn', 'test_' + id + '_sn');
item.addProperty('mail', 'test_' + id + '');
item.addProperty('uid', 'test_' + id);
item.addProperty('userPassword', 'password' + id);
item.addProperty('description', "Auto generated user with password 'password" + id + "'");
// Add item to flow
// Done!

Example Configuration (inline)

This example will increment the numeric value of the item property adminDescription.

     "name": "ScriptEvalValve",
          "config": {
               "mime_type": "application/javascript",
               "script": "var newValue = parseInt(flow.items().get(0).getPropertyValue('adminDescription')) + 1;flow.items().get(0).replaceProperty('adminDescription', newValue);"