The Script Connector enables you to write our own Connector in JavaScript.
A Script Connector must implement a few functions to operate. If you plan to use it for iteration purposes only (for example, reading, not searching or updating), we can operate with two functions only. If you plan to use it as a fully qualified Connector, implement all functions. The functions do not use parameters. Passing data between the hosting Connector and the script is enabled by using predefined objects. One of these predefined objects is the result object, which is used to communicate status information. Upon entry in either function, the status field is set to normal, which causes the hosting Connector to continue calls. Signaling end-of-input or error is done by setting the status and message fields in this object. Two other script objects are defined upon function entry, the entry object and the search object.
When you modify a Script Connector or Parser, the script gets copied from the Library where it is stored, into our configuration file. This enables you to customize the script, but with the caveat that new versions are not known to our AssemblyLine.
One workaround is to remove the old Script Connector from the AssemblyLine and reintroduce it.
The Config Instance (RS object) that is running.
The AssemblyLine this Connector is a part of
This object gives you access to the configuration of this AssemblyLine component, and its Input and Output schema -- note that the getSchema() method of this object has a single Boolean parameter: true means to return the Input Schema while false gets you the Output Schema.
The entry object corresponds to the conn Entry for a Connector (or Function, when scripting an FC.)
See The Entry object for more details.
The search object gives you access to the searchCriteria object (built based on Link Criteria settings.) See The Search (criteria) object for more details.
A reference to this Connector.
This could be useful for example when returning multiple Entries found in the findEntry() function, with code similar to this:
function findEntry() { connector.clearFindEntries(); // Use the search object fo find Entries, and for ( entry = all Entries found) { connector.addFindEntry(entry) } if (connector.getFindEntryCount() == 1) result.setStatus(1); else result.setStatus(0); }
The following functions can be implemented by the Script Connector. Even though some functions might never be called, it is recommended that you insert the functions with an error-signaling code that notifies the caller that the function is unsupported.
In order to support Schema discovery your Script Connector or -FC can contain code like this:
function querySchema() { config.getSchema(true).newItem("name-in"); config.getSchema(true).newItem("address-in"); config.getSchema(false).newItem("name-out"); config.getSchema(false).newItem("address-out"); }
This would create two items in the input and output schemas respectively. Check the SchemaConfig and SchemaItemConfig API (in the Javadocs) for more details.
According to the various modes, these are the minimum required functions we need to implement:
Mode | Function implement |
---|---|
Iterator |
selectEntries() |
AddOnly | putEntry() |
Lookup | findEntry() |
Delete |
findEntry() |
Update |
findEntry() |
CallReply | queryReply() |
The Connector needs the following parameters:
With this parameter checked (which is the default) the behavior of this Connector changed in TDI v7.1. If we need global variables to be reinitialized along with the Connector, we should either uncheck this parameter, or set these variables inside the initialize() method.
Navigate to the root_directory/examples/script_connector directory of the IBM TDI installation.
Script Parser,
Scripted Function Component,
"JavaScript™ Connector" in IBM TDI V7.1 Users Guide.