This component is used for executing BeanShell Scripts. The BeanShell script to be executed is specified using the Custom Property Sheet (CPS). This component executes the script on documents it receives as input and returns the result.

Icon

The component uses the document object to get the content and properties of the message. The result after executing the script should be set back onto the document object.

Configuration and Testing

Interaction Configuration

Beanshell microservice configuration can be edited in the Configuration Property Sheet (CPS). The figure below illustrates properties in the Interaction Configuration panel with Expert Properties view enabled.


Figure 1: Interaction Configurations panel in BeanShell CPS

Attributes

Pre Processing XSL Configuration

Pre Processing XSL configuration can be used to transform request message before processing it. Click the ellipses button against the property to configure the properties.

Refer to the Pre/Post Processing XSL Configuration section under the Common Configurations page for details regarding Pre Processing XSL configuration and Post Processing XSL configuration (below).

Post Processing XSL Configuration 

Post Processing XSL configuration can be used to transform the response message before sending it to the output port.

Process Message Based on Property

The property helps components to skip certain messages from processing.

Refer to the Process Message Based On a Property section under the Common Configurations page.

Read Script from file?

If enabled, Script file path property appears where you can provide the location where the script file is saved.

Script File Path

Provide the complete path of the BeanShell Script file (file should have .bsh extension) which you want to execute.


Figure 2: Script file path property to provide the location where the script file is saved

BeanShellScript 

If Read Script from file ? property is disabled, populate the BeanShellScript property with the BeanShell Script.

Replace Control Characters

If this property is enabled, Control Characters present in the input will be replaced by a string representation of the same value during script evaluation. This is an expert property.

Cleanup resources (excluding connection) after each document

This closes all the resources except for the connection after every request. If the less processing time is more important the less memory usage, then it is recommended to disable this property and vice versa.

For more details, refer to the respective section under in the Common Configurations page.

Target Namespace

Refer to the Target Namespace section under the Common Configurations page. 

Monitoring Configuration

Please refer to the Monitoring Configuration section in Common Configurations page.

Scheduler Configuration

Please refer the respective section in Common Configurations page.

Transport Configurations

Please refer the respective section in Common Configurations page.

Icon

Transport Configurations panel will be available only if scheduling is enabled in Scheduler Configurations panel

Error Handling

Please refer the sections Request Processing Error and Invalid Request Error in the Error Handling section of Common Configurations page for details.

Sample Input and Output

The configuration can be tested by clicking the Test button in the Interaction Configuration panel.

Below is a sample BeanShell script.

Below are the sample input and the output respectively for the above script.


Figure 3: Sample Input Message


Figure 4: Response Generated

Functional Demonstration

Scenario 1

Configure the BeanShell Script as described in Configuration and Testing section and use feeder and display component to send sample input and to check the response respectively.

In the example given below, the script used is the same as that is provided in the Sample Input and Output section.


Figure 5: Scenario demonstration with sample input and output

Scenario 2

This sample demonstrates accessing an input message.

Configure the component with the following script.

Figure 6: Sample BeanShell Script


Figure 7:
Sample Input message


Figure 8:
Response Generated

Useful Tips

  • Input message content and properties can be accessed using document object. For example, 'document.getText()' returns input message content. To access a message property named 'TestProperty, 'document.getRecord().getProperty('TestProperty')' returns the value of the property.
  • Message properties can be set using 'setProperty' method.
  • Message properties which are set on input message also appear on output message unless they are changed in the script. For example, if a property named 'TestProperty' is present on input message then output message also contains the property unless it is changed in the script provided.
  • If there is no return value in the script, the input record is sent as output message with empty message content.
  • The component uses the document object to get the content and properties of the message. The result(return value) after executing the script is set as output message.


Adaptavist ThemeBuilder EngineAtlassian Confluence